Tempo histogram (folded to 70–180 BPM)
Algorithm notes
- Novelty: light high-pass (150 Hz), half-wave spectral-flux style: rectified + differencing + positive part, MA smooth 10 ms, downsample ~200 Hz, z-score.
- Sliding ACF: window 8 s, step 1 s, search 60–200 BPM. Peak picking w/ parabolic interpolation.
- Tempo folding: push estimates to 70–180 BPM via ×2/÷2 octave mapping; histogram + weighted mode by ACF peak strength.
- Global phase: fit grid phase that maximizes novelty at beat instants -> start offset (s) from audio start.
- Metronome: audio tick & visual pulse, sample-accurate scheduling vs
AudioContext.currentTime, synced to playback.
Tips: For tougher material, consider a pre-emphasis, band-pass (100–4000 Hz), or spectral-flux from STFT magnitudes. This version keeps CPU light and works well for 4/4 electronic music.