io.musicxml.reader
reader
MusicXML in: a <score-partwise> document becomes an OmkGraph holding one Score.
The mapping, rule by rule, is _plans/musicxml.md §5; in short:
- a
<score-part>is aPartwith aStintover its line, or aPartperforming aLineGroupof one line per staff, or, for a drum kit, aLineGroupof one line per<score-instrument>with aPercussionParteach; - on a staff, the lowest voice number is the main line and every contiguous run of another voice is a line branched from the event it starts under;
- every measure boundary is a
DivisionEventin every line that crosses it, with the bar-line shape; key, meter, clef and tempo are context events on every staff’s main line; - a
<note>is aNoteEventat sounding pitch; a chord whose tones differ in what is tied to them or fingered on them is split so that every tie has an event of its own; ties, slurs, hairpins and pedals areMarkSpanners, everything else in<notations>and<direction>aMarking; <lyric>s are syllable lines, one per verse number, joined to their notes;<harmony>is aChordEventon a chord line, pinned to the event at its position, with no duration;- with two or more parts, a bar grid (
SyncLine) pins every part’s head and divisions to one instant per bar line; - the parts are stacked (
OmkGraph.add_stack) in part-list order, a drum kit by itsLineGroup, and a part’s staves in staff order; a<part-group>is aStackGroupover its parts, drawn as a WSMNBracketShape.
Presentation is dropped. What the writer needs back and the model cannot hold goes in node.meta["musicxml"], a dict OMK core never reads. Its keys:
Score:movement_number,movement_title,encoding,source.Part:id,abbreviation,instruments,midi.- a line’s head event:
staff,voice,hidden. DivisionEvent:number,implicit,width,left,right_style(the<bar-style>a start repeat replaced at this boundary),multiple_rest,slash.NoteEvent:forward(a gap the file left),hidden,cue,slash_pitch,display(unpitched step and octave),notehead,instrument,voice(kit lines),tuplet,measure_repeat,staff(only where it differs).Marking/MarkSpanner:offset,tremolo,fingering,accidental_mark,ending,element(a minted mark’s source element),fermata_type,text.offset(and a spanner’send_offset) is how far past its event’s onset the mark falls, in whole notes, as a fraction string ("1/4"), so that meta stays plain JSON.MeterEvent:symbol;TempoEvent:sound_tempo,per_minute,tempo_hidden(the figure is not printed),term_hidden,term_text(the word as printed, when it is not the term’s name).LyricSyllable:extend,humming,laughing,end_line,end_paragraph.ChordEvent:kind,kind_text,frame.
Attributes
| Name | Description |
|---|---|
| XML_LANG | |
| ORIGIN |
Functions
| Name | Description |
|---|---|
| read | The score in a MusicXML file, as a new graph holding one Score. |
| read_into | Adds the score in source to graph and returns its Score node. |
| xml_meta | The musicxml dict of node.meta, made on first use. |