serious question time.
I made some emitters that blink to the beat of a song, and a formula to get a near-precise delay value for a relay to trigger them.
30000/(tempo/2)
(or tempo divided by 2; 30000, or the maximum delay value, divided by the result of tempo/2)
The problem with this though, is that it has a decimal place or more.
For example, 128BPM is typical in house music. Doing the formula (30000/(128/2)), it returns 468.75. I have to round it up to 469 since events cannot use 468.75; because of this, it starts getting out-of-sync about 30, 45 seconds in.
Is there any way to potentially fix this issue, maybe through another brick occasionally firing some relay that fixes it?
oh and for any overly curious people:
function getBeatDelayPrecise(%v){
return 30000/(%v/2);
}
function getBeatDelay(%v){
return mFloatLength(30000/(%v/2),0);
}