# [sdiy] Tap tempo question

Mattias Rickardsson mr at analogue.org
Tue Feb 2 22:30:51 CET 2021

```On Tue, 2 Feb 2021 at 07:12, Brian Willoughby <brianw at audiobanshee.com>
wrote:

> On Feb 1, 2021, at 16:31, Didier Leplae wrote:
> >... I tap multiple times with the assumption that the multiple taps are
> averaged.

Averaging might seem like a good idea to find the tempo, but if you just
average a number of periods between consecutive pairs of taps, the end
result only depends on the timing of the first and the last tap. The
timings of all intermediate taps get thrown away in the calculation since
they are first added (as one end of a period) and then subtracted (as the
other end of next period).

(If taps occur at times A, B, C, D, E
then the measured periods are B-A, C-B, D-C, E-D.
The average of these periods are (B-A + C-B + D-C + E-D) / 4
which equals (E-A) / 4
meaning the total time between the first and last taps, divided by the
number of periods tapped in between.)

While this would converge over time to a better and better measurement of
the tempo, it converges very slowly and does so only because the total time
increases. If the first tap is badly timed, it will always follow you in
the summing even if later taps are becoming better and better. Sure, it
would have less and less impact along the way, but the only way of getting
rid of the first tap being off-beat is to end the tapping session with a
tap that is exactly equally off-beat. And the other taps don't matter.
Something smells wrong here. Among all imaginable solutions to the problem
- and especially from a practical perspective where a tireless tempo tapper
gets better and better and stops tapping when the timing feels good - this
must be the least good solution.

education way back in time, and a clever trick was introduced in order to
make this type of calculation much more sensible, using all the taps in the
details... very annoying! Does anybody know what kind of solution I'm
after? I won't be able to sleep until this is cleared up. :-)

You can also weight the average so the most recent pair of taps affects the
> average a lot more than older information.

Yes, weighting more recently tapped periods does have a good chance of
giving a better result and a faster convergence.

Another detail that has already been touched upon in the discussion is the
concept of phase (or absolute timing). The tempo isn't the only thing that
can be determined from the tap-tempo button, but the timing of the repeated
taps is often also important. In the example above where only the first and
last tap would be significant when calculating the average period (i.e.,
tempo) and the other taps thrown away, the situation isn't all that bad for
the absolute timing calculation. Here all the taps actually count, and
keeping a steady tapping pace pays off. I'm guessing that some "adaptive"
version of weighting, that both gives a good tempo calculation and
gradually corrects the absolute timing of the LFO/delay (etc) to match the
tapping and the music, is what people almost always would want.

Interesting with tap-tempo mechanisms... similarly to chromatic tuner
functionality in the way that it's a seemingly small and simple task, easy
to describe loosely, easy to have a gut feeling of what one would expect
the behaviour to be, but complex to implement without making something far
worse than those expectations. :-)

/mr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20210202/ab9a4e41/attachment.htm>
```