Author Topic: taptation code and theory  (Read 1134 times)

alparent

taptation code and theory
« on: February 26, 2015, 04:22:53 PM »
I know there are a lot of info on the Taptation and that the code is not open source.
But I'm trying to understand and learn how I could use my Arduino to do more then blink LEDs.
I'd like to understand and learn how it's done.

Any help would be appreciated.

Transmogrifox

Re: taptation code and theory
« Reply #1 on: February 26, 2015, 05:18:30 PM »
You might find this interesting:
[url]http://forum.43oh.com/topic/2627-simple-tap-tempo/[\url]

The concept is pretty simple:
Set interrupt to call an interrupt routine on rising edge of input pin.
Set initial value in a timer.

Next time the interrupt happens (button pushed):
Check if timer overflowed.  If so, reset the timer and exit ISR.

If it didn't overflow, then you record the number of counts and that is the period of your tempo.

Now most tap tempo implementations average the times so you even out the "jitter" in the timing.l  Usually it is an average of 4 taps, so ...
You have the time between two taps, then store it into a 4-element circular buffer.  Every new element overwrites the oldest so you always have 4 counter values.

4 is easy to average because you can add all of them together then right shift twice (right shift is divide by two)  and the remaining number is your average.

This average value is used to set a different timer to toggle an output pin every time it expires. 

More complex things would be to set the frequency on a digital LFO and output the digital LFO value on a PWM pin.

Probably the first thing would be to flash an LED in tempo with the tap tempo pin.
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.