Syncronize metronomes
in
Programming Questions
•
3 years ago
Hi
I am trying to build a simple metronome. My code is
i also have a virtual metronome which is shown on the screen
My problem is that after some seconds it appears a delay between the two countings.
Why is this happening and how can i deal with it?
Thank you.
I am trying to build a simple metronome. My code is
- void keyPressed()
{
if (key == 'c')
{
metro1 = minim.loadFile("1st metron.mp3",buffersize);
metro1.loop(tempo);
}else if(key == 'v')
{
metro1.close();
}
}
i also have a virtual metronome which is shown on the screen
- ///////////////////////////////////////METRONOME////////////////////////////////////////
if(millis()-start >= tempo)
{
start = millis();
counter++;
xpos = xpos+width/17;
if(xpos>=width)
{
xpos=2*width/17;
}
if(counter==5)
{
counter=1;
}
My problem is that after some seconds it appears a delay between the two countings.
Why is this happening and how can i deal with it?
Thank you.
1