fix: scope spanner number pools to the part, not the staff - #351
Merged
Conversation
MusicXML's number-level type judges concurrency in document order within the part; the staff never enters into it. The spec's own piano example requires a cross-staff slur to take a different number from staff-local slurs it overlaps in document order. SpannerNumberResolver pooled per staff, so two identity slurs overlapping in document order on different staves of the same part both received number 1, and readers that pair endpoints by number within the part (e.g. MuseScore) mispaired them. Drop the staff dimension from the resolver: events no longer carry a staff index, reservations and identity groups live in one pool per part and spanner class, and the cross-staff every-pool-touched reservation logic disappears. New tests pin both directions of the contract: slurs overlapping in document order across staves take distinct numbers, and same-measure slurs on different staves (no document-order overlap) still reuse number 1 as the spec example allows.
Coverage reportCore-dev coverage
|
| Metric | Coverage | Covered / Total |
|---|---|---|
| Lines | 77.8% | 28514 / 36648 |
| Functions | 74.2% | 6352 / 8556 |
| Branches | 50.7% | 22680 / 44751 |
API coverage src/private/mx/{api,impl,utility}/
| Metric | Coverage | Covered / Total |
|---|---|---|
| Lines | 84.5% | 7228 / 8551 |
| Functions | 74.9% | 2511 / 3352 |
| Branches | 52.4% | 6307 / 12042 |
Core HTML report | API HTML report
Commit 6fd3df3b52622df3eadb3ae3088f165be4035538.
gen-quality
|
webern
approved these changes
Jul 13, 2026
webern
left a comment
Owner
There was a problem hiding this comment.
Oops, thank you for fixing my mistake. Nice tests, too.
3 tasks
webern
added a commit
that referenced
this pull request
Jul 19, 2026
## Human Summary Changes the way pedals are modeled into two different things. Pedal marks, which are the old fashioned Ped and * marks, and a separate type for more modern lines. ## Summary `DirectionReader::parsePedal` handled only `PedalType` start/stop and silently dropped `sostenuto`, `change`, `continue`, `discontinue`, and `resume`, even though `core::PedalType` carries all seven tags. This was the last unmodeled item in #324. The shape decision (called for in #324) was to store the pedal type as one fact in one field rather than scatter it across start/stop/other vectors. This replaces the `pedalStarts` / `pedalStops` spanner vectors on `DirectionData` with a single `std::vector<PedalData> pedals`, where each `PedalData` carries a `PedalKind` enum covering every pedal-line type. Each pedal event stands on its own and is placed at its own tick, so the model has no neighbor-dependent meaning. - New `PedalData.h`: the `PedalKind` enum (`start`, `stop`, `sostenuto`, `change`, `continueLine`, `discontinue`, `resume`) and the `PedalData` struct. - Reader: line pedals (`line="yes"`, plus the inherently line-formatting types `sostenuto`/`change`/`continue`/`discontinue`/`resume`) go to `pedals`; sign start/stop still route through `MarkData` as `MarkType::pedal` / `damp`, unchanged. - Writer: a single `emitPedal` maps `PedalKind` back to `core::PedalType`, emits `line="yes"`, and emits nothing for an unspecified kind. Only two corpus files use these types (`lysuite/ly31a_Directions.xml`, `lysuite/ly33a_Spanners.xml`) and both fail first on unrelated features, so this does not flip any file to PASS. It is validated by a focused unit test that round-trips each pedal type through the api. This is a breaking change: it reshapes `DirectionData`'s pedal fields. ## Testing - [x] New `PedalAllKinds` round-trips all seven pedal types through the api; `PedalPlacement` covers placement (`*Pedal*`: 44 assertions in 5 test cases) - [x] Full unit suite passes (5130 assertions in 451 test cases) - [x] api round-trip regression unchanged (284 passed, 0 failed of 284 pinned) ## References - Closes #324 (the `symbol` item from that worklist is tracked separately by #294 and is not included here) - Follows the merged direction-type stack #358–#363 - Part of #208 - Spanner-numbering context: #320, #351
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
Fixes #350.
SpannerNumberResolverpooled spanner numbers per staff, but MusicXML'snumber-leveltype scopes concurrency to the part in document order — its own piano example requires a cross-staff slur to take a different number from staff-local slurs it overlaps. Two identity slurs overlapping in document order on different staves of the same part therefore both receivednumber="1", and readers that pair endpoints by number within the part (e.g. MuseScore) mispaired them.Fix
Drop the staff dimension from the resolver: events no longer carry a staff index, and explicit reservations and identity groups live in one pool per part + spanner class. The cross-staff "reserve in every staff pool touched" logic disappears rather than needing repair.
Fixed File
This file is the same one I posted in the issue, but it now has non-conflicting number levels.
numberlev_2staffpart_fixed.musicxml.txt
Testing
overlappingSlursOnDifferentStavesGetDistinctNumbers— barline-crossing slurs on two staves of one part take numbers 1 and 2 (fails against the unfixed resolver: both came back 1)sameMeasureSlursOnDifferentStavesReuseTheNumber— the spec-blessed reuse case still gets 1/1, guarding against a naive always-increment fixmake test(425 cases),make test-api-roundtrip(224/224 pinned),make fmtCMAKE_UNITY_BUILD=ON, batch size 0) compiles