fix(midi): always export SMF as Type 1 (Parallel) - #61
Conversation
export_score declared Type 0 (SingleTrack) for single-track scores, but a dedicated meta/conductor chunk is always emitted (ADR-0003), so the file carried two chunks — spec-invalid for Type 0, which must contain exactly one track. Strict readers rejected such files (notably single-track `generate` output), while multi-track import/complement output stayed valid only by accident of having ≥2 note tracks. Always declare Type 1. Adds a regression test: a single-track export must parse as Format::Parallel with ≥2 chunks. https://claude.ai/code/session_01TTUbGjzD8ysnVnCJnZJE95
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesSMF Header Format Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Problem
A generated single-track riff (
griff generate …) produced a MIDI file thatstrict readers reject with "a type 0 file must contain exactly one track".
Multi-track output (import, complement) opened fine.
Root cause
export_score(core/src/midi.rs) chose the SMF header format from the note-trackcount:
But a dedicated meta/conductor chunk is always emitted (ADR-0003). So a
single-track score serialises to two chunks (meta + 1 note) while declaring
Type 0 — and SMF Type 0 must contain exactly one track chunk. The file is
therefore spec-invalid. Multi-track scores avoided this only by accident of
already having ≥2 note tracks.
Confirmed on a freshly generated riff: header was
format=0, ntracks=2(invalid);after the fix it is
format=1, ntracks=2with two realMTrkchunks.Fix
Always declare
Format::Parallel. One line, plus a comment explaining theinvariant.
Test (TDD, red → green)
export_score_single_track_is_type1_parallel: a single-track score must exportas
Format::Parallelwith ≥2 chunks. Red before the fix (was Type 0), greenafter. Full
griff-coresuite (87 tests) andclippy --all-targetsare clean.This is the first of two fixes for the reported import/export issues; the GP6
string-indexing pitch fix follows in a separate PR.
https://claude.ai/code/session_01TTUbGjzD8ysnVnCJnZJE95
Generated by Claude Code
Summary by CodeRabbit