Repository navigation
feat: keep <level> and <footnote> in mx::api - #561
Merged
Merged
Conversation
Add LevelData and FootnoteData, and an optional level and footnote on NoteData, LyricData, BarlineData, FigureData, FiguredBassData, PartGroupData (start element), DirectionData (<direction> only) and ChordData (the <harmony>, shared by a direction's chords: the reader copies it onto every chord, the writer takes the first chord that has one). One helper pair in mx::impl reads and writes the three core editorial groups; writers copy the group so <voice> is kept. A DirectionData whose level or footnote has no <direction> to go on reports droppedData. Remove NoteData::miscData and its ##misc-data## footnote encoding. A note's <footnote> is now NoteData::footnote. Claude-Session: https://claude.ai/code/session_01A8XRpcx6L2kGcYfiUhYJ8V
Round-trip fixtures for each host, a parenthesized rest, a note with level, footnote and voice together, the harmony first-chord rule, and the dropped-direction diagnostic. Pin synthetic/level.3.0.xml and level.4.0.xml in the api round-trip baseline. Claude-Session: https://claude.ai/code/session_01A8XRpcx6L2kGcYfiUhYJ8V
The chords of one direction share one <harmony>, so the writer uses the first chord's level and footnote; a later chord with a different one now reports valueAdjusted, naming the chord used. Reword the DirectionData and FootnoteData comments for a musician. Test a text-only footnote, a figure footnote, a footnote-only dropped direction, and that a direction with level, footnote and voice writes without diagnostics. Claude-Session: https://claude.ai/code/session_01A8XRpcx6L2kGcYfiUhYJ8V
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.
AI Summary
mx::api now reads and writes MusicXML's
<level>and<footnote>. That covers the parenthesized rest from #559 (<level parentheses="yes"/>on a rest), along with the other editorial uses of the two elements.LevelData(text, reference, type, parentheses, bracket, size) withLevelType { unspecified, start, stop, single }inLevelData.h, andFootnoteData(text, position, font, color, justify, enclosure, xml:space) inFootnoteData.h. The comment aboveLevelDataexplains what the element is for, taken fromdocs/level-element-explained.md.std::optional<LevelData> levelandstd::optional<FootnoteData> footnoteonNoteData,LyricData,BarlineData,FigureData,FiguredBassData,PartGroupData(written on the start element),DirectionData(the<direction>element only) andChordData.ChordData: all chords of one direction are one<harmony>. The reader copies its level and footnote onto every chord. The writer takes each from the first chord that has one, the same rule asprintFrame. When chords disagree, the writer reportsvalueAdjustednaming the chord it used.DirectionData: the writer now builds the editorial group from the level, the footnote and the voice together. A level or footnote on a direction with no direction types has no<direction>to go on, so it reportsdroppedData.EditorialFunctions.h(getLevel,getFootnote,setEditorial) serves all three core editorial groups. Writers copy the group, set level and footnote, and set it back, so<voice>is kept.Converterhas a newLevelTypemap.<attributes>,<notations>,<backup>and<forward>also carry an editorial group in MusicXML, but mx::api does not model them as one object each, so they do not get these fields.Breaking:
NoteData::miscDatais removed, along with the##misc-data##encoding it hid in a note's<footnote font-family>. Code that uses it no longer compiles. A note's footnote is nowNoteData::footnote, and an old file's misc-data footnote reads as a plainFootnoteData.ChordData::miscDatais a separate field and is unchanged.Also:
docs/level-element-explained.mdhad two "own" possessives thatdeslagrejects (main's CI run for #560 was cancelled before fmt-check). This PR removes them so fmt-check passes.Testing
EditorialApiTest.cpp: 14 test cases, 134 assertions. Covers every host with XML fixtures (each field set to a value no other field shares), a parenthesized rest, a note and a direction with level, footnote and voice together, an authored note in voice 2, the harmony first-chord rule and its disagreement diagnostic, a text-only footnote written without attributes, a figure footnote, part-group start vs stop, and the dropped-direction diagnostic for a level and for a footnote.make api-test(native): 10876 assertions in 994 test cases pass.make api-roundtrip(native): 484 of 484 pinned pass, including the newly pinnedsynthetic/level.3.0.xmlandsynthetic/level.4.0.xml.synthetic/footnote.3.0.xmlstill fails, because it sets formatted-text attributes that FootnoteData does not model (xml:lang, rotation, letter-spacing, line-height, dir), so it is not pinned.make fmt-checkpasses.References
<level>in mx::api #559