Hi.
How would you make a timer countdown while stroking to the beat?
I made this little tool:
Code:
def metronome = { speed ->
def baud = 100
def timeLeft = timePerSquare
def counter = 0
def speedBaud = (int)((1/speed)*baud)
while(timeLeft>0){
if(counter%baud==0){
timeLeft--
show("Time: "+timeLeft)
}
if(counter%speedBaud==0){
playBackgroundSound("tom.wav")
}
counter++
sleep((int)(1000/baud))
}
}
It basically displays the time left, and the sound is independent from the timer. The problem is that there is a small delay when using the show(), causing it to beat irregularly. If i comment this line out it works perfectly.
Is there a way to minimize the delay, or another way to optain the same effect? In fact, I want there to be a timer countdown, while stroking is sounding while there is a button, which can be pressed before the time runs out.