We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am trying to have two different delays at the beginning and the same delay between each sound on repeat for a project, there is no stop time in this. I tried using delay but it seems to just add the two delays instead of separating them, I was told to use millis(); function but am not sure how to implement this? Any help would be amazing!
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.*;
Minim minim;
AudioPlayer player;
AudioPlayer player2;
void setup()
{
size(512, 200, P3D);
minim = new Minim(this);
player = minim.loadFile("clapping.mp3");
player2 = minim.loadFile("bell.mp3");
}
void draw()
{
background(0);
stroke(255);
player1delay();
player2delay();
}
void delayatstart(){
millis(4000);
}
void player1delay(){
delayatstart();
player.play();
player.rewind();
}
void delayatstart2(){
millis(10000);
}
void player2delay(){
delayatstart2();
player2.play();
player2.rewind();
}
Above is the code I'm trying to use, i replaced my delays with millis and have looked up forums but can't find one to match what I'm looking for!
Answers
1st stop, even before looking at the forum, is take a look at http://processing.org/reference/ .
Never seen millis() w/ some parameter before:
http://processing.org/reference/millis_.html
Crossposted: http://stackoverflow.com/questions/23339114/using-millis-instead-of-delay-inprocessing-for-different-delays
there are three processing libraries available for timing events. under 'Utilities' here:
http://www.processing.org/reference/libraries/
specifically
http://multiply.org/processing/
https://github.com/heuermh/executor-processing
https://github.com/dhchoi/processing-countdowntimer
perhaps try one of those (although they don't look simple, so maybe choose the one with the best examples)
(i'd like to see this in processing proper, just something simple like
after(ms, "myMethod");
orevery(ms, "myMethod");
would help. the number of times we see something like the above posted and people hacking things together with millis() depresses me...)Here's an example that uses millis: http://stackoverflow.com/questions/12417937/create-a-simple-countdown-in-processing/12421641#12421641
You could also accomplish it using the thread() and delay() functions:
http://forum.processing.org/two/discussion/1725/millis-and-timer
So that's the third topic you make on the exact same subject. I answered an old one, because there was no sign of activity, wasting my time. Avoid to do multiply threads on the same topic, please. People loose time and information is diluted.