We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've started on a project to create a music sequencer with minim using instrument classes and playNote functions etc. I've got a sequence of notes working ok, but I have no way of looping them. Here's the main code:
import ddf.minim.*;
import ddf.minim.ugens.*;
Minim minim;
AudioOutput out;
Delay myDelay;
int i;
int endSeq;
public void settings() {
size(800, 300, P2D);
}
void setup() {
minim = new Minim(this);
out = minim.getLineOut();
myDelay = new Delay(1.5,0.5, false,false);
bassSeq(); // starts bass sequence function
chordSeq(); // starts chord sequence function
}
void draw() {
}
And here's the bassSeq function which describes the whole bass sequence:
void bassSeq(){
float[] stepArray = {0.00, 0.75, 2.00, 2.5, 2.75, 3.5, 4, 4.5};
float[] decayArray = {1.0, 0.5, 0.5, 0.5, 0.5, 0.2, 0.5, 1.0};
float[] noteArray = {C2, F2, E2, G2, B2, C2, C2, B2};
for (i = 0; i <= 7; i++){
out.pauseNotes();
out.setTempo(125);
out.playNote(stepArray[i], decayArray[i], new BassInstr(noteArray[i], 0.5, out ) );
out.resumeNotes();
}
}
The problem is, if I put these functions in setup, they only play once. What ideally I'd want to do is iterate back to the start of i=0 so it gives the instruments the sequence from the start of the array after it is finished one loop. If I put the sequence functions in the draw loop, it sends the instrument notes incredibly fast (prob around 60fps if that's the default for draw). I've put a delay() function in the draw loop which does actually loop the music after the time but there's no way of giving delay a number that is totally accurate so it loops accurately.
Some help would be appreciated.
Answers
Does out have a isPlaying property?
Then check it in draw
If it's false call bassSeq
Avoid double questions/ posts
I think isPlaying only applies to audio files, I can't get processing to recoginise the function.
Please link between crossposts: http://stackoverflow.com/questions/40743012/creating-a-basic-music-sequencer-with-minim-library-in-processing-trouble-with
Ended up getting it working by adding a variable to the note startime parameter, so once the last item of the array is passed to the playNote function, x is reset and the total number of steps is added to each consecutive startime value, like so:
curiosity :
could you post your entire code in one piece please?
also remember, you can hit ctrl-t in processing to get better indents
Thanks.
Chrisir
Sure. It's in seperate tabs so might be a bit messy as a whole
but what are the values for
?
and what is Delay?
thanks!
I created a list of variables that contain the note name and their corresponding frequency values. This saves me from having to find the frequency of each note I want to play.
'Delay' is just an effect class with minim. It was a remaining piece of code from a tutorial I was doing, it's not used in this case.
thanks.
but it still doesn't run.
Now I get an error for :
maybe because ChordInstr is not an Instrument?
How can I make it work?
What does the error say?
The command playNote expects float, float, Instrument
i need to check, maybe I know why
does the sketch run for you?
message me your email i will send you zip.
I, too, would like to learn from your code. Thanks for sharing what you've posted so far. Any chance you could post the whole thing? By which I mean enough to make this fragment work.