We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have two seperate files that play audio on repeat at dealyed intervals. I need them to both begin at the same time and am not sure about how to do this?
First file:
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.*;
Minim minim;
AudioPlayer player;
void setup()
{
size(512, 200, P3D);
minim = new Minim(this);
player = minim.loadFile("bell.mp3");
delay(10000);
}
void draw()
{
player.play();
delay(10000);
player.rewind();
background(0);
stroke(255);
}
The second file is similar but with different delays:
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.*;
Minim minim;
AudioPlayer player;
void setup()
{
size(512, 200, P3D);
minim = new Minim(this);
player = minim.loadFile("clapping.mp3");
delay(4000);
}
void draw()
{
player.play();
delay(4000);
player.rewind();
background(0);
stroke(255);
}
Is there a way of stitching these together or do i make another file that selects them both to play at the same time? I'm at a bit of a loss here!
Answers
You could run each in a thread running in one umbrella program. See http://wiki.processing.org/w/Threading for info on using threads
Technical FAQ -> Sequencing and timing
Avoid using delay(), blocking instruction with very rare practical usage (was almost removed from Processing 2.0...).