The BeatTracker is a C++ implementation of a beat-tracking algorithm that adapts to QLC+'s AudioCapture contract. It processes interleaved int16 PCM input and provides two main outputs: a boolean indicating if a beat occurred (driving beatDetected()) and a BPM estimate via the bpm() getter.
The system consists of two main stages connected by an onset-strength stream:
BeatOnsetExtractor: Processes audio in 512-sample hops. It uses a 4096-sample Hann window FFT, analyzes energy increases across three frequency bands (low, mid, high), and applies per-band saturation to ensure backbeats (like kick/snare alternation) are detected reliably.AutoBpmDetector: Analyzes the onset stream every 2 seconds of audio time using an 8-second window. It uses unbiased autocorrelation and a harmonic comb score on a fractional BPM grid (50–240 BPM) to estimate tempo. A temporal belief filter and an 'octave-raise walk' are used to ensure stability and resolve octave ambiguities.
Instead of reacting to individual onsets, the tracker emits beats based on a predicted beat grid, which ensures steady output even on syncopated material.
/*
Conceptual flow:
int16 PCM blocks -> BeatOnsetExtractor -> onset value per 512-sample hop
|
v
AutoBpmDetector -> BPM estimate,
confidence,
predicted beat grid
*/