feat: expose musicxml id attributes in mx::api - #401
Open
webern wants to merge 1 commit into
Open
Conversation
Beginning with MusicXML 3.1 most elements can carry an id attribute that names that one element within the document. mx::api dropped nearly all of them. Add an optional id member to every api type that maps one-to-one onto an element with an id, and read and write it in mx::impl. New id fields: NoteData, MeasureData, ClefData, KeyData, TimeChoice, TransposeData, BarlineData, LyricData, DirectionData, WordsData, SymbolData, RehearsalData, WedgeStart, WedgeStop, SpannerStart, SpannerStop, PedalLineData, CurveStart, CurveContinue, CurveStop, TieLetRing, TupletStart, TupletStop, SoundData and FiguredBassData. A new IdFunctions.h holds the two impl helpers that read and write the attribute. ApiCommon.h explains what ids are for and the uniqueness rule that mx does not enforce. Left out are the elements where placing the id needs a design decision: the grouping elements mx::api does not model (direction-type, notations, articulations, ornaments, technical, beam), the marks folded into MarkData (dynamics, fermata, accidental-mark), harmony and frame (one DirectionData holds several ChordData that serialize into a single harmony), credit (both credit and credit-words carry an id and PageTextData models the pair), and the elements mx::api does not model at all (print, measure-style, grouping, for-part, glissando, slide). synthetic/bracket.3.1.xml and synthetic/dashes.3.1.xml now survive the strict api round trip and are pinned in roundtrip-baseline.txt.
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
Model ID for those cases where the mx::api data model is close enough the MusicXML data model to make that simple.
Caveats:
Summary
Starting with MusicXML 3.1 most elements can carry an
idattribute naming that one element within the document.mx::apidropped nearly all of them (only a handful of recently-added direction types had one). This adds an optionalidmember to every api type that maps one-to-one onto an element with an id, and reads and writes it inmx::impl.Types that gained an
id:NoteData,LyricDataMeasureData,BarlineDataClefData,KeyData,TimeChoice,TransposeDataDirectionData,SoundDataWordsData,SymbolData,RehearsalDataWedgeStart,WedgeStopSpannerStart,SpannerStopPedalLineDataCurveStart,CurveContinue,CurveStop,TieLetRingTupletStart,TupletStopFiguredBassDataSupporting changes:
src/private/mx/impl/IdFunctions.hwith the two helpers (getId,setId) the readers and writers call.ApiCommon.hexplains what ids are for, and that mx repairs a malformed id but does not check uniqueness (see ID uniqueness is not constrained bymx::core. #397).<time>element carries it.SoundData::isSpecifiednow counts an id, so a<sound>that has nothing but an id is not dropped.Left out, because placing the id would need a design decision:
mx::apidoes not model as their own type: direction-type, notations, articulations, ornaments, technical, beam.MarkData: dynamics, fermata, accidental-mark. These would need newMarkDataChoicealternatives.DirectionDataholds severalChordDatathat serialize into a single<harmony>, so it is not clear which chord owns the id.<credit>and<credit-words>have an id andPageTextDatamodels the pair.mx::apidoes not model at all: print, measure-style, grouping, for-part, glissando, slide (see api: model note-attached paired spanners (glissando, slide, wavy-line) #389).Testing
src/private/mxtest/api/IdAttributeApiTest.cpp: 7 cases, 53 assertions, covering every new field throughroundTrip, plus one case reading ids straight off source XML and one pinning the implicit-time-signature rulemake test-allgreen: core roundtrip (839 cases), core unit (44 cases), api/impl suite (6018 assertions in 542 cases), api roundtrip (366 pinned, 0 failed)synthetic/bracket.3.1.xmlandsynthetic/dashes.3.1.xmlnewly pass because of the bracket and dashes ids, and are pinned inroundtrip-baseline.txt. No file regressed.make fmt-checkpassesReferences
mx::api. #399mx::core. #397 (id uniqueness is not constrained bymx::core)