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.
Modules§
- step
- music21’s per-element steps of reading MusicXML: what its
MeasureParsermakes of one<clef>, one<note>, one<measure>.
Structs§
- Export
Options - What a document says about how it was made, where the score does not say.
- Joined
- A spanner joining an element written alone, and where among the spanner’s elements the element stands.
- Staff
Differences - Which marks the staves of a group start with differently: music21’s
isMultiAttributefor keys and meters. - Surroundings
- Where an element written alone stands: the measure holding it, its offset there, and the spanners joining it, which mark the element as they mark it in a score (a slur’s end on a note, a pedal’s change at a bounce); the directions a spanner opens and closes with are not the element’s and are left out. By default it stands at the start of a measure of its own, joined by none.
Enums§
- Across
- Whether the staves of a group start in the same key, or meter.
- Joinable
Groups - Which of a score’s staff groups are written as one part each.
- Spanner
End - Which end of a spanner is written.
- Spanner
Parameter - A value of
spanner_parameters: text, or a number music21 keeps as one.
Constants§
- CSS_
COLORS Deprecated - The CSS3 colour names: moved to the style module.
- 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. - DYNAMIC_
MARKS - music21’s
xmlObjects.DYNAMIC_MARKS: the marks MusicXML writes as a<dynamics>element of their own name. - MUSICXML_
VERSION - The MusicXML version written.
- STAFF_
TAGGED - The children of a measure told their staff when staves are joined.
Traits§
- XmlTree
- An XML element the joining steps can read and change: its tag, attributes, text and children, counted as ElementTree counts them, comments included.
Functions§
- add_
staff_ tags - music21’s
addStaffTags: a<staff>in each child of a measure whose tag is one oftags, before its beams, notations, lyrics and sound. - add_
staff_ tags_ to_ staves - music21’s
addStaffTagsMultiStaffParts:add_staff_tagsover every measure of each staff, the first staff numbered one. - chord_
with_ fret_ board_ xml - What music21’s
chordWithFretBoardToXmlwrites for a chord symbol with a diagram: the symbol’s<harmony>with the<frame>at its end. - css_
color_ hex Deprecated - The hex value of a CSS3 colour name: moved to the style module.
- divider_
text - The text of the comment music21’s
addDividerCommentwrites: the comment centred in signs that pad it out to sixty characters. - element_
xml - The MusicXML music21’s
MeasureExporterwrites for one element, each top-level element as a document of its own. - fraction_
to_ percent - music21’s
xmlObjects.fractionToPercent: a share as a whole percent, truncated. - frame_
note_ xml - What music21’s
fretNoteToXmlwrites for one stopped string: its<frame-note>. - frame_
xml - What music21’s
fretBoardToXmlwrites for a chord diagram: its<frame>, the notes lowest string first;Nonefor a board with no notes. - from_
musicxml - Reads a MusicXML document – the text of a
.musicxmlfile, or of the score inside a compressed.mxl– into a score: music21’sconverter.parsefor the format. - instrument_
xml - What music21’s
instrumentToXmlScoreInstrumentandinstrumentToXmlMidiInstrumentwrite for an instrument: its<score-instrument>and its<midi-instrument>. - is_
valid_ xsd_ id - music21’s
xmlObjects.isValidXSDID: whether text is anxsd:ID, an XML name with no colon, which an element’sidattribute has to be. - join_
staves - music21’s
movePartStaffMeasureContents,setEarliestAttributesAndClefsand the staff tags before them: the staves ofparts, first to last, joined into the first. - joinable_
staff_ groups - music21’s
joinableGroupsfor a whole score: the staff groups whose staves are written as one<part>. - layout_
xml - The element music21 writes a page, system or staff layout as:
<page-layout>,<system-layout>or<staff-layout>, aspageLayoutToXmlPageLayoutand its neighbours write them.Nonefor a score layout, which is written as the parts of<defaults>. - make_
notation - A copy of a stream, or of an element put in one, with the notation it
leaves unsaid worked out, as
ExportOptions::make_notationworks it out before writing: music21’sGeneralObjectExporter.fromGeneralObjectand the score’smakeNotation. What comes back is a score. - measure_
number_ comes_ before - music21’s
measureNumberComesBefore: whether one measure number comes strictly before another, suffixes and all. - move_
measure_ contents - music21’s
moveMeasureContents: the contents ofmeasuremoved intootherbehind a<backup>to the start, with voices numbered on fromother’s, mid-measure clefs told their staff, and a barline replacing the one at the same end. - move_
part_ staff_ contents - music21’s
movePartStaffMeasureContents: every later staff’s measures moved into the first’s, a measure the first lacks put in where it falls. - musicxml_
octave - An octave as MusicXML can say it: music21’s
moveOctaveIntoMusicxmlRange, new in v11, which moves an octave outside the format’s 0 to 9 to the nearest end of that range rather than writing a number no reader will take. - normalize_
color - music21’s
normalizeColor: a hex colour upper-cased, and a CSS colour name written as its hex value. - part_
group_ xml - What music21’s
staffGroupToXmlPartGroupwrites for a staff group: the<part-group type="start">, its number left for the part list to give it. - process_
subsequent_ part_ staff - music21’s
processSubsequentPartStaff: each measure ofsourcemoved into the measure oftargetwith the same number, and the measurestargethas no number for gathered, with their divider comments, to be inserted where they fall. - score_
header_ xml - What music21’s
ScoreExporterwrites before a score’s parts, element by element: the work and movement titles,<identification>,<defaults>, a<credit>for each text box and the<part-list>. - set_
earliest_ attributes_ and_ clefs - music21’s
setEarliestAttributesAndClefsPartStaff: the first staff’s first<attributes>told how many staves there are, given a clef for each, and, where they differ across the staves, a key and a meter for each. - sound_
tempo - music21’s
setSoundTempo: the quarters a minute a<sound>’stempoattribute plays at, orNonefor one that is nought or no number, which sets no tempo. - spanner_
parameters - music21’s
_spannerStartParametersand_spannerEndParameters: the attributes an octave line, a bracket line, a hairpin or a pedal mark writes where it starts or stops. Every other spanner has only itstype. - staff_
details_ xml - What music21’s
staffLayoutToXmlStaffDetailswrites for a staff layout: its<staff-details>. - staff_
differences - Which marks a group’s staves start with differently: music21’s
isMultiAttributefor keys and for meters. - to_
musicxml - Writes a score as a MusicXML document.
- transpose_
xml - What music21’s
intervalToXmlTransposewrites for an interval a part is transposed by: its<transpose>. - type_
to_ musicxml - music21’s
typeToMusicXMLType: the MusicXML<type>for a music21 duration type, which is the type itself but forlonga, writtenlong. The types MusicXML has no value for are refused.