Skip to main content

Module musicxml

Module musicxml 

Source
Available on crate feature musicxml only.
Expand description

MusicXML import and export: music21’s musicxml.xmlToM21 and musicxml.m21ToXml. MusicXML export: music21’s musicxml.m21ToXml.

to_musicxml writes a score as a score-partwise document, element for element as music21’s ScoreExporter writes it with makeNotation=False: the score is taken as already notated, so its measures, beams, ties and the accidentals it shows are written as they stand rather than worked out again. A score is parts holding measures, a measure may hold voices, and a stream holding no parts is written as one part.

ExportOptions::make_notation asks for the notation to be worked out first, as music21’s exporter does by default: a part of loose notes, or a score whose lengths no single note value writes, is then written as music21 writes it.

The writer does no file IO; it hands back the document as a string.

Structs§

ExportOptions
What a document says about how it was made, where the score does not say.

Constants§

CSS_COLORS
The CSS3 colour names and their hex values, sorted by name: the table music21 reads a colour name out of, through webcolors.
DIVISIONS_PER_QUARTER
How many divisions of a quarter note durations are counted in: music21’s defaults.divisionsPerQuarter, 32 * 3 * 3 * 5 * 7, which counts every tuplet music21 writes in whole numbers.
MUSICXML_VERSION
The MusicXML version written.

Functions§

css_color_hex
The hex value of a CSS3 colour name, as #FF0000 for red, whatever case the name is written in; None for a name CSS does not have.
from_musicxml
Reads a MusicXML document – the text of a .musicxml file, or of the score inside a compressed .mxl – into a score: music21’s converter.parse for the format.
to_musicxml
Writes a score as a MusicXML document.