io.musicxml.writer
writer
MusicXML out: one Score of an OmkGraph becomes a <score-partwise> document.
The inverse of reader, rule by rule (_plans/musicxml.md §5 and §6); in short:
- the parts are written in their
STACKS_ABOVEorder: aPartwith aStintover a line is one staff, aPartperforming aLineGroupis one staff per line in the group’s stack order, and aLineGroupwhose lines are each performed by aPercussionPartis one staff of a drum kit; - a line’s
DivisionEvents are its bar lines, and between them (or on a line without them) theMeterEventin force puts one every meter, which is exactly whatOmkGraph.remove_derivable_divisionstakes away, so a graph stripped of derivable bar lines writes the same document as the full one; - a branched line is another voice on its parent’s staff, except a single event branched with no displacement from a chord it fits, which is written back into that chord as
<chord/>notes; - pitches are written as written: a
Stint.transpositionis added back to the stored sounding pitches and becomes<transpose>; - ties, slurs, hairpins, pedals and other spanners become start/stop pairs, markings become
<notations>or<direction>s throughtables, lyric syllables become<lyric>s numbered by their verse, and a chord line pinned to a part becomes that part’s<harmony>s; - what the reader kept in
node.meta["musicxml"](voice and measure numbers, hidden notes, tuplet brackets, part ids and instruments) is written back.
The writer refuses (UnexportableError) only when no document can be written. Everything else it cannot write – an event of unknown or clock-time duration and the rest of its line, an annotation, a line no part performs – raises an OmkWarning naming what was left out.
Attributes
| Name | Description |
|---|---|
| DOCTYPE | |
| SOFTWARE | |
| XML_LANG | |
| ORIGIN | |
| MAX_NUMBER | |
| NEVER |
Functions
| Name | Description |
|---|---|
| write | Writes score (the graph’s only Score when None) as MusicXML 4.0, |
| to_bytes | The uncompressed document write writes, as bytes. |
| document | The <score-partwise> element write serializes. |