Skip to content

feat: keep <level> and <footnote> in mx::api - #561

Merged
webern merged 4 commits into
mainfrom
m/mx-level
Nov 25, 2026
Merged

webern merged 4 commits into
mainfrom
m/mx-level

Conversation

@webern

@webern webern commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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.

  • New public types: LevelData (text, reference, type, parentheses, bracket, size) with LevelType { unspecified, start, stop, single } in LevelData.h, and FootnoteData (text, position, font, color, justify, enclosure, xml:space) in FootnoteData.h. The comment above LevelData explains what the element is for, taken from docs/level-element-explained.md.
  • std::optional<LevelData> level and std::optional<FootnoteData> footnote on NoteData, LyricData, BarlineData, FigureData, FiguredBassData, PartGroupData (written on the start element), DirectionData (the <direction> element only) and ChordData.
  • 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 as printFrame. When chords disagree, the writer reports valueAdjusted naming 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 reports droppedData.
  • mx::impl: one helper pair in 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. Converter has a new LevelType map.
  • Out of scope: <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::miscData is 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 now NoteData::footnote, and an old file's misc-data footnote reads as a plain FootnoteData. ChordData::miscData is a separate field and is unchanged.

Also: docs/level-element-explained.md had two "own" possessives that deslag rejects (main's CI run for #560 was cancelled before fmt-check). This PR removes them so fmt-check passes.

Testing

  • New 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 pinned synthetic/level.3.0.xml and synthetic/level.4.0.xml. synthetic/footnote.3.0.xml still 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-check passes.

References

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
@webern webern added ai Issues opened by, or through, a coding agent. api Affects the mx::api layer breaking fixes or implementation that require breaking changes feature new feature request impl Affects the mx::impl layer labels Nov 25, 2026
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
@webern
webern marked this pull request as ready for review November 25, 2026 16:52
@webern
webern merged commit 9fb5738 into main Nov 25, 2026
9 checks passed
@webern
webern deleted the m/mx-level branch November 25, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Issues opened by, or through, a coding agent. api Affects the mx::api layer breaking fixes or implementation that require breaking changes feature new feature request impl Affects the mx::impl layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support <level> in mx::api

1 participant