Tech
How GroovePilot keeps time
For the engineers in the band. Many metronome apps keep time with software timers. GroovePilot keeps time with the audio hardware clock, down to the single sample.
One beat timeline, driven by the audio clock
Only the audio clock decides when a beat happens. One timeline counts audio samples, 48 000 per second on iPhone. The screen, flash, pendulum, beat dots and phone haptics read that timeline. They never decide a beat.
What this means when you playNo timer, animation loop or sleep call can move a click.
Integer sample positions, exact maths
Each click’s position is worked out as an exact fraction and placed on the nearest whole sample. At 109 BPM a beat is 26 422.0183 samples long. GroovePilot alternates 26 422 and 26 423 sample intervals so the long-term average is exact.
- 26 422
- 26 423
- 26 422
- 26 422
- …
What this means when you playMeasured drift: 0.0006 ms over 10 minutes at 109 BPM.
A real-time-safe audio thread
While it plays, the audio thread avoids the classic causes of dropouts.
- No memory allocation
- No locks
- No logging or file access
- No waiting on another thread
Click sounds, normal and accent, are synthesised once before playback. Nothing is loaded, decoded or created per beat.
What this means when you playNo timer, animation loop or sleep call can move a click.
Measurements
| Measure | 109 BPM | 300 BPM |
|---|---|---|
| Clicks on the exact correct sample | 1 090 of 1 090 | 3 000 of 3 000 |
| Worst timing error | 0.0103 ms | 0.000 ms |
| Average timing error | 0.0052 ms | 0.000 ms |
| Drift over 10 minutes | 0.0006 ms | 0 |
| Missed / doubled clicks | 0 / 0 | 0 / 0 |
Microphone tempo detection
| Measure | Result | In practice |
|---|---|---|
| Precision when the octave is right | within 0.1 BPM | Within 0.1 BPM when it locks. |
| Time to a stable reading | about 5.5 s | Tap or listen once, then start. |
| Silence, noise, a held tone, random clicks | no tempo shown | It never invents a tempo from silence or noise. |
| Known weakness | half or double tempo | That is why ×2 and ÷2 exist. |
