Hello,
I am trying to read several files using multiple audioplayers with minim library.
There are 4 .wav files corresponding to a zone, when one plays the others stop.
I am stuck with the index and would very much appreciate some help.
Thanks a lot in advance !
best, laurent
import ddf.minim.*;
Minim minim;
String [] fileNames = {"MOUSE", "WORDS", "FLOW", "VORTEX"};
int numSounds = fileNames.length-1;
int Border = 50;
/**AudioPlayer sounds1;
AudioPlayer sounds2;
AudioPlayer sounds3;
AudioPlayer sounds4;*/
AudioPlayer [] sounds = new AudioPlayer[numSounds];
int idx;
void setup () {
size(1080, 1080, P2D);
minim = new Minim (this);
/*sounds1 = minim.loadFile("MOUSE.wav");
sounds2 = minim.loadFile("WORDS.wav");
sounds3 = minim.loadFile("FLOW.wav");
sounds4 = minim.loadFile("VORTEX.wav");*/
for (byte idx = 0; idx != numSounds;
sounds[idx] = minim.loadFile (fileNames [idx++] +".wav"));
}
void draw() {
background (255);
fill(255, 0, 0);
rect(25, 25, 50, 50);
fill(0, 0, 255);
rect(125, 25, 50, 50);
}
void mouseMoved() {
if (mouseX > Border && mouseX < 350) {
sounds [(int)(idx)].play();
println("sound0:"+sounds);
} else if (mouseX < 750) {
} else {
}
if (mouseX < Border && mouseX > height-Border) {
}
}
void stop() {
for ( byte idx = 0; idx != numSounds; sounds[idx++].close() );
minim.stop();
super.stop();
}