fix(song): make bass detection instrument-type-aware, not name-only - #1019
Conversation
Editor now authors an arrangement's instrument as first-class data (a manifest 'type' field). Core dropped it: the sloppak loader never read 'type', and 'is this a bass?' was defined three different ways across call sites (name-only in note_pitch_midi and the highway scale-degree path; path_bass+name in bass selection; name-only in arrangement_string_count). So an authored type=bass chart not named 'bass' got 6-string lane counts and guitar open-string MIDI. - Add optional Arrangement.type; sloppak load_song lifts the manifest type onto it - Add arrangement_is_bass(arr) = type=='bass' OR path_bass OR 'bass' in name (None/whitespace safe), and route string count, note_pitch_midi, the highway scale-degree base, and bass-player selection through it - Back-compat: no bass signal -> unchanged 6-string / guitar behavior Companion to editor #335 (first-class instrument type). Scale degrees are display-only and never feed a grader. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughChangesBass arrangement type detection
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_song.py (1)
1224-1224: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMove the local import to the module level.
Consider moving
from song import arrangement_is_bassto the top of the file alongside the other imports for consistency and to avoid hidden dependencies within the test function.♻️ Proposed refactor
- from song import arrangement_is_bass(And add
arrangement_is_bassto the existing imports fromsongat the top of the file).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_song.py` at line 1224, Move the arrangement_is_bass import from inside the test to the module-level import section, adding it to the existing song imports; remove the local import while preserving the test’s behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_song.py`:
- Line 1224: Move the arrangement_is_bass import from inside the test to the
module-level import section, adding it to the existing song imports; remove the
local import while preserving the test’s behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e006e554-4de8-442a-b810-3f9b3d5b60a5
📒 Files selected for processing (4)
lib/routers/ws_highway.pylib/sloppak.pylib/song.pytests/test_song.py
Companion to editor PR #335 (feedBack-plugin-editor), which makes a track's instrument first-class data (a manifest `type` field) instead of a name guess.
Problem
Core dropped the authored instrument type, and "is this a bass?" was defined three different ways across call sites:
The sloppak loader (the editor's save format) never read the manifest `type` at all. So an editor-authored bass arrangement not named "bass" (e.g. "Low End") would render with 6-string lane counts and guitar open-string MIDI — disagreeing with the editor, which lays out 4 lanes.
Fix
Scale degrees are display-only and never feed a grader.
Tests
Added to `tests/test_song.py` (each fails pre-fix, passes post-fix): authored `type=bass` and `path_bass` both yield 4-string count and bass open-string MIDI; `arrangement_is_bass` signal-safety (case/whitespace/None); a guitar no-regression case.
Gate: `pytest tests/` → 2733 passed, 4 skipped, 0 failed.
Deferred (not in scope)
`compute_smart_names` still doesn't fold in `arr.type`, so a `type=bass` part named "Low End" displays as "Track 1" rather than "Bass" — a label nicety only; lanes, pitch base, and player selection are all correct.
🤖 Generated with Claude Code
Summary by CodeRabbit