Previous topic


Next topic


Table Of Contents

Table Of Contents

This Page


Low-level conversion routines from MusicXML to music21.

This module supposes that the musicxml document has already been parsed by xml.sax (by ) and is stored as a collection of mxObjects – equivalent parsing methods could be created and fed into mxScoreToScore to make this work.


music21.musicxml.fromMxObjects.mxScoreToScore(mxScore, spannerBundle=None, inputM21=None)

Translate an mxScore into a music21 Score object or puts it into the given inputM21 object (which does not necessarily have to be a Score object. It can be any Stream object)

All spannerBundles accumulated at all lower levels are inserted here.

music21.musicxml.fromMxObjects.addToStaffReference(mxObjectOrNumber, music21Object, staffReference)

Utility routine for importing musicXML objects; here, we store a reference to the music21 object in a dictionary, where keys are the staff values. Staff values may be None, 1, 2, etc.

music21.musicxml.fromMxObjects.configureStaffGroupFromMxPartGroup(staffGroup, mxPartGroup)

Given an already instantiated spanner.StaffGroup, configure it with parameters from an mxPartGroup.


Utility function to convert a MusicXML duration type to an music21 duration type.

Changes ‘long’ to ‘longa’ and deals with a Guitar Pro 5.2 bug in MusicXML export, that exports a 32nd note with the type ‘32th’.

>>> musicxml.fromMxObjects.musicXMLTypeToType('long')
>>> musicxml.fromMxObjects.musicXMLTypeToType('32th')
>>> musicxml.fromMxObjects.musicXMLTypeToType('quarter')
>>> musicxml.fromMxObjects.musicXMLTypeToType(None)
Traceback (most recent call last):
music21.musicxml.fromMxObjects.mxArticulationToArticulation(mxArticulationMark, inputM21=None)

Convert an mxArticulationMark to a music21.articulations.Articulation object or one of its subclasses.

Example: Provided an musicxml.mxObjects.ArticulationMark object (not an mxArticulations object) configure the music21 object.

Create both a musicxml.mxObjects.ArticulationMark object and a conflicting music21 object:

>>> mxArticulationMark = musicxml.mxObjects.ArticulationMark('accent')
>>> mxArticulationMark.set('placement', 'below')
>>> a = articulations.Tenuto()
>>> a.placement = 'above'

Now override the music21 object with the mxArticulationMark object’s characteristics

>>> musicxml.fromMxObjects.mxArticulationToArticulation(mxArticulationMark, inputM21 = a)
>>> 'Tenuto' in a.classes
>>> 'Accent' in a.classes
>>> a.placement
music21.musicxml.fromMxObjects.mxClefToClef(mxClefList, inputM21=None)

Given a MusicXML Clef object, return a music21 Clef object

>>> a = musicxml.mxObjects.Clef()   
>>> a.set('sign', 'G')
>>> a.set('line', 2)
>>> b = clef.Clef()
>>> b
>>> 'TrebleClef' in b.classes
>>> musicxml.fromMxObjects.mxClefToClef(a, b)
>>> b.sign
>>> 'TrebleClef' in b.classes
>>> b

Create a new clef from thin air:

>>> a = musicxml.mxObjects.Clef()   
>>> a.set('sign', 'TAB')
>>> c = musicxml.fromMxObjects.mxClefToClef(a)
>>> c
music21.musicxml.fromMxObjects.mxCreatorToContributor(mxCreator, inputM21=None)

Given an mxCreator, fill the necessary parameters of a Contributor.

>>> mxCreator = musicxml.mxObjects.Creator()
>>> mxCreator.set('type', 'composer')
>>> mxCreator.set('charData', 'Beethoven, Ludwig van')
>>> c = musicxml.fromMxObjects.mxCreatorToContributor(mxCreator)
>>> c
<music21.metadata.primitives.Contributor object at 0x...>
>>> c.role
'Beethoven, Ludwig van'

Convert a MusicXML credit to a music21 TextBox

>>> c = musicxml.mxObjects.Credit()
>>> c.append(musicxml.mxObjects.CreditWords('testing'))
>>> c.set('page', 2)
>>> tb = musicxml.fromMxObjects.mxCreditToTextBox(c)
>>> tb.content
music21.musicxml.fromMxObjects.mxDefaultsToScoreLayout(mxDefaults, inputM21=None)

Convert a Defaults object to a ScoreLayout object

music21.musicxml.fromMxObjects.mxDirectionToSpanners(targetLast, mxDirection, spannerBundle)

Some spanners, such as MusicXML octave-shift, are encoded as MusicXML directions.

music21.musicxml.fromMxObjects.mxFermataToFermata(mxFermata, inputM21=None)

Convert an mxFermata object to a music21 expressions.Fermata object.

If inputM21 is None, creates a new Fermata object and returns it. Otherwise changes the current Fermata object and returns nothing.

>>> mxFermata = musicxml.mxObjects.Fermata()
>>> mxFermata.set('type', 'inverted')
>>> fermata = musicxml.fromMxObjects.mxFermataToFermata(mxFermata)
>>> fermata.type
music21.musicxml.fromMxObjects.mxGraceToGrace(noteOrChord, mxGrace=None)

Given a completely formed, non-grace Note or Chord, create and return a m21 grace version of the same.

If mxGrace is None, no change is made and the same object is returned.

music21.musicxml.fromMxObjects.mxKeyListToKeySignature(mxKeyList, inputM21=None)

Given a mxKey object or keyList, return a music21.key.KeySignature object and return it, or if inputM21 is None, change its attributes and return nothing.

>>> mxk = musicxml.mxObjects.Key()
>>> mxk.set('fifths', 5)
>>> ks = key.KeySignature()
>>> musicxml.fromMxObjects.mxKeyListToKeySignature(mxk, ks)
>>> ks.sharps

Or just get a new KeySignature object from scratch:

>>> mxk.set('fifths', -2)
>>> ks2 = musicxml.fromMxObjects.mxKeyListToKeySignature(mxk)
>>> ks2
<music21.key.KeySignature of 2 flats>
music21.musicxml.fromMxObjects.mxNotationsToSpanners(target, mxNotations, spannerBundle)

General routines for gathering spanners from notes via mxNotations objects and placing them in a spanner bundle.

Spanners may be found in musicXML notations and directions objects.

The passed-in spannerBundle will be edited in-place; existing spanners may be completed, or new spanners may be added.

The target object is a reference to the relevant music21 object this spanner is associated with.

music21.musicxml.fromMxObjects.mxNoteToGeneralNoteHelper(n, mxNote, spannerBundle=None)

helper function for things common to notes and rests.

n can be a note or rest...


Convert mxOrnament into a music21 ornament.

This only processes non-spanner ornaments. Many mxOrnaments are spanners: these are handled elsewhere.

Returns None if cannot be converted or not defined.

music21.musicxml.fromMxObjects.mxPageLayoutToPageLayout(mxPageLayout, inputM21=None)

get a PageLayout object from an mxPageLayout

Called out from mxPrintToPageLayout because it is also used in the <defaults> tag

music21.musicxml.fromMxObjects.mxPrintToPageLayout(mxPrint, inputM21=None)

Given an mxPrint object, set object data for the print section of a layout.PageLayout object

>>> mxPrint = musicxml.mxObjects.Print()
>>> mxPrint.set('new-page', 'yes')
>>> mxPrint.set('page-number', 5)
>>> mxPageLayout = musicxml.mxObjects.PageLayout()
>>> mxPageLayout.pageHeight = 4000
>>> mxPageMargins = musicxml.mxObjects.PageMargins()
>>> mxPageMargins.set('leftMargin', 20)
>>> mxPageMargins.set('rightMargin', 30.2)
>>> mxPageLayout.append(mxPageMargins) 
>>> mxPrint.append(mxPageLayout)
>>> pl = musicxml.fromMxObjects.mxPrintToPageLayout(mxPrint)
>>> pl.isNew
>>> pl.rightMargin > 30.1 and pl.rightMargin < 30.3
>>> pl.leftMargin
>>> pl.pageNumber

Alternatively, pass a music21 object into this routine.

>>> plAlt = layout.PageLayout()
>>> musicxml.fromMxObjects.mxPrintToPageLayout(mxPrint, plAlt)
>>> plAlt.pageNumber
>>> plAlt.pageHeight
>>> plAlt.isNew
music21.musicxml.fromMxObjects.mxPrintToStaffLayoutList(mxPrint, inputM21=None)

Given an mxPrint object, return a list of StaffLayout objects (may be empty)

>>> mxPrint = musicxml.mxObjects.Print()

# this is a red-herring... does nothing here... >>> mxPrint.set(‘new-system’, ‘yes’)

>>> mxStaffLayout = musicxml.mxObjects.StaffLayout()
>>> mxStaffLayout.staffDistance = 55
>>> mxStaffLayout.set('number', 1)
>>> mxPrint.append(mxStaffLayout)
>>> slList = musicxml.fromMxObjects.mxPrintToStaffLayoutList(mxPrint)
>>> sl = slList[0]
>>> sl.distance
>>> sl.staffNumber
music21.musicxml.fromMxObjects.mxPrintToSystemLayout(mxPrint, inputM21=None)

Given an mxPrint object, set object data

>>> mxPrint = musicxml.mxObjects.Print()
>>> mxPrint.set('new-system', 'yes')
>>> mxSystemLayout = musicxml.mxObjects.SystemLayout()
>>> mxSystemLayout.systemDistance = 55
>>> mxSystemMargins = musicxml.mxObjects.SystemMargins()
>>> mxSystemMargins.set('leftMargin', 20)
>>> mxSystemMargins.set('rightMargin', 30.2)
>>> mxSystemLayout.append(mxSystemMargins) 
>>> mxPrint.append(mxSystemLayout)
>>> sl = musicxml.fromMxObjects.mxPrintToSystemLayout(mxPrint)
>>> sl.isNew
>>> sl.rightMargin > 30.1 and sl.rightMargin <= 30.2
>>> sl.leftMargin
>>> sl.distance
music21.musicxml.fromMxObjects.mxScoreToMetadata(mxScore, inputM21=None)

Use an mxScore, to fill in parameters of a Metadata object.

if inputM21 is None, a new Metadata object is created and returned at the end.

Otherwise, the parameters of this Metadata object are changed and nothing is returned.

music21.musicxml.fromMxObjects.mxStaffLayoutToStaffLayout(mxStaffLayout, inputM21=None)

get a StaffLayout object from an mxStaffLayout

Called out from mxPrintToStaffLayoutList because it is also used in the <defaults> tag

music21.musicxml.fromMxObjects.mxSystemLayoutToSystemLayout(mxSystemLayout, inputM21=None)

get a SystemLayout object from an mxSystemLayout

Called out from mxPrintToSystemLayout because it is also used in the <defaults> tag

music21.musicxml.fromMxObjects.mxTechnicalToArticulation(mxTechnicalMark, inputM21=None)

Convert an mxTechnicalMark to a music21.articulations.TechnicalIndication object or one of its subclasses.

Example: Provided an musicxml.mxObjects.TechnicalMark object (not an mxTechnical object) configure the music21 object.

Create both a musicxml.mxObjects.ArticulationMark object and a conflicting music21 object:

>>> mxTechnicalMark = musicxml.mxObjects.TechnicalMark('up-bow')
>>> mxTechnicalMark.set('placement', 'below')
>>> a = articulations.DownBow()
>>> a.placement = 'above'

Now override the music21 object with the mxArticulationMark object’s characteristics

>>> musicxml.fromMxObjects.mxTechnicalToArticulation(mxTechnicalMark, inputM21 = a)
>>> 'DownBow' in a.classes
>>> 'UpBow' in a.classes
>>> a.placement
music21.musicxml.fromMxObjects.mxToAccidental(mxAccidental, inputM21Object=None)
>>> a = musicxml.mxObjects.Accidental()
>>> a.set('content', 'half-flat')
>>> a.get('content')
>>> b = pitch.Accidental()
>>> bReference = musicxml.fromMxObjects.mxToAccidental(a, b)
>>> b is bReference
>>> b.alter
music21.musicxml.fromMxObjects.mxToBarline(mxBarline, inputM21=None)

Given an mxBarline, fill the necessary parameters

>>> mxBarline = musicxml.mxObjects.Barline()
>>> mxBarline.set('barStyle', 'light-light')
>>> mxBarline.set('location', 'right')
>>> b = musicxml.fromMxObjects.mxToBarline(mxBarline)
>>>  # different in music21 than musicxml
>>> b.location
music21.musicxml.fromMxObjects.mxToBeam(mxBeam, inputM21=None)

given an mxBeam object return a Beam object

>>> mxBeam = musicxml.mxObjects.Beam()
>>> mxBeam.set('charData', 'begin')
>>> a = musicxml.fromMxObjects.mxToBeam(mxBeam)
>>> a.type
>>> mxBeam.set('charData', 'continue')
>>> a = musicxml.fromMxObjects.mxToBeam(mxBeam)
>>> a.type
>>> mxBeam.set('charData', 'end')
>>> a = musicxml.fromMxObjects.mxToBeam(mxBeam)
>>> a.type
>>> mxBeam.set('charData', 'forward hook')
>>> a = musicxml.fromMxObjects.mxToBeam(mxBeam)
>>> a.type
>>> a.direction
>>> mxBeam.set('charData', 'backward hook')
>>> a = musicxml.fromMxObjects.mxToBeam(mxBeam)
>>> a.type
>>> a.direction
>>> mxBeam.set('charData', 'crazy')
>>> a = musicxml.fromMxObjects.mxToBeam(mxBeam)
Traceback (most recent call last):
FromMxObjectsException: unexpected beam type encountered (crazy)
music21.musicxml.fromMxObjects.mxToBeams(mxBeamList, inputM21=None)

given a list of mxBeam objects, sets the beamsList

>>> a = beam.Beams()
>>> a.fill(2, type='start')
>>> mxBeamList = musicxml.toMxObjects.beamsToMx(a)
>>> b = musicxml.fromMxObjects.mxToBeams(mxBeamList)
>>> b
<music21.beam.Beams <music21.beam.Beam 1/start>/<music21.beam.Beam 2/start>>
music21.musicxml.fromMxObjects.mxToChord(mxNoteList, inputM21=None, spannerBundle=None)

Given an a list of mxNotes, fill the necessary parameters

>>> a = musicxml.mxObjects.Note()
>>> p = musicxml.mxObjects.Pitch()
>>> p.set('step', 'A')
>>> p.set('octave', 3)
>>> a.setDefaults()
>>> a.set('pitch', p)
>>> b = musicxml.mxObjects.Note()
>>> b.setDefaults()
>>> b.set('chord', True)
>>> m = musicxml.mxObjects.Measure()
>>> m.setDefaults()
>>> a.external['measure'] = m # assign measure for divisions ref
>>> a.external['divisions'] = m.external['divisions']
>>> b.external['measure'] = m # assign measure for divisions ref
>>> b.external['divisions'] = m.external['divisions']
>>> c = musicxml.fromMxObjects.mxToChord([a, b])
>>> len(c.pitches)
>>> c.pitches[0]
<music21.pitch.Pitch A3>
>>> a = musicxml.mxObjects.Note()
>>> a.setDefaults()
>>> nh1 = musicxml.mxObjects.Notehead()
>>> nh1.set('charData', 'diamond')
>>> a.noteheadObj = nh1
>>> b = musicxml.mxObjects.Note()
>>> b.setDefaults()
>>> b.set('chord', True)
>>> m = musicxml.mxObjects.Measure()
>>> m.setDefaults()
>>> a.external['measure'] = m # assign measure for divisions ref
>>> a.external['divisions'] = m.external['divisions']
>>> b.external['measure'] = m # assign measure for divisions ref
>>> b.external['divisions'] = m.external['divisions']
>>> c = musicxml.fromMxObjects.mxToChord([a, b])
>>> c.getNotehead(c.pitches[0])

Convert a musicxml.mxObjects.Harmony() object to a harmony.ChordSymbol object:

>>> mxHarmony = musicxml.mxObjects.Harmony()
>>> mxKind = musicxml.mxObjects.Kind()
>>> mxKind.charData = 'major-seventh'
>>> mxHarmony.kindObj = mxKind
>>> mxRoot = musicxml.mxObjects.Root()
>>> mxRoot.set('root-step', 'D')
>>> mxRoot.set('root-alter', '-1')
>>> mxHarmony.rootObj = mxRoot
>>> cs = musicxml.fromMxObjects.mxToChordSymbol(mxHarmony)
>>> cs
<music21.harmony.ChordSymbol D-maj7>
>>> cs.figure
>>> cs.pitches
(<music21.pitch.Pitch D-3>, <music21.pitch.Pitch F3>, <music21.pitch.Pitch A-3>, <music21.pitch.Pitch C4>)
>>> cs.root()
<music21.pitch.Pitch D-3>

TODO: this is very classically-oriented. Make it more Jazz/Rock like.

>>> mxKind.charData = 'major-sixth'
>>> cs = musicxml.fromMxObjects.mxToChordSymbol(mxHarmony)
>>> cs
<music21.harmony.ChordSymbol D-6>
>>> cs.figure
>>> cs.pitches
(<music21.pitch.Pitch D-3>, <music21.pitch.Pitch F3>, <music21.pitch.Pitch A-3>, <music21.pitch.Pitch B-3>)
>>> cs.root()
<music21.pitch.Pitch D-3>  

Translate a MusicXML Coda object to a music21 Coda object.

music21.musicxml.fromMxObjects.mxToDuration(mxNote, inputM21=None)

Translate a MusicXML Note object to a music21 Duration object.

>>> a = musicxml.mxObjects.Note()
>>> a.setDefaults()
>>> m = musicxml.mxObjects.Measure()
>>> m.setDefaults()
>>> a.external['measure'] = m # assign measure for divisions ref
>>> a.external['divisions'] = m.external['divisions']
>>> c = duration.Duration()
>>> musicxml.fromMxObjects.mxToDuration(a, c)
<music21.duration.Duration 1.0>
>>> c.quarterLength

Given an mxDirection, load instance

>>> mxDirection = musicxml.mxObjects.Direction()
>>> mxDirectionType = musicxml.mxObjects.DirectionType()
>>> mxDynamicMark = musicxml.mxObjects.DynamicMark('ff')
>>> mxDynamics = musicxml.mxObjects.Dynamics()
>>> mxDynamics.set('default-y', -20)
>>> mxDynamics.append(mxDynamicMark)
>>> mxDirectionType.append(mxDynamics)
>>> mxDirection.append(mxDirectionType)
>>> a = dynamics.Dynamic()
>>> a = musicxml.fromMxObjects.mxToDynamicList(mxDirection)[0]
>>> a.value
>>> a.englishName
'very loud'
>>> a._positionDefaultY
music21.musicxml.fromMxObjects.mxToInstrument(mxScorePart, inputM21=None)

Return a generic instrument.Instrument object from this mxScorePart

music21.musicxml.fromMxObjects.mxToLyric(mxLyric, inputM21=None)

Translate a MusicXML Lyric object to a music21 Lyric object.

If inputM21 is a Lyric object, then the values of the mxLyric are transfered there and nothing returned.

Otherwise, a new Lyric object is created and returned.

>>> mxLyric = musicxml.mxObjects.Lyric()
>>> mxLyric.set('text', 'word')
>>> mxLyric.set('number', 4)
>>> mxLyric.set('syllabic', 'single')
>>> lyricObj = note.Lyric()
>>> musicxml.fromMxObjects.mxToLyric(mxLyric, lyricObj)
>>> lyricObj
<music21.note.Lyric number=4 syllabic=single text="word">

Non-numeric MusicXML lyric “number”s are converted to identifiers:

>>> mxLyric.set('number', 'part2verse1')    
>>> l2 = musicxml.fromMxObjects.mxToLyric(mxLyric)
>>> l2
<music21.note.Lyric number=0 identifier="part2verse1" syllabic=single text="word">
music21.musicxml.fromMxObjects.mxToMeasure(mxMeasure, spannerBundle=None, inputM21=None, lastMeasureInfo=None)

Translate an mxMeasure (a MusicXML Measure object) into a music21 Measure.

If an inputM21 object reference is provided, this object will be configured and returned; otherwise, a new Measure object is created.

The spannerBundle that is passed in is used to accumulate any created Spanners. This Spanners are not inserted into the Stream here.

Returns a tuple of ( object, staffReference (a dictionary for partStaffs of elements that only belong to a single staff), and a transposition)

music21.musicxml.fromMxObjects.mxToNote(mxNote, spannerBundle=None, inputM21=None)

Translate a MusicXML Note to a Note.

The spannerBundle parameter can be a list or a Stream for storing and processing Spanner objects.

If inputM21 is not None then that object is used for translating. Otherwise a new Note is created.

Returns a note.Note object.

>>> mxNote = musicxml.mxObjects.Note()
>>> mxNote.setDefaults()
>>> mxMeasure = musicxml.mxObjects.Measure()
>>> mxMeasure.setDefaults()
>>> mxMeasure.append(mxNote)
>>> mxNote.external['measure'] = mxMeasure # manually create ref
>>> mxNote.external['divisions'] = mxMeasure.external['divisions']
>>> n = musicxml.fromMxObjects.mxToNote(mxNote)
>>> n
<music21.note.Note C>
music21.musicxml.fromMxObjects.mxToOffset(mxDirection, mxDivisions)

Translate a MusicXML Direction with an offset value to an offset in music21.

music21.musicxml.fromMxObjects.mxToPitch(mxNote, inputM21=None)

Given a MusicXML Note object, set this Pitch object to its values.

>>> b = musicxml.mxObjects.Pitch()
>>> b.set('octave', 3)
>>> b.set('step', 'E')
>>> b.set('alter', -1)
>>> c = musicxml.mxObjects.Note()
>>> c.set('pitch', b)
>>> a = pitch.Pitch('g#4')
>>> a = musicxml.fromMxObjects.mxToPitch(c)
>>> print(a)
music21.musicxml.fromMxObjects.mxToRepeat(mxBarline, inputM21=None)

Given an mxBarline (not an mxRepeat object) with repeatObj as a parameter, file the necessary parameters and return a bar.Repeat() object

>>> mxRepeat = musicxml.mxObjects.Repeat()
>>> mxRepeat.set('direction', 'backward')
>>> mxRepeat.get('times') == None
>>> mxBarline = musicxml.mxObjects.Barline()
>>> mxBarline.set('barStyle', 'light-heavy')
>>> mxBarline.set('repeatObj', mxRepeat)
>>> b = musicxml.fromMxObjects.mxToRepeat(mxBarline)
>>> b
< direction=end>

Test that the music21 style for a backwards repeat is called “final” (because it resembles a final barline) but that the musicxml style is called light-heavy.

>>> b.direction
>>> mxBarline2 = musicxml.toMxObjects.repeatToMx(b)
>>> mxBarline2.get('barStyle')

Given an mxDirection that may define a coda, segno, or other repeat expression statement, realize the appropriate music21 object.

music21.musicxml.fromMxObjects.mxToRest(mxNote, inputM21=None, spannerBundle=None)

Translate a MusicXML Note object to a Rest.

If an inputM21 object reference is provided, this object will be configured; otherwise, a new Rest object is created and returned.


Translate a MusicXML Coda object to a music21 Coda object.

music21.musicxml.fromMxObjects.mxToStreamPart(mxScore, partId, spannerBundle=None, inputM21=None)

Load a part into a new Stream or one provided by inputM21 given an mxScore and a part name.

The spannerBundle reference, when passed in, is used to accumulate Spanners. These are not inserted here.

Though it is incorrect MusicXML, PDFtoMusic creates empty measures when it should create full measures of rests (possibly hidden). This routine fixes that bug. See

music21.musicxml.fromMxObjects.mxToTempoIndication(mxMetronome, mxWords=None)

Given an mxMetronome, convert to either a TempoIndication subclass, either a tempo.MetronomeMark or tempo.MetricModulation.

>>> m = musicxml.mxObjects.Metronome()
>>> bu = musicxml.mxObjects.BeatUnit('half')
>>> pm = musicxml.mxObjects.PerMinute(125)
>>> m.append(bu)
>>> m.append(pm)
>>> musicxml.fromMxObjects.mxToTempoIndication(m)
<music21.tempo.MetronomeMark Half=125.0>

Given an mxDirection, create one or more TextExpressions

music21.musicxml.fromMxObjects.mxToTie(mxNote, inputM21=None)

Translate a MusicXML Note (sic!) to a music21 Tie object according to its <tieList> parameter.

Only called if the mxObjects.Note has a tieList that is not blank, so as not to create additional ties.

music21.musicxml.fromMxObjects.mxToTimeSignature(mxTimeList, inputM21=None)

Given an mxTimeList, load this object

if inputM21 is None, create a new TimeSignature and return it.

>>> mxTime = musicxml.mxObjects.Time()
>>> mxTime.setDefaults()
>>> mxAttributes = musicxml.mxObjects.Attributes()
>>> mxAttributes.timeList.append(mxTime)
>>> ts = meter.TimeSignature()
>>> musicxml.fromMxObjects.mxToTimeSignature(mxAttributes.timeList, ts)
>>> ts.numerator
music21.musicxml.fromMxObjects.mxToTuplet(mxNote, inputM21Object=None)

Given an mxNote, based on mxTimeModification and mxTuplet objects, return a Tuplet object (or alter the input object and then return it)


Convert a MusicXML Transpose object to a music21 Interval object.

>>> t = musicxml.mxObjects.Transpose()
>>> t.diatonic = -1
>>> t.chromatic = -2
>>> musicxml.fromMxObjects.mxTransposeToInterval(t)
<music21.interval.Interval M-2>
>>> t = musicxml.mxObjects.Transpose()
>>> t.diatonic = -5
>>> t.chromatic = -9
>>> musicxml.fromMxObjects.mxTransposeToInterval(t)
<music21.interval.Interval M-6>
>>> t = musicxml.mxObjects.Transpose()
>>> t.diatonic = 3 # a type of 4th
>>> t.chromatic = 6
>>> musicxml.fromMxObjects.mxTransposeToInterval(t)
<music21.interval.Interval A4>
music21.musicxml.fromMxObjects.separateOutPartStaffs(mxPart, streamPart, spannerBundle, s, staffReferenceList, partId)

given an mxPart and other necessary information, insert into the score (s) multiple PartStaff objects separating the information for one part from the other