feat(chords): stem-aware chord + segment-key path (accuracy PR-B4) - #207
Merged
Conversation
Runs chord/key chroma on a bass-removed stem mix (other+vocals) instead
of the full mix when Demucs stems are available. The bassline is the
single biggest polluter of full-mix chroma, so harmonic-source isolation
is the highest-leverage chord-accuracy lever in the baseline audit.
- mix_stems_mono(stems, ('other','vocals')) in analyze_audio_io.py sums
the harmonic stems to mono; None when no stem loads.
- analyze_chords / analyze_segment_key gain a harmonic_mono kwarg; when
present the chroma runs on it. Additive chordDetail.chordSource +
segmentKey[].source ('full_mix' | 'harmonic_stems') record which ran.
- Stems absent -> full-mix path, BIT-IDENTICAL to before (golden diff adds
only the two source keys; chord values unchanged; chords-only corpus
clips hold at ~0.99).
Validation honesty: Demucs model weights are network-blocked in this
sandbox (proxy 403, same restriction as the datasets), so separation
returns None here and the synthetic multi-layer clips exercise the
full-mix fallback, not the harmonic path. The harmonic wiring is proven
by unit tests (mix_stems_mono summing/skip-missing; chordSource +
segmentKey source tagging); the end-to-end accuracy GAIN must be measured
where Demucs weights are reachable (operator machine / CI with network) on
real dense mixes — the synthetic bass is a clean low sine that barely
pollutes chroma anyway. No accuracy improvement is claimed from this
sandbox.
Contract mirrors (tripwire #4): JSON_SCHEMA rows; types/measurement.ts
ChordDetail.chordSource + SegmentKeyEntry.source; backendPhase1Client
chord reconstructor forwards chordSource (segmentKey passes through);
phase1FullPayload fixture; golden re-baselined (structural). Tests:
test_stem_aware_chords. Backend 1306 OK, fundamentals gate green,
frontend verify green.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T4wfz87k6kzJqkKLKZE7YL
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.
The highest-leverage chord-accuracy lever from the baseline audit: run chord and per-segment-key chroma on a bass-removed stem mix instead of the full mix. The bassline is the single biggest polluter of full-mix chroma (measured chord accuracy drops from ~0.65 clean to ~0.5 under a dense mix), and Demucs stems are already on disk under
--separate— so this is an input-array swap, not a re-separation.What
mix_stems_mono(stems, ('other','vocals'))(analyze_audio_io.py) sums the harmonic stems to mono;Nonewhen none load.analyze_chords/analyze_segment_keygain aharmonic_monokwarg; when present, chroma runs on it. AdditivechordDetail.chordSource+segmentKey[].source("full_mix"|"harmonic_stems") record which path ran.sourcekeys (chord values unchanged), and the chords-only corpus clips hold at ~0.99.Validation honesty (please note)
Demucs model weights are network-blocked in this sandbox (proxy 403 — the same restriction that blocks the datasets). So separation returns
Nonehere, and the synthetic multi-layer clips exercise the full-mix fallback, not the harmonic path. I'm therefore not claiming any measured accuracy gain from this environment. What is proven:mix_stems_monosumming + skip-missing;chordSource/segmentKey.sourcetagging whenharmonic_monois passed).The end-to-end gain must be measured where Demucs weights are reachable (operator machine / networked CI) on real dense mixes — the synthetic bass is a clean low sine that barely pollutes chroma, so it wouldn't be a fair test even if separation ran. This mirrors how the whole accuracy program handles the sandbox's network limits.
Contract mirrors (tripwire #4)
JSON_SCHEMA.md rows ·
types/measurement.ts(ChordDetail.chordSource,SegmentKeyEntry.source) ·backendPhase1Clientchord reconstructor forwardschordSource(segmentKey passes through) ·phase1FullPayloadfixture (+ parity gate) · golden re-baselined (structural).Tests
test_stem_aware_chords(helper + source tagging). Backend 1306 OK, default fundamentals gate green, frontend verify green.🤖 Generated with Claude Code
https://claude.ai/code/session_01T4wfz87k6kzJqkKLKZE7YL
Generated by Claude Code