Repository navigation
fix(tempo): Rayleigh prior on tempo detection — kill octave-doubling - #26
Merged
Merged
Conversation
User's lo-fi-swing-hip-hop master detected as 180 BPM instead of the audibly-correct ~90 BPM. Classic tempo-octave-aliasing failure: with a kick on every beat (85 BPM) and a hat on every off-beat (170 BPM events), the autocorrelation surface peaks at BOTH lags — and the unprior'd picker landed on the doubled tempo because the existing octave-voting summed the on-beat AC into the doubled lag's score. Fix: multiply the voted AC by a Rayleigh prior centred at 110 BPM (Klapuri / Davies-style perceptual-tempo prior). The prior's shape peaks where typical music sits and tapers smoothly toward the search limits — drum'n'bass at 170 still wins if its AC is genuinely strong, but lofi/swing at 85 lands on its true octave. Verified on the user's actual master mp3 PCM: 180 BPM → 90.08 BPM. Existing 90/120 BPM click-track tests still green; new regression test reproduces the 85 + 170 hat pattern. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
User's lo-fi swing-hip-hop master (~85-90 BPM by ear) was being detected as 180 BPM. Classic tempo-octave-aliasing failure: with a kick on every beat (85 BPM events) and a hat on every off-beat (170 BPM events), the autocorrelation surface peaks at BOTH lags — and the unprior'd picker landed on the doubled tempo because the existing octave-voting summed the on-beat AC into the doubled lag's score.
Fix
Multiply the voted autocorrelation by a Rayleigh prior centred at 110 BPM (Klapuri / Davies-style perceptual-tempo prior). The prior peaks where typical music sits and tapers smoothly toward the search limits — drum'n'bass at 170 still wins if its AC is genuinely strong, but lofi/swing at 85 lands on its true octave.
Approximate weights:
Verification
On the user's actual master mp3 PCM (16-min lo-fi hip-hop session): 180 BPM → 90.08 BPM.
Existing 90 BPM and 120 BPM click-track tests still pass; new regression test reproduces the 85 + 170 hat pattern.
Test plan
cargo test --releasen/a (TS-only change)npx vitest run --project=unit src/local/render/audio-analysis/analyze.test.ts— 13 tests green🤖 Generated with Claude Code