Previous topic

music21.environment

Next topic

music21.features.base

Table Of Contents

Table Of Contents

music21.expressions

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

It also includes representations of things such as TextExpressions which are better attached to the Stream itself.

music21.expressions.realizeOrnaments(srcObject)

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()
_images/expressionsMordentRealize.png

TextExpression

Inherits from: Expression, Music21Object, JSONSerializer, TextFormat

class music21.expressions.TextExpression(content=None)

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
1

New classes can define their own default classSortOrder

>>> class ExampleClass(base.Music21Object):
...     classSortOrderDefault = 5
...
>>> ec1 = ExampleClass()
>>> ec1.classSortOrder
5

Attributes inherited from Music21Object: isSpanner, isStream, isVariant, id, groups, hideObjectOnPrint

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.

Other legal positions are ‘above’ and ‘below’ which are synonyms for 10 and -70 respectively (for 5-line staves; other staves are not yet implemented)

>>> from music21 import *
>>> te = expressions.TextExpression()
>>> te.positionVertical = 10
>>> te.positionVertical
10.0
>>> te.positionVertical = 'below'
>>> te.positionVertical
-70.0

Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds

Properties inherited from JSONSerializer: json

Properties inherited from TextFormat: justify, letterSpacing, size, style, weight

TextExpression methods

getRepeatExpression()

If this TextExpression can be a RepeatExpression, return a new RepeatExpression. object, otherwise, return None.

getTempoText()

No documentation.

Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

Appoggiatura

Inherits from: GeneralAppoggiatura, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.Appoggiatura

Expression

Inherits from: Music21Object, JSONSerializer

class music21.expressions.Expression

This base class is inherited by many diverse expressions.

Fermata

Inherits from: Expression, Music21Object, JSONSerializer

class music21.expressions.Fermata

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()
_images/expressionsFermata.png

Fermata attributes

Attributes without Documentation: shape, tieAttach, type

Attributes inherited from Music21Object: classSortOrder, isSpanner, isStream, isVariant, hideObjectOnPrint, groups, id

Fermata properties

Fermata methods

Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

GeneralAppoggiatura

Inherits from: Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.GeneralAppoggiatura

GeneralAppoggiatura attributes

Attributes without Documentation: direction, size

Attributes inherited from Ornament: connectedToPrevious, tieAttach

Attributes inherited from Music21Object: classSortOrder, isSpanner, isStream, isVariant, hideObjectOnPrint, groups, id

GeneralAppoggiatura properties

GeneralAppoggiatura methods

realize(srcObject)

realize an appoggiatura

returns a three-element tuple. The first is the notes that the grace note was 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 an appoggiatura)

>>> from music21 import *
>>> n1 = note.Note("C4")
>>> n1.quarterLength = 0.5
>>> a1 = expressions.Appoggiatura()
>>> a1.realize(n1)
(<music21.note.Note D>, <music21.note.Note C>, [])

>>> from music21 import *
>>> n2 = note.Note("C4")
>>> n2.quarterLength = 1
>>> a2 = expressions.HalfStepInvertedAppoggiatura()
>>> a2.realize(n2)
(<music21.note.Note B>, <music21.note.Note C>, [])

Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

GeneralMordent

Inherits from: Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.GeneralMordent

Base class for all Mordent types.

GeneralMordent attributes

size

An Interval class that encapsulates both Chromatic and Diatonic intervals all in one model.

The interval is specified either as named arguments, a DiatonicInterval and a ChromaticInterval, or two Note objects, from which both a ChromaticInterval and DiatonicInterval are derived.

>>> from music21 import *
>>> n1 = note.Note('c3')
>>> n2 = note.Note('c5')
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=n2)
>>> aInterval
<music21.interval.Interval P15>
>>> aInterval.name
'P15'

Reduce to a single octave:

>>> aInterval.simpleName
'P1'

Reduce to no more than an octave:

>>> aInterval.semiSimpleName
'P8'

An interval can also be specified directly

>>> aInterval = interval.Interval('m3')
>>> aInterval
<music21.interval.Interval m3>
>>> aInterval = interval.Interval('M3')
>>> aInterval
<music21.interval.Interval M3>
>>> aInterval = interval.Interval('p5')
>>> aInterval
<music21.interval.Interval P5>
>>> aInterval.isChromaticStep
False
>>> aInterval.isDiatonicStep
False
>>> aInterval.isStep
False
>>> aInterval = interval.Interval('half')
>>> aInterval
<music21.interval.Interval m2>
>>> aInterval.isChromaticStep
True
>>> aInterval.isDiatonicStep
True
>>> aInterval.isStep
True
>>> aInterval = interval.Interval('-h')
>>> aInterval
<music21.interval.Interval m-2>
>>> aInterval.directedName
'm-2'
>>> aInterval.name
'm2'
>>> aInterval = interval.Interval(3)
>>> aInterval
<music21.interval.Interval m3>
>>> aInterval = interval.Interval(7)
>>> aInterval
<music21.interval.Interval P5>
>>> n1 = note.Note('c3')
>>> n2 = note.Note('g3')
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=n2)
>>> aInterval
<music21.interval.Interval P5>
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=None)
Traceback (most recent call last):
IntervalException: either both the starting and the ending note.Note must be given or neither can be given.  You cannot have one without the other.
>>> aInterval = interval.DiatonicInterval('major', 'third')
>>> bInterval = interval.ChromaticInterval(4)
>>> cInterval = interval.Interval(diatonic=aInterval, chromatic=bInterval)
>>> cInterval
<music21.interval.Interval M3>
>>> cInterval = interval.Interval(diatonic=aInterval, chromatic=None)
Traceback (most recent call last):
IntervalException: either both a DiatonicInterval and a ChromaticInterval object have to be given or neither can be given.  You cannot have one without the other.

Two Intervals are the same if their Chromatic and Diatonic intervals are the same. N.B. that interval.Interval(‘a4’) != ‘a4’ – maybe it should...

Attributes without Documentation: direction, quarterLength

Attributes inherited from Ornament: connectedToPrevious, tieAttach

Attributes inherited from Music21Object: classSortOrder, isSpanner, isStream, isVariant, hideObjectOnPrint, groups, id

GeneralMordent properties

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)

>>> from music21 import *
>>> n1 = note.Note("C4")
>>> n1.quarterLength = 0.5
>>> m1 = expressions.Mordent()
>>> m1.realize(n1)
([<music21.note.Note C>, <music21.note.Note B>], <music21.note.Note C>, [])

>>> from music21 import *
>>> n2 = note.Note("C4")
>>> n2.quarterLength = 0.125
>>> m2 = expressions.GeneralMordent()
>>> m2.realize(n2)
Traceback (most recent call last):
    ...
ExpressionException: Cannot realize a mordent if I do not know its direction

Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

HalfStepAppoggiatura

Inherits from: Appoggiatura, GeneralAppoggiatura, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.HalfStepAppoggiatura

HalfStepInvertedAppoggiatura

Inherits from: InvertedAppoggiatura, GeneralAppoggiatura, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.HalfStepInvertedAppoggiatura

HalfStepInvertedMordent

Inherits from: InvertedMordent, GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.HalfStepInvertedMordent

A half-step inverted Mordent.

>>> from music21 import *
>>> m = expressions.HalfStepInvertedMordent()
>>> m.direction
'up'
>>> m.size
<music21.interval.Interval m2>

HalfStepMordent

Inherits from: Mordent, GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.HalfStepMordent

A half step normal Mordent.

>>> from music21 import *
>>> m = expressions.HalfStepMordent()
>>> m.direction
'down'
>>> m.size
<music21.interval.Interval m2>

HalfStepTrill

Inherits from: Trill, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.HalfStepTrill

A basic trill marker.

>>> from music21 import *
>>> m = expressions.HalfStepTrill()
>>> m.placement
'above'
>>> m.size
<music21.interval.Interval m2>

InvertedAppoggiatura

Inherits from: GeneralAppoggiatura, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.InvertedAppoggiatura

InvertedMordent

Inherits from: GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.InvertedMordent

An inverted Mordent.

>>> from music21 import *
>>> m = expressions.InvertedMordent()
>>> m.direction
'up'
>>> m.size
<music21.interval.Interval M2>

InvertedTurn

Inherits from: Turn, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.InvertedTurn

Mordent

Inherits from: GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.Mordent

A normal Mordent.

>>> from music21 import *
>>> m = expressions.Mordent()
>>> m.direction
'down'
>>> m.size
<music21.interval.Interval M2>

Ornament

Inherits from: Expression, Music21Object, JSONSerializer

class music21.expressions.Ornament

Ornament attributes

Attributes without Documentation: connectedToPrevious, tieAttach

Attributes inherited from Music21Object: classSortOrder, isSpanner, isStream, isVariant, hideObjectOnPrint, groups, id

Ornament properties

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: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

Schleifer

Inherits from: Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.Schleifer

Schleifer attributes

size

An Interval class that encapsulates both Chromatic and Diatonic intervals all in one model.

The interval is specified either as named arguments, a DiatonicInterval and a ChromaticInterval, or two Note objects, from which both a ChromaticInterval and DiatonicInterval are derived.

>>> from music21 import *
>>> n1 = note.Note('c3')
>>> n2 = note.Note('c5')
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=n2)
>>> aInterval
<music21.interval.Interval P15>
>>> aInterval.name
'P15'

Reduce to a single octave:

>>> aInterval.simpleName
'P1'

Reduce to no more than an octave:

>>> aInterval.semiSimpleName
'P8'

An interval can also be specified directly

>>> aInterval = interval.Interval('m3')
>>> aInterval
<music21.interval.Interval m3>
>>> aInterval = interval.Interval('M3')
>>> aInterval
<music21.interval.Interval M3>
>>> aInterval = interval.Interval('p5')
>>> aInterval
<music21.interval.Interval P5>
>>> aInterval.isChromaticStep
False
>>> aInterval.isDiatonicStep
False
>>> aInterval.isStep
False
>>> aInterval = interval.Interval('half')
>>> aInterval
<music21.interval.Interval m2>
>>> aInterval.isChromaticStep
True
>>> aInterval.isDiatonicStep
True
>>> aInterval.isStep
True
>>> aInterval = interval.Interval('-h')
>>> aInterval
<music21.interval.Interval m-2>
>>> aInterval.directedName
'm-2'
>>> aInterval.name
'm2'
>>> aInterval = interval.Interval(3)
>>> aInterval
<music21.interval.Interval m3>
>>> aInterval = interval.Interval(7)
>>> aInterval
<music21.interval.Interval P5>
>>> n1 = note.Note('c3')
>>> n2 = note.Note('g3')
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=n2)
>>> aInterval
<music21.interval.Interval P5>
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=None)
Traceback (most recent call last):
IntervalException: either both the starting and the ending note.Note must be given or neither can be given.  You cannot have one without the other.
>>> aInterval = interval.DiatonicInterval('major', 'third')
>>> bInterval = interval.ChromaticInterval(4)
>>> cInterval = interval.Interval(diatonic=aInterval, chromatic=bInterval)
>>> cInterval
<music21.interval.Interval M3>
>>> cInterval = interval.Interval(diatonic=aInterval, chromatic=None)
Traceback (most recent call last):
IntervalException: either both a DiatonicInterval and a ChromaticInterval object have to be given or neither can be given.  You cannot have one without the other.

Two Intervals are the same if their Chromatic and Diatonic intervals are the same. N.B. that interval.Interval(‘a4’) != ‘a4’ – maybe it should...

Attributes without Documentation: quarterLength

Attributes inherited from Ornament: connectedToPrevious, tieAttach

Attributes inherited from Music21Object: classSortOrder, isSpanner, isStream, isVariant, hideObjectOnPrint, groups, id

Schleifer properties

Schleifer methods

Methods inherited from Ornament: realize()

Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

Shake

Inherits from: Trill, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.Shake

Tremolo

Inherits from: Spanner, Music21Object, JSONSerializer

class music21.expressions.Tremolo(*arguments, **keywords)

A tremolo, which may be a single or multi-note spanner

Trill

Inherits from: Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.Trill

A basic trill marker.

>>> from music21 import *
>>> m = expressions.Trill()
>>> m.placement
'above'
>>> m.size
<music21.interval.Interval M2>

Trill attributes

size

An Interval class that encapsulates both Chromatic and Diatonic intervals all in one model.

The interval is specified either as named arguments, a DiatonicInterval and a ChromaticInterval, or two Note objects, from which both a ChromaticInterval and DiatonicInterval are derived.

>>> from music21 import *
>>> n1 = note.Note('c3')
>>> n2 = note.Note('c5')
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=n2)
>>> aInterval
<music21.interval.Interval P15>
>>> aInterval.name
'P15'

Reduce to a single octave:

>>> aInterval.simpleName
'P1'

Reduce to no more than an octave:

>>> aInterval.semiSimpleName
'P8'

An interval can also be specified directly

>>> aInterval = interval.Interval('m3')
>>> aInterval
<music21.interval.Interval m3>
>>> aInterval = interval.Interval('M3')
>>> aInterval
<music21.interval.Interval M3>
>>> aInterval = interval.Interval('p5')
>>> aInterval
<music21.interval.Interval P5>
>>> aInterval.isChromaticStep
False
>>> aInterval.isDiatonicStep
False
>>> aInterval.isStep
False
>>> aInterval = interval.Interval('half')
>>> aInterval
<music21.interval.Interval m2>
>>> aInterval.isChromaticStep
True
>>> aInterval.isDiatonicStep
True
>>> aInterval.isStep
True
>>> aInterval = interval.Interval('-h')
>>> aInterval
<music21.interval.Interval m-2>
>>> aInterval.directedName
'm-2'
>>> aInterval.name
'm2'
>>> aInterval = interval.Interval(3)
>>> aInterval
<music21.interval.Interval m3>
>>> aInterval = interval.Interval(7)
>>> aInterval
<music21.interval.Interval P5>
>>> n1 = note.Note('c3')
>>> n2 = note.Note('g3')
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=n2)
>>> aInterval
<music21.interval.Interval P5>
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=None)
Traceback (most recent call last):
IntervalException: either both the starting and the ending note.Note must be given or neither can be given.  You cannot have one without the other.
>>> aInterval = interval.DiatonicInterval('major', 'third')
>>> bInterval = interval.ChromaticInterval(4)
>>> cInterval = interval.Interval(diatonic=aInterval, chromatic=bInterval)
>>> cInterval
<music21.interval.Interval M3>
>>> cInterval = interval.Interval(diatonic=aInterval, chromatic=None)
Traceback (most recent call last):
IntervalException: either both a DiatonicInterval and a ChromaticInterval object have to be given or neither can be given.  You cannot have one without the other.

Two Intervals are the same if their Chromatic and Diatonic intervals are the same. N.B. that interval.Interval(‘a4’) != ‘a4’ – maybe it should...

Attributes without Documentation: nachschlag, placement, quarterLength

Attributes inherited from Ornament: connectedToPrevious, tieAttach

Attributes inherited from Music21Object: classSortOrder, isSpanner, isStream, isVariant, hideObjectOnPrint, groups, id

Trill properties

Trill methods

realize(srcObject)

realize a trill.

returns a three-element tuple. The first is a list of the notes that the note was converted to. The second is None because the trill “eats up” the whole note. The third is a list of the notes at the end if nachschlag is True, and empty list if False.

>>> from music21 import *
>>> n1 = note.Note("C4")
>>> n1.quarterLength = 0.5
>>> t1 = expressions.Trill()
>>> t1.realize(n1)
([<music21.note.Note C>, <music21.note.Note D>, <music21.note.Note C>, <music21.note.Note D>], None, [])

>>> from music21 import *
>>> n2 = note.Note("D4")
>>> n2.quarterLength = 0.125
>>> t2 = expressions.Trill()
>>> t2.realize(n2)
Traceback (most recent call last):
    ...
ExpressionException: The note is not long enough to realize a trill

Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

TrillExtension

Inherits from: Spanner, Music21Object, JSONSerializer

class music21.expressions.TrillExtension(*arguments, **keywords)

A wavy line trill extension, placed between two notes. Note that some MusicXML readers include a trill symbol with the wavy line.

>>> from music21 import *
>>> s = stream.Stream()
>>> s.repeatAppend(note.Note(), 8)
>>> # create between notes 2 and 3
>>> te = expressions.TrillExtension(s.notes[1], s.notes[2])
>>> s.append(te) # can go anywhere in the Stream
>>> te.getDurationBySite(s).quarterLength
2.0
>>> print te
<music21.expressions.TrillExtension <music21.note.Note C><music21.note.Note C>>

TrillExtension attributes

Attributes inherited from Spanner: isSpanner, idLocal, completeStatus

Attributes inherited from Music21Object: classSortOrder, isStream, isVariant, hideObjectOnPrint, groups, id

TrillExtension properties

placement

Get or set the placement as either above or below.

>>> from music21 import *
>>> s = stream.Stream()
>>> s.repeatAppend(note.Note(), 8)
>>> te = expressions.TrillExtension(s.notes[1], s.notes[2])
>>> te.placement = 'above'
>>> te.placement
'above'

Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds

Properties inherited from JSONSerializer: json

TrillExtension methods

Methods inherited from Spanner: addComponents(), freezeIds(), getComponentIds(), getComponents(), getComponentsByClass(), getDurationBySite(), getDurationSpanBySite(), getFirst(), getLast(), getOffsetSpanBySite(), getOffsetsBySite(), getSpannerStorageId(), hasComponent(), isFirst(), isLast(), purgeLocations(), purgeOrphans(), replaceComponent(), unfreezeIds(), unwrapWeakref(), wrapWeakref()

Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

Turn

Inherits from: Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.Turn

Turn attributes

size

An Interval class that encapsulates both Chromatic and Diatonic intervals all in one model.

The interval is specified either as named arguments, a DiatonicInterval and a ChromaticInterval, or two Note objects, from which both a ChromaticInterval and DiatonicInterval are derived.

>>> from music21 import *
>>> n1 = note.Note('c3')
>>> n2 = note.Note('c5')
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=n2)
>>> aInterval
<music21.interval.Interval P15>
>>> aInterval.name
'P15'

Reduce to a single octave:

>>> aInterval.simpleName
'P1'

Reduce to no more than an octave:

>>> aInterval.semiSimpleName
'P8'

An interval can also be specified directly

>>> aInterval = interval.Interval('m3')
>>> aInterval
<music21.interval.Interval m3>
>>> aInterval = interval.Interval('M3')
>>> aInterval
<music21.interval.Interval M3>
>>> aInterval = interval.Interval('p5')
>>> aInterval
<music21.interval.Interval P5>
>>> aInterval.isChromaticStep
False
>>> aInterval.isDiatonicStep
False
>>> aInterval.isStep
False
>>> aInterval = interval.Interval('half')
>>> aInterval
<music21.interval.Interval m2>
>>> aInterval.isChromaticStep
True
>>> aInterval.isDiatonicStep
True
>>> aInterval.isStep
True
>>> aInterval = interval.Interval('-h')
>>> aInterval
<music21.interval.Interval m-2>
>>> aInterval.directedName
'm-2'
>>> aInterval.name
'm2'
>>> aInterval = interval.Interval(3)
>>> aInterval
<music21.interval.Interval m3>
>>> aInterval = interval.Interval(7)
>>> aInterval
<music21.interval.Interval P5>
>>> n1 = note.Note('c3')
>>> n2 = note.Note('g3')
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=n2)
>>> aInterval
<music21.interval.Interval P5>
>>> aInterval = interval.Interval(noteStart=n1, noteEnd=None)
Traceback (most recent call last):
IntervalException: either both the starting and the ending note.Note must be given or neither can be given.  You cannot have one without the other.
>>> aInterval = interval.DiatonicInterval('major', 'third')
>>> bInterval = interval.ChromaticInterval(4)
>>> cInterval = interval.Interval(diatonic=aInterval, chromatic=bInterval)
>>> cInterval
<music21.interval.Interval M3>
>>> cInterval = interval.Interval(diatonic=aInterval, chromatic=None)
Traceback (most recent call last):
IntervalException: either both a DiatonicInterval and a ChromaticInterval object have to be given or neither can be given.  You cannot have one without the other.

Two Intervals are the same if their Chromatic and Diatonic intervals are the same. N.B. that interval.Interval(‘a4’) != ‘a4’ – maybe it should...

Attributes without Documentation: nachschlag, placement, quarterLength

Attributes inherited from Ornament: connectedToPrevious, tieAttach

Attributes inherited from Music21Object: classSortOrder, isSpanner, isStream, isVariant, hideObjectOnPrint, groups, id

Turn properties

Turn methods

realize(srcObject)

realize a turn.

returns a three-element tuple. The first is a list of the four notes that the beginning of the note was converted to. The second is a note of duration 0 because the turn “eats up” the whole note. The third is a list of the notes at the end if nachschlag is True, and empty list if False.

>>> from  music21 import *
>>> m1 = stream.Measure()
>>> m1.append(key.Key('F', 'major'))
>>> n1 = note.Note("C5")
>>> m1.append(n1)
>>> t1 = expressions.Turn()
>>> t1.realize(n1)
([], <music21.note.Note C>, [<music21.note.Note D>, <music21.note.Note C>, <music21.note.Note B->, <music21.note.Note C>])

>>> from music21 import *
>>> m2 = stream.Measure()
>>> m2.append(key.KeySignature(5))
>>> n2 = note.Note("B4")
>>> m2.append(n2)
>>> t2 = expressions.InvertedTurn()
>>> t2.realize(n2)
([], <music21.note.Note B>, [<music21.note.Note A#>, <music21.note.Note B>, <music21.note.Note C#>, <music21.note.Note B>])
>>> from music21 import *
>>> n2 = note.Note("C4")
>>> n2.quarterLength = 0.125
>>> t2 = expressions.Turn()
>>> t2.realize(n2)
Traceback (most recent call last):
    ...
ExpressionException: The note is not long enough to realize a turn

Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

WholeStepAppoggiatura

Inherits from: Appoggiatura, GeneralAppoggiatura, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.WholeStepAppoggiatura

WholeStepInvertedAppoggiatura

Inherits from: InvertedAppoggiatura, GeneralAppoggiatura, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.WholeStepInvertedAppoggiatura

WholeStepInvertedMordent

Inherits from: InvertedMordent, GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.WholeStepInvertedMordent

A whole-step inverted Mordent.

>>> from music21 import *
>>> m = expressions.WholeStepInvertedMordent()
>>> m.direction
'up'
>>> m.size
<music21.interval.Interval M2>

WholeStepMordent

Inherits from: Mordent, GeneralMordent, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.WholeStepMordent

A whole step normal Mordent.

>>> from music21 import *
>>> m = expressions.WholeStepMordent()
>>> m.direction
'down'
>>> m.size
<music21.interval.Interval M2>

WholeStepTrill

Inherits from: Trill, Ornament, Expression, Music21Object, JSONSerializer

class music21.expressions.WholeStepTrill

A basic trill marker.

>>> from music21 import *
>>> m = expressions.WholeStepTrill()
>>> m.placement
'above'
>>> m.size
<music21.interval.Interval M2>