squarewave

Digital Metronome
« on: December 24, 2017, 12:21:58 AM »
I just build a channel strip that includes an 8 LED VU / gain reduction meter. All of the LEDs and tactile buttons are controlled using an Arduino. So I thought it might be neat, just as a sort of easter egg, to add a little code for a digital metronome. This would be a parallel bit of code invoked by holding down one of the tactile buttons.

More specifically, there are two tactile buttons right next to the VU that could be used as controls. Specifically as I press one of the tactile buttons repeatedly, the uC code computes the time between presses and averages that into the running tempo value. Meaning to set the tempo you just press and release this tactile button at the desired rate and that sets the tempo. Then the other tactile button would be used to select the number of beats per measure. So maybe you just press it some number of times to select 4 for 4 beats per measure, or 3 for a waltz or 7 if you want to play "Money" or whatever.

The LED sequence could be like this:

1        ◌ ◌ ● ● ● ● ◌ ◌
2        ● ● ● ◌ ◌ ● ● ●
3        ● ● ◌ ● ● ◌ ● ●
4        ● ◌ ● ◌ ◌ ● ◌ ●
5        ● ◌ ◌ ◌ ● ◌ ◌ ◌
6        ● ◌ ◌ ◌ ● ● ◌ ◌
7        ● ◌ ◌ ◌ ● ● ● ◌
8        ● ◌ ◌ ◌ ● ● ● ●

For example, if I hit the first tactile at a rate of approx. 800ms a few times and then hit the second tactile 4 times in rapid succession to set the number of beats I should get something like this:



So given 8 LEDs and two tactile buttons, is there a way I can improve on this? I know very little about metronomes or even time signatures.