Don't execute the same note multiple times
Beat advances once every 5 frames. Return before executing any audio code if the beat has not advanced on this frame.
@@ -86,9 +86,12 @@ void render(uint32_t time_ms) {
void update(uint32_t time_ms) {
static uint16_t tick = 0;
+ static uint16_t prev_beat = 1;
+ beat = (tick / 5) % 384; // 100ms per beat
tick++;
- beat = (tick / 5) % 384; // 100ms per beat
+ if (beat == prev_beat) return;
+ prev_beat = beat;
for(uint8_t i = 0; i < 3; i++) {
if(notes[i][beat] > 0) {
