feat(temporal): real downbeat detection from onset energy (was 'every 4th beat from index 0')#561
Open
seonghobae wants to merge 1 commit into
Open
feat(temporal): real downbeat detection from onset energy (was 'every 4th beat from index 0')#561seonghobae wants to merge 1 commit into
seonghobae wants to merge 1 commit into
Conversation
…at from index 0') Downbeat times were computed as beat_times[i] for i % 4 == 0 — this blindly assumes the first detected beat starts the bar and never looks at the audio, so a song whose first beat is an upbeat gets every downbeat wrong. Replace with onset-energy phase selection: sample librosa's onset-strength envelope at each beat and choose the bar phase (0..3) with the highest mean onset strength, since downbeats carry the strongest onset. librosa-only, no new dependency. Still assumes 4/4 (documented ceiling; madmom/DBN or meter estimation is the upgrade path for other meters). Unit tests assert the phase is actually chosen from the signal (an accented phase-2 pattern that the old logic would have missed), plus empty and too-few-beats fallbacks. 100% coverage on the module; full engine suite green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RjGVapDZ3k7V7zKYk16P4C
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.
What
Downbeat detection was
beat_times[i] for i % 4 == 0— it blindly treats the first detected beat as the bar's downbeat and never looks at the audio. Any song whose first beat is an upbeat (or isn't 4/4-aligned to index 0) gets every downbeat wrong.Replaced with onset-energy phase selection: sample librosa's onset-strength envelope at each beat, and pick the bar phase (0–3) with the highest mean onset strength — downbeats carry the strongest onset, so this places the bar line where the audio actually accents it.
Why
Downbeats drive the section roadmap and rehearsal cue grid; a systematically-wrong bar line quietly corrupts everything built on top of it.
Scope / notes
# ponytail:), with madmom/DBN or meter estimation as the upgrade path.🤖 Generated with Claude Code