Previous topic

music21.musedata.base40

Next topic

music21.musicxml.m21ToString

Table Of Contents

Table Of Contents

music21.musicxml.base

This module defines an object representation of MusicXML, used for converting to and from MusicXML and music21.

music21.musicxml.base.booleanToYesNo(value)
music21.musicxml.base.yesNoToBoolean(value)

Accidental

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Accidental

AccidentalMark

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.AccidentalMark(type=None)

Used inside an ornament definition; chardata holds the accidental type

ArticulationMark

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.ArticulationMark(tag)

This is not an XML object, but a container for all XML articulation tags.

Articulations

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Articulations(type=None)

Attributes

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Attributes

Attributes attributes

Attributes without Documentation: transposeObj, divisions, directive, clefList, timeList, staves, measureStyleObj, staffDetailsList, keyList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Attributes properties

Properties inherited from XMLNode: tag

Attributes methods

setDefaultDivisions()

Utility to just set the divisions parameters

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

Backup

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Backup(type=None)

Backup attributes

Attributes without Documentation: duration

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Backup properties

Properties inherited from XMLNode: tag

Backup methods

Barline

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Barline

Barline attributes

Attributes without Documentation: repeatObj, barStyle, endingObj

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Barline properties

Properties inherited from XMLNode: tag

Barline methods

Bass

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Bass

A root defines a pitch, with a step and an alter

Bass attributes

Attributes without Documentation: bassStep, bassAlter

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Bass properties

Properties inherited from XMLNode: tag

Bass methods

Beam

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Beam

Beams are specified is individual objects for each beam, in order, where the beam number refers to its duration representation (8th, 16th, etc) and its character data specifies whether it is begin/continue/end (for normal beams) or backward hook/forward wook (for beams that do not continue are attached only to the staff). These character data values can be mixed: one beam can continue while another can hook or end.

1 = 8th 2 = 16th 3 = 32th 4 = 64th 5 = 128th 6 = 256th

From musicxml.xsd:

Beam values include begin, continue, end, forward hook, and backward hook. Up to six concurrent beam levels are available to cover up to 256th notes. The repeater attribute, used for tremolos, needs to be specified with a “yes” value for each beam using it. Beams that have a begin value can also have a fan attribute to indicate accelerandos and ritardandos using fanned beams. The fan attribute may also be used with a continue value if the fanning direction changes on that note. The value is “none” if not specified.

Note that the beam number does not distinguish sets of beams that overlap, as it does for slur and other elements. Beaming groups are distinguished by being in different voices and/or the presence or absence of grace and cue

BeatType

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.BeatType(charData=None)

BeatUnit

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.BeatUnit(charData=None)

Part of <metronome> tags

BeatUnitDot

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.BeatUnitDot

Part of <metronome> tags

Beats

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Beats(charData=None)

Bracket

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Bracket(type=None)
>>> from music21 import *
>>> b = musicxml.Bracket()
>>> b.tag
'bracket'

Clef

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Clef

Clef attributes

Attributes without Documentation: clefOctaveChange, sign, line

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Clef properties

Properties inherited from XMLNode: tag

Clef methods

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

Coda

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Coda(type=None)

Creator

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Creator
>>> from music21 import *
>>> a = musicxml.Creator()
>>> a.tag
'creator'

Credit

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Credit

The credit tag stores on or more credit-words tags, defining text positioned on a page.

>>> from music21 import *
>>> a = musicxml.Credit()
>>> a.tag
'credit'
>>> a.setDefaults()
>>> b = musicxml.CreditWords('testing')
>>> a.append(b)
>>> print a
<credit page=1 <credit-words charData=testing>>

CreditWords

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.CreditWords(charData=None)
>>> from music21 import *
>>> a = musicxml.CreditWords()
>>> a.tag
'credit-words'

Dashes

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Dashes(type=None)
>>> from music21 import *
>>> d = musicxml.Dashes()
>>> d.tag
'dashes'

Defaults

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Defaults

from musicxml schema:

The defaults type specifies score-wide defaults for scaling, layout, and appearance.

<xs:sequence>
<xs:element name=”scaling” type=”scaling” minOccurs=”0”/> <xs:group ref=”layout”/> <xs:element name=”appearance” type=”appearance” minOccurs=”0”/> <xs:element name=”music-font” type=”empty-font” minOccurs=”0”/> <xs:element name=”word-font” type=”empty-font” minOccurs=”0”/> <xs:element name=”lyric-font” type=”lyric-font” minOccurs=”0” maxOccurs=”unbounded”/> <xs:element name=”lyric-language” type=”lyric-language” minOccurs=”0” maxOccurs=”unbounded”/>

</xs:sequence>

Defaults attributes

Attributes without Documentation: musicFontObj, lyricLanguage, lyricFontObj, scalingObj, appearanceObj, layoutList, wordFontObj

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Defaults properties

Properties inherited from XMLNode: tag

Defaults methods

Degree

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Degree

The degree type is used to add, alter, or subtract individual notes in the chord.

DegreeAlter

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.DegreeAlter

Chromatic alteration of current degree

DegreeType

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.DegreeType

addition, alteration, subtraction relative to the kind of current chord

DegreeValue

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.DegreeValue

Stores 1 for root, 3 for third, etc

DelayedTurn

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.DelayedTurn(type=None)

Direction

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Direction

One or more Direction objects are found in measures, after an attributes object. Within the Direction object may be a number of objects, including DirectionType, Sound.

Direction attributes

Attributes without Documentation: offset, staff

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Direction properties

Properties inherited from XMLNode: tag

Direction methods

getBracket()

Search this direction and determine if it contains a segno mark.

>>> from music21 import *
>>> a = musicxml.Direction()
>>> b = musicxml.DirectionType()
>>> c = musicxml.Bracket()
>>> b.append(c)
>>> a.append(b)
>>> a.getBracket() is not None
True
getCoda()

Search this direction and determine if it contains a coda mark.

>>> from music21 import *
>>> a = musicxml.Direction()
>>> b = musicxml.DirectionType()
>>> c = musicxml.Coda()
>>> b.append(c)
>>> a.append(b)
>>> a.getCoda() is not None
True
getDashes()

Search this direction and determine if it contains a segno mark.

>>> from music21 import *
>>> a = musicxml.Direction()
>>> b = musicxml.DirectionType()
>>> c = musicxml.Dashes()
>>> b.append(c)
>>> a.append(b)
>>> a.getDashes() is not None
True
getDynamicMark()

Search this direction and determine if it contains a dynamic mark, return, otherwise, return None

>>> from music21 import *
>>> a = musicxml.Direction()
>>> b = musicxml.DirectionType()
>>> c = musicxml.Dynamics()
>>> d = musicxml.DynamicMark('f')
>>> c.append(d)
>>> b.append(c)
>>> a.append(b)
>>> a.getDynamicMark() is not None
True
getMetronome()

Search this direction and determine if it contains a dynamic mark.

>>> from music21 import *
>>> a = musicxml.Direction()
>>> b = musicxml.DirectionType()
>>> c = musicxml.Metronome()
>>> b.append(c)
>>> a.append(b)
>>> a.getMetronome() is not None
True
getSegno()

Search this direction and determine if it contains a segno mark.

>>> from music21 import *
>>> a = musicxml.Direction()
>>> b = musicxml.DirectionType()
>>> c = musicxml.Segno()
>>> b.append(c)
>>> a.append(b)
>>> a.getSegno() is not None
True
getWedge()

Search this direction and determine if it contains a dynamic mark.

>>> from music21 import *
>>> a = musicxml.Direction()
>>> b = musicxml.DirectionType()
>>> c = musicxml.Wedge('crescendo')
>>> b.append(c)
>>> a.append(b)
>>> a.getWedge() is not None
True
getWords()

Search this direction and determine if it contains a Words entity.

>>> from music21 import *
>>> a = musicxml.Direction()
>>> b = musicxml.DirectionType()
>>> c = musicxml.Words('crescendo')
>>> b.append(c)
>>> a.append(b)
>>> a.getWords() == [c]
True
>>> a.getWords()[0].charData
'crescendo'

Methods inherited from MusicXMLElementList: append(), insert()

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), setDefaults(), toxml(), xmlStr()

DirectionType

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.DirectionType

DirectionType stores objects like Pedal, dynamics, wedge, and words

DisplayOctave

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.DisplayOctave(type=None)

DisplayStep

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.DisplayStep(type=None)

Dot

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Dot(type=None)

DynamicMark

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.DynamicMark(tag)

This is not an XML object in the normal sense, but a container for all XML dynamic tags. Dynamic tags have no attributes or elements. Tags inlcude common marks such as p, pp, ff, etc.

Dynamics

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Dynamics(type=None)

Encoding

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Encoding

Encoding attributes

Attributes without Documentation: encodingDate, supportsList, softwareList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Encoding properties

Properties inherited from XMLNode: tag

Encoding methods

Ending

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Ending

Ending tags are stored in Barline tags to indicate the start ane end of a repeat bracket, used to designate an alternate repeat.

Fermata

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Fermata(type=None)

Forward

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Forward(type=None)

Forward attributes

Attributes without Documentation: duration

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Forward properties

Properties inherited from XMLNode: tag

Forward methods

Glissando

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Glissando(type=None)
>>> from music21 import *
>>> g = musicxml.Glissando()
>>> g.tag
'glissando'

Grace

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Grace(type=None)

Harmony

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Harmony

A harmony tag stores a root, kind – eventually becomes converted to a music21 ChordSymbol object (not Harmony; though ChordSymbol is a subclass of the music21 object called Harmony, which also deals with Figured bass and Roman Numerals.

Harmony attributes

Attributes without Documentation: function, inversion, rootObj, degreeObj, kindObj, bassObj

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Harmony properties

Properties inherited from XMLNode: tag

Harmony methods

Identification

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Identification
>>> from music21 import *
>>> a = musicxml.Identification()
>>> a.tag
'identification'

Identification attributes

Attributes without Documentation: rights, encodingObj, creatorList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Identification properties

Properties inherited from XMLNode: tag

Identification methods

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

InvertedMordent

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.InvertedMordent(type=None)

InvertedTurn

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.InvertedTurn(type=None)

Key

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Key

Key attributes

Attributes without Documentation: mode, nonTraditionalKeyList, cancel, fifths

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Key properties

Properties inherited from XMLNode: tag

Key methods

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

KeyAlter

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.KeyAlter

KeyOctave

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.KeyOctave

KeyStep

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.KeyStep

Kind

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Kind

A harmony tag stores a root, kind

Lyric

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Lyric(number=None)

Multiple Lyric objects can be defined within a single Note.

Lyric attributes

Attributes without Documentation: text, syllabic

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Lyric properties

Properties inherited from XMLNode: tag

Lyric methods

filterLyric(text)

Remove and fix character strings that cause problems in MusicXML

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), setDefaults(), toxml(), xmlStr()

MIDIInstrument

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.MIDIInstrument

MIDIInstrument attributes

Attributes without Documentation: midiBank, volume, midiUnpitched, pan, elevation, midiChannel, midiProgram, midiName

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

MIDIInstrument properties

Properties inherited from XMLNode: tag

MIDIInstrument methods

Measure

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Measure

Measure attributes

Attributes without Documentation: attributesObj

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Measure properties

Properties inherited from XMLNode: tag

Measure methods

getVoiceCount()

Return the number of voices defined in this Measure; this must be called after update().

getVoiceIndices()

Return a list of unique sorted voice ids.

setDefaults()

No documentation.

update()

This method looks at all note, forward, and backup objects and updates divisons and attributes references

Methods inherited from MusicXMLElementList: append(), insert()

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

MeasureStyle

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.MeasureStyle

MeasureStyle attributes

Attributes without Documentation: multipleRest

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

MeasureStyle properties

Properties inherited from XMLNode: tag

MeasureStyle methods

Metronome

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Metronome(charData=None)

A direction type used to store tempo indications, consisting of a <beat-unit> tag (a duration) as well as a <per-unit> tag (a number). Also used to store metric modulations.

>>> from music21 import *
>>> m = musicxml.Metronome()
>>> bu1 = musicxml.BeatUnit('half')
>>> m.append(bu1)
>>> m.isMetricModulation()
False

Metronome attributes

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Metronome properties

Properties inherited from XMLNode: tag

Metronome methods

isMetricModulation()

Return True if this Metronome defines a metric modulation. If there are more than on <beat-unit> tag, than this is True

>>> from music21 import *
>>> m = musicxml.Metronome()
>>> bu1 = musicxml.BeatUnit('half')
>>> bu2 = musicxml.BeatUnit('quarter')
>>> m.append(bu1)
>>> m.append(bu2)
>>> m.isMetricModulation()
True

Methods inherited from MusicXMLElementList: append(), insert()

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), setDefaults(), toxml(), xmlStr()

Mordent

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Mordent(type=None)

MusicXMLElement

Inherits from: XMLNode

class music21.musicxml.base.MusicXMLElement

MusicXML elements are an abstraction of MusicXML into an object oriented framework. Some, not all, of MusicXML elements are represented as objects. Some sub-elements are much more simply placed as attributes of parent objects. These simple elements have only a tag and character data. Elements that have attributes and/or sub-elements, however, must be represented as objects.

These tests are module specific and should be loaded as unittests, below

>>> from music21 import *

>>> a = musicxml.MusicXMLElement()
>>> a._convertNameToXml('groupAbbreviation')
'group-abbreviation'
>>> a._convertNameToXml('midiUnpitched')
'midi-unpitched'
>>> a._convertNameToXml('groupNameDisplay')
'group-name-display'
>>> a._convertNameToXml('group-name-display')
'group-name-display'
>>> a = musicxml.MusicXMLElement()
>>> a._convertNameFromXml('group-abbreviation')
'groupAbbreviation'
>>> a._convertNameFromXml('midi-unpitched')
'midiUnpitched'
>>> a._convertNameFromXml('midiUnpitched')
'midiUnpitched'
>>> a._convertNameFromXml('opus')
'opus'
>>> a._convertNameFromXml('group-name-display')
'groupNameDisplay'

>>> a = musicxml.MusicXMLElement()
>>> len(a._publicAttributes())
3
>>> print(a._publicAttributes())
['charData', 'external', 'tag']

MusicXMLElement attributes

Attributes without Documentation: external

Attributes inherited from XMLNode: charData

MusicXMLElement properties

Properties inherited from XMLNode: tag

MusicXMLElement methods

MusicXMLElementList

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.MusicXMLElementList

MusicXML that is designed to function as a list. In general, this is an element this only used to contain other Elements. List operations permit easy access and manipuation.

Note that design here mirrors that of node.py NodeList, but this needs to be a subclass of of MusicXMLElement

MusicXMLElementList attributes

Attributes without Documentation: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

MusicXMLElementList properties

Properties inherited from XMLNode: tag

MusicXMLElementList methods

append(item)

No documentation.

insert(position, item)

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), setDefaults(), toxml(), xmlStr()

Notations

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Notations(type=None)

Notations contains many elements, including Ornaments. Most of these are stored in the .componentList

Notations attributes

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Notations properties

Properties inherited from XMLNode: tag

Notations methods

getArticulations()

A quick way to get all articulations objects; there may be more than one.

Returns a list of ArticulationMark objects

getFermatas()

Get all Fermatas from the componentList as a list

getGlissandi()

Get all glissandi objects stored on components. There can be more than one.

>>> from music21 import *
>>> g1 = musicxml.Glissando()
>>> g2 = musicxml.Glissando()
>>> n = musicxml.Notations()
>>> n.append(g1)
>>> n.append(g2)
>>> n.getGlissandi()
[<glissando >, <glissando >]
getOrnaments()

Get all ornament objects stored on componentList. There can be more than one.

getSlurs()

Get all Slurs from the componentList as a list

getTechnical()

A quick way to get all technical objects; there may be more than one.

Returns a list of TechnicalMark objects

getTieds()

A quick way to get all tied objects; there is likely only one, but we return a list anyhow.

getTremolos()

Get one or more tremolo line objects Stored in Ornaments

>>> from music21 import *
>>> t = musicxml.Tremolo()
>>> o = musicxml.Ornaments()
>>> n = musicxml.Notations()
>>> o.append(t)
>>> n.append(o)
>>> n.getTremolos()
[<tremolo >]
getTuplets()

A quick way to get all tuplets; there is likely only one, but we return a list anyhow.

getWavyLines()

Get one or more wavy line objects Stored in Ornaments

>>> from music21 import *
>>> wl = musicxml.WavyLine()
>>> o = musicxml.Ornaments()
>>> n = musicxml.Notations()
>>> o.append(wl)
>>> n.append(o)
>>> n.getWavyLines()
[<wavy-line >]

Methods inherited from MusicXMLElementList: append(), insert()

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), setDefaults(), toxml(), xmlStr()

Note

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Note

Note attributes

Attributes without Documentation: chord, timeModificationObj, duration, staff, type, dotList, graceObj, accidentalObj, stem, lyricList, beamList, restObj, noteheadObj, tieList, notationsObj, pitchObj, voice

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Note properties

Properties inherited from XMLNode: tag

Note methods

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

Notehead

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Notehead(type=None)

OctaveShift

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.OctaveShift(type=None)
>>> from music21 import *
>>> os = musicxml.OctaveShift()
>>> os.tag
'octave-shift'

Offset

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Offset(charData=None)

A musicxml <offset> element can be found defined in the <direction> element. the charData stores a number that is the shift in divisions from the location of the tag.

Ornaments

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Ornaments(type=None)

The Ornaments tag wraps the following muscixml entities: trill-mark, turn, delayed-turn, inverted-turn, shake, wavy-line, mordent, inverted mordent, schleifer, tremolo, other-ornament.

Ornaments are stored on the notations object.

PageLayout

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.PageLayout

PageLayout attributes

Attributes without Documentation: pageWidth, pageHeight

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

PageLayout properties

Properties inherited from XMLNode: tag

PageLayout methods

PageMargins

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.PageMargins

Does not support the type = (odd|even|both) attribute

PageMargins attributes

Attributes without Documentation: bottomMargin, topMargin, rightMargin, leftMargin

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

PageMargins properties

Properties inherited from XMLNode: tag

PageMargins methods

Part

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Part

This assumes a part-wise part

Part attributes

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Part properties

Properties inherited from XMLNode: tag

Part methods

getStavesCount()

Look ahead into the measure Attributes and return the highest number of staves used in this part.

setDefaults()

No documentation.

Methods inherited from MusicXMLElementList: append(), insert()

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

PartGroup

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.PartGroup

The PartGroup tag is stored in the PartList, intermingled with ScorePart tags and other definitions.

PartGroup attributes

Attributes without Documentation: groupNameDisplay, groupAbbreviationDisplay, groupBarline, groupSymbol, groupName, groupTime, groupAbbreviation

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

PartGroup properties

Properties inherited from XMLNode: tag

PartGroup methods

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

PartList

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.PartList

The PartList defines the parts, as well as their names and abbreviations.

It stores the parts in its .componentList list in order.

Additionally, the order of this list is used as a way specifying arrangements of brackets and/or braces that group parts in partGroup objects.

The order of this list thus matters.

The PartList for a score is usually accessed from the Score (musicxml.Score) object’s .partListObj parameter.

PerMinute

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.PerMinute(charData=None)

Part of <metronome> tags

Pitch

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Pitch

Pitch attributes

Attributes without Documentation: step, octave, alter

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Pitch properties

Properties inherited from XMLNode: tag

Pitch methods

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

Print

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Print

from direction.mod:

The print element contains general printing parameters, including the layout elements defined in the layout.mod file. The part-name-display and part-abbreviation-display elements used in the score.mod file may also be used here to change how a part name or abbreviation is displayed over the course of a piece. They take effect when the current measure or a succeeding measure starts a new system.

The new-system and new-page attributes indicate whether to force a system or page break, or to force the current music onto the same system or page as the preceding music. Normally this is the first music data within a measure. If used in multi-part music, they should be placed in the same positions within each part, or the results are undefined. The page-number attribute sets the number of a new page; it is ignored if new-page is not “yes”. Version 2.0 adds a blank-page attribute. This is a positive integer value that specifies the number of blank pages to insert before the current measure. It is ignored if new-page is not “yes”. These blank pages have no music, but may have text or images specified by the credit element. This is used to allow a combination of pages that are all text, or all text and images, together with pages of music.

Staff spacing between multiple staves is measured in tenths of staff lines (e.g. 100 = 10 staff lines). This is deprecated as of Version 1.1; the staff-layout element should be used instead. If both are present, the staff-layout values take priority.

Layout elements in a print statement only apply to the current page, system, staff, or measure. Music that follows continues to take the default values from the layout included in the defaults element.

<!ELEMENT print (page-layout?, system-layout?, staff-layout*, measure-layout?, measure-numbering?, part-name-display?, part-abbreviation-display?)> <!ATTLIST print staff-spacing %tenths; #IMPLIED new-system %yes-no; #IMPLIED new-page %yes-no; #IMPLIED blank-page NMTOKEN #IMPLIED page-number CDATA #IMPLIED>

Supported in music21: page-layout system-layout new-system new-page page-number

Repeat

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Repeat

Rest

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Rest(type=None)

Root

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Root

A root defines a pitch, with a step and an alter

Root attributes

Attributes without Documentation: rootStep, rootAlter

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Root properties

Properties inherited from XMLNode: tag

Root methods

Scaling

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Scaling

Scaling attributes

Attributes without Documentation: millimeters, tenths

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Scaling properties

Properties inherited from XMLNode: tag

Scaling methods

Schleifer

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Schleifer(type=None)

Score

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Score(m21Version=None)

Score is used to collect score header elements and, if available, all other MusicXML data. Score can be used for partwise or timewise scores. This object includes all MusicXML score information.

>>> from music21 import *
>>> a = musicxml.Score()
>>> a.tag
'score-partwise'
>>> a.setDefaults()
>>> b = musicxml.Identification()
>>> b.setDefaults()
>>> a.set('identification', b)
>>> c = musicxml.Score()
>>> d = c.merge(a)

Score attributes

Attributes without Documentation: workObj, m21Version, partListObj, movementTitle, encodingObj, creditList, defaultsObj, identificationObj, movementNumber

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Score properties

Properties inherited from XMLNode: tag

Score methods

getPart(partId)

Get a part, given an id.

>>> from music21 import *
>>> from music21.musicxml import testPrimitive
>>> from music21.musicxml import xmlHandler
>>> b = xmlHandler.Document()
>>> b.read(testPrimitive.ALL[0])
>>> c = b.score.getPart(b.score.partIdToNameDict().keys()[0])
>>> c
<part id=P1 <measure width=983 number=1 <print <system-layout...
>>> isinstance(c, musicxml.Part)
True
>>> isinstance(c, stream.Part)
False
getPartGroupData()

Get part groups organized by part id in dictionaries.

Returns a list of dictionaries, each dictionary containing number, a list of part ids, and a mx PartGroup object.

getPartIds()

A quick way to get all valid part ids in the componentList

getPartIdsFromPartListObj()

A quick way to get all valid part ids in the partListObj for each one that is a ScorePart

getScorePart(partId)

Get an instrument, as defined in a ScorePart object, from a Score.

>>> from music21 import *
>>> a = musicxml.Score()
>>> a.setDefaults()
>>> a.getScorePart('P3') == None
True

>>> from music21.musicxml import testPrimitive
>>> from music21.musicxml import xmlHandler
>>> b = xmlHandler.Document()
>>> b.read(testPrimitive.pitches01a)
>>> b.score.getScorePart(b.score.partIdToNameDict().keys()[0])
<score-part id=P1 part-name=MusicXML Part>
partIdToNameDict()

A quick way to get a mapping of valid part ids to the part names from a Score (musicxml.Score) object in the .partListObj property.

Returns a dictionary mapping part id to part-name for each ScorePart in .partListObj.

Note that dictionaries are not sorted, so the order of .partListObj still needs to be used.

setDefaults()

No documentation.

Methods inherited from MusicXMLElementList: append(), insert()

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

ScoreInstrument

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.ScoreInstrument

ScoreInstrument attributes

Attributes without Documentation: instrumentName, solo, instrumentAbbreviation, ensemble

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

ScoreInstrument properties

Properties inherited from XMLNode: tag

ScoreInstrument methods

ScorePart

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.ScorePart

Lives in a PartList

ScorePart attributes

Attributes without Documentation: partName, scoreInstrumentList, partAbbreviation, midiInstrumentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

ScorePart properties

Properties inherited from XMLNode: tag

ScorePart methods

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

Segno

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Segno(type=None)

Shake

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Shake(type=None)

Slur

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Slur

Software

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Software

Defines the Software that created this MusicXML document.

Sound

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Sound(charData=None)

A direction type used to store a large variety of performance indications.

These tags seem to be found most often in <direction> tags, usually following a symbolic definition. For example, MetronomeMark definitions are often followed by a <sound> definition.

Other <sound> tags are found after the <attributes> tag in a measure, often defining tempo.

StaffDetails

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.StaffDetails

StaffDetails attributes

Attributes without Documentation: staffSize

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

StaffDetails properties

Properties inherited from XMLNode: tag

StaffDetails methods

StaffLayout

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.StaffLayout

StaffLayout attributes

Attributes without Documentation: staffDistance

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

StaffLayout properties

Properties inherited from XMLNode: tag

StaffLayout methods

Supports

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Supports

Defines what sorts of notation this encoding supports

SystemLayout

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.SystemLayout

SystemLayout attributes

Attributes without Documentation: topSystemDistance, systemDistance

Attributes inherited from MusicXMLElementList: componentList

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

SystemLayout properties

Properties inherited from XMLNode: tag

SystemLayout methods

SystemMargins

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.SystemMargins

SystemMargins attributes

Attributes without Documentation: bottomMargin, topMargin, rightMargin, leftMargin

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

SystemMargins properties

Properties inherited from XMLNode: tag

SystemMargins methods

Tag

class music21.musicxml.base.Tag(tag, cdFlag=False, className=None)

Object to store tags as encountered by SAX. Tags can be open or closed based on the status attribute. Tags can store character data collected between their defined tags.

These objects are used only for finding and collecting tag attributes and elements. As we do not need character data for all tags, tags have an optional flag to select if the are to collect character data.

>>> from music21 import *

>>> t = musicxml.Tag('note')
>>> t.start()
>>> t.start() # catch double starts
Traceback (most recent call last):
TagException: Tag (note) is already started.

Tag methods

clear()

No documentation.

end()

No documentation.

start()

No documentation.

TagLib

class music21.musicxml.base.TagLib

An object to store all MusicXML tags as Tag objects. Tag objects are used just to identify tags, store element contents and status in SAX parsing.

With this design some tags (called simple elements) can be used simply in SAX parsing as structural monitors, but not be instantiated as objects for content delivery.

>>> from music21 import *
>>> tl = musicxml.TagLib()
>>> tl['voice'].tag
'voice'
>>> tl['voice'].status # open or closed
False
>>> tl.audit()
(True, 'TagLib audit: no errors found.')
>>> tl['note'].start()
>>> tl.audit()
(False, 'TagLib audit: 1 errors found:\ntag <note> left open')

TagLib attributes

Attributes without Documentation: tagsAll, tagsCharData

TagLib methods

audit()

A way to check for errors in SAX parsing. Assumes that all start() calls have been paired with an end() call, and that all element data has been cleared.

getClassName(key)

Get the class or name, or None if none defined.

>>> from music21 import *
>>> tl = musicxml.TagLib()
>>> tl.getClassName('voice')
keys()

No documentation.

statClear()

No documentation.

statRun()

No documentation.

Technical

Inherits from: MusicXMLElementList, MusicXMLElement, XMLNode

class music21.musicxml.base.Technical(type=None)

Class for the <technical> musicxml mark which contains things like <up-bow> etc. objects

TechnicalMark

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.TechnicalMark(tag)

This is not an XML object, but a container for all XML technical tags.

Tie

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Tie(type=None)

Tied

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Tied

Time

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Time

Time attributes

Attributes without Documentation: componentList, senzaMisura

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Time properties

Properties inherited from XMLNode: tag

Time methods

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()

TimeModification

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.TimeModification

TimeModification attributes

Attributes without Documentation: normalType, normalDot, normalNotes, actualNotes

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

TimeModification properties

Properties inherited from XMLNode: tag

TimeModification methods

Transpose

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Transpose

Transpose attributes

Attributes without Documentation: diatonic, double, chromatic, octaveChange

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Transpose properties

Properties inherited from XMLNode: tag

Transpose methods

Tremolo

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Tremolo(type=None)

Tremolo may or may not extend over multiple notes. Char data may store integer number.

TrillMark

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.TrillMark(type=None)

Tuplet

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Tuplet

Stored in notations object and governs presentation and bracket.

Turn

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Turn(type=None)

WavyLine

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.WavyLine(type=None)

A wavy line that extends across many notes or measures.

>>> from music21 import *
>>> wl = musicxml.WavyLine()
>>> wl.tag
'wavy-line'

Wedge

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Wedge(type=None)
>>> from music21 import *
>>> w = musicxml.Wedge()
>>> w.tag
'wedge'

Words

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Words(charData=None)

A direction type that can be used for arbitrary text expressions, and font formatting

Work

Inherits from: MusicXMLElement, XMLNode

class music21.musicxml.base.Work
>>> from music21 import *
>>> a = musicxml.Work()
>>> a.tag
'work'

Work attributes

Attributes without Documentation: workNumber, opus, workTitle

Attributes inherited from MusicXMLElement: external

Attributes inherited from XMLNode: charData

Work properties

Properties inherited from XMLNode: tag

Work methods

setDefaults()

No documentation.

Methods inherited from XMLNode: get(), getNewDoc(), hasAttrs(), loadAttrs(), merge(), set(), toxml(), xmlStr()