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.