feat: preserve source voice names in mx::api - #422
Open
webern wants to merge 2 commits into
Open
Conversation
mx::api keys the voices of a staff by index and the writer named every voice from that index, so a voice whose <voice> element said something else lost its name. MusicXML does not require a voice to be named with a number, and a part whose voices are numbered straight through its staves rather than restarting on each one does not survive renumbering either. VoiceData gains a label. Empty, the default, numbers the voice from its index as before. The reader fills it in from the <voice> element and then drops it again wherever it is just the number the writer would have used anyway, so the common case stays empty. Which notes get a <voice> element does not change, so a source that leaves it off a chord member still does. The one addition is a voice where no note carried a number: there the label is the only thing that can ask for the element, so it does. Pins two more files in the api round-trip baseline.
5 tasks
…nto claude/mx-api-roundtrip-corpus-9pkrg6-05-voice-label
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.
Human Summary
Allows voices to be labeled instead of numbered.
Summary
mx::apikeys the voices of a staff by index, and the writer named every voice from that index. A voice whose<voice>element said something else lost its name. MusicXML does not require a voice to be named with a number at all --<voice>FirstVoice</voice>is legal, and some programs write it -- and a part whose voices are numbered straight through its staves rather than restarting on each one does not survive renumbering either.VoiceDatagainsstd::string label. Empty, the default, numbers the voice from its index exactly as before. The reader fills it in from the<voice>element and then drops it again wherever it is just the number the writer would have used anyway, so the common case comes back empty and the field stays out of the way.The name belongs on the voice, not on each note: containment is what states voice membership in this api, and a per-note name would let notes in one voice disagree about which voice they are in.
Which notes get a
<voice>element does not change, so a source that leaves it off a chord member (Sibelius does this) still does. The one addition is a voice where no note carried a number -- an authored score, or a voice named with a word -- since there the label is the only thing that can ask for the element.Non-breaking: one new field defaulting to the behavior mx had before.
NoteData::userRequestedVoiceNumberis untouched.Round-trip corpus
Adds 2 files to
roundtrip-baseline.txt(405 -> 407):musuite/testChordNoVoice.xmlandmusuite/testStringVoiceName.xml.musuite/testVoiceMapper1.xml, the third file the classifier listed undervalue:voice, is not fixed here, and this is not the change that will fix it. That file writes voices 4, 5, 4 back to back with no<backup>between them. mx's reader buckets voices by counting backups, so all three notes land in one api voice, and one api voice can only carry one name. Splitting them into separate voices would be correct but would make the writer emit<forward>/<backup>between them, which the source does not have. Getting that file to round-trip means changing how the reader buckets voices and how the writer interleaves them -- a separate piece of work, worth its own issue.Testing
VoiceLabelApiTest: unlabeled voices numbered from their index, word names round-tripped, a lone voice named 5 written as 5 and stable on a second write, and a name that matches the index dropped on read (*VoiceLabel*: 18 assertions in 4 test cases)make api-test(6332 assertions in 586 test cases)make api-roundtrip(407 passed, 0 failed of 407 pinned)make api-roundtrip-discoverreports exactly the 2 new passes and no regressionsmake fmtReferences