1
BPM detection
Overlapping 20-second windows are analyzed with multi-threshold peak detection, spectral onsets, and
autocorrelation. Results are clustered and normalized for double/half-time relationships.
2
Cadence mapping
Candidate SPM-to-BPM ratios are scored by tempo-shift size, ratio simplicity, and musical context. The
best mapping is applied, capped at roughly 8% slowdown.
3
Playback
AVAudioEngine with pitch-preserving time-stretching changes tempo while keeping songs in key. Cadence
changes are debounced and playback rate ramps smoothly in steps.