This module provides object representations of expressions, that is notational symbols such as Fermatas, Mordents, Trills, Turns, etc. which are stored under a Music21Object’s .expressions attribute
given a Music21Object with Ornament expressions, convert them into a list of objects that represents the performed version of the object:
>>> from music21 import *
>>> n1 = note.Note("D5")
>>> n1.quarterLength = 1
>>> n1.expressions.append(expressions.WholeStepMordent())
>>> expList = expressions.realizeOrnaments(n1)
>>> st1 = stream.Stream()
>>> st1.append(expList)
>>> st1.show()
Inherits from: Music21Object, JSONSerializer
Inherits from: Expression, Music21Object, JSONSerializer
Fermatas by default get appended to the last note if a note is split because of measures. To override this (for Fermatas or for any expression) set .tieAttach to ‘all’ or ‘first’ instead of ‘last’.
>>> from music21 import *
>>> p1 = stream.Part()
>>> p1.append(meter.TimeSignature('6/8'))
>>> n1 = note.Note("D-2")
>>> n1.quarterLength = 6
>>> n1.expressions.append(expressions.Fermata())
>>> p1.append(n1)
>>> p1.show()
Fermata attributes
Attributes without Documentation: lily, shape, tieAttach, type
Attributes inherited from Music21Object: classSortOrder, hideObjectOnPrint, id, groups
Fermata properties
- mx¶
Advanced feature: As a getter gives the music21.musicxml object for the Fermata or as a setter changes the current fermata to have the characteristics of the musicxml object to fit this type:
>>> from music21 import * >>> a = Fermata() >>> mxFermata = a.mx >>> mxFermata.get('type') 'upright'>>> mxFermata2 = musicxml.Fermata() >>> mxFermata2.set('type', 'upright-inverted') >>> a.mx = mxFermata2 >>> a.type 'upright-inverted'Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, measureNumber, offset, priority
Properties inherited from JSONSerializer: json
Fermata methods
Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Ornament, Expression, Music21Object, JSONSerializer
GeneralMordent attributes
Attributes without Documentation: direction, quarterLength, size
Attributes inherited from Ornament: connectedToPrevious, tieAttach
Attributes inherited from Music21Object: classSortOrder, hideObjectOnPrint, id, groups
GeneralMordent properties
Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, measureNumber, offset, priority
Properties inherited from JSONSerializer: json
GeneralMordent methods
- realize(srcObject)¶
realize a mordent. returns a three-element tuple. The first is a list of the two notes that the beginning of the note were converted to. The second is the rest of the note The third is an empty list (since there are no notes at the end of a mordent)
TODO: write more docs...
Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: InvertedMordent, GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer
Inherits from: Mordent, GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer
Inherits from: Trill, Ornament, Expression, Music21Object, JSONSerializer
Inherits from: GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer
Inherits from: Ornament, Expression, Music21Object, JSONSerializer
Inherits from: GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer
Inherits from: Expression, Music21Object, JSONSerializer
Ornament attributes
Attributes without Documentation: connectedToPrevious, tieAttach
Attributes inherited from Music21Object: classSortOrder, hideObjectOnPrint, id, groups
Ornament properties
Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, measureNumber, offset, priority
Properties inherited from JSONSerializer: json
Ornament methods
- realize(sourceObject)¶
- subclassible method call that takes a sourceObject and returns a three-element tuple of a list of notes before the “main note”, the “main note” itself, and a list of notes after the “main note”.
Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Expression, Music21Object, JSONSerializer, TextFormat
A TextExpression is a word, phrase, or similar bit of text that is positioned in a Stream or Measure. Conventional expressive indications are text like “agitato” or “con fuoco.”
>>> from music21 import *
>>> te = expressions.TextExpression('testing')
>>> te.size = 24
>>> te.size
24.0
>>> te.style = 'bolditalic'
>>> te.letterSpacing = 0.5
TextExpression attributes
- classSortOrder¶
Property which returns an number (int or otherwise) depending on the class of the Music21Object that represents a priority for an object based on its class alone – used as a tie for stream sorting in case two objects have the same offset and priority. Lower numbers are sorted to the left of higher numbers. For instance, Clef, KeySignature, TimeSignature all come (in that order) before Note. All undefined classes have classSortOrder of 20 – same as note.Note
>>> from music21 import * >>> tc = clef.TrebleClef() >>> tc.classSortOrder 0 >>> ks = key.KeySignature(3) >>> ks.classSortOrder 1New classes can define their own default classSortOrder
>>> class ExampleClass(base.Music21Object): ... classSortOrderDefault = 5 ... >>> ec1 = ExampleClass() >>> ec1.classSortOrder 5Attributes inherited from Music21Object: hideObjectOnPrint, id, groups
TextExpression properties
- content¶
Get or set the the content.
>>> from music21 import * >>> te = expressions.TextExpression('testing') >>> te.content 'testing'
- enclosure¶
Get or set the the enclosure.
>>> from music21 import * >>> te = expressions.TextExpression() >>> te.justify = 'center' >>> te.enclosure = None >>> te.enclosure = 'rectangle'
- positionVertical¶
Get or set the the vertical position, where 0 is the top line of the staff and units are in 10ths of a staff space.
>>> from music21 import * >>> te = expressions.TextExpression() >>> te.positionVertical = 10 >>> te.positionVertical 10.0Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, measureNumber, offset, priority
Properties inherited from JSONSerializer: json
Properties inherited from TextFormat: justify, letterSpacing, size, style
TextExpression methods
Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Ornament, Expression, Music21Object, JSONSerializer
Trill attributes
- size¶
- A GenericInterval is an interval such as Third, Seventh, Octave, or Tenth. Constructor takes an integer or string specifying the interval and direction. The interval is not specified in half-steps, but in numeric values derived from interval names: a Third is 3; a Seventh is 7, etc. String values for interval names (‘3rd’ or ‘third’) are accepted. staffDistance: the number of lines or spaces apart, eg: E.g. C4 to C4 = 0; C4 to D4 = 1; C4 to B3 = -1 Two generic intervals are the equal if their size and direction are the same.
Attributes without Documentation: nachschlag, placement, quarterLength, tieAttach
Attributes inherited from Ornament: connectedToPrevious
Attributes inherited from Music21Object: classSortOrder, hideObjectOnPrint, id, groups
Trill properties
- mx¶
Returns a musicxml.TrillMark object
>>> a = Trill() >>> a.placement = 'above' >>> mxTrillMark = a.mx >>> mxTrillMark.get('placement') 'above'Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, measureNumber, offset, priority
Properties inherited from JSONSerializer: json
Trill methods
- realize()¶
- neena will write this... with docs... and examples...
Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Ornament, Expression, Music21Object, JSONSerializer
Inherits from: InvertedMordent, GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer
Inherits from: Mordent, GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer
Inherits from: Trill, Ornament, Expression, Music21Object, JSONSerializer