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.
A sub-category of Expressions are Ornaments.
Unlike articulations, expressions can be attached to the Stream itself. For instance, TextExpressions.
TextExpression¶
- 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.”
>>> te = expressions.TextExpression('Con fuoco') >>> te.content 'Con fuoco'
Most configuration of style is done on the .style
TextStyle
object itself.>>> te.style.fontSize = 24.0 >>> te.style.fontSize 24 >>> te.style.fontStyle = 'italic' >>> te.style.fontWeight = 'bold' >>> te.style.letterSpacing = 0.5
TextExpression
bases
TextExpression
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
TextExpression
read/write properties
- TextExpression.content¶
Get or set the content.
>>> te = expressions.TextExpression('dolce') >>> te.content 'dolce'
- TextExpression.enclosure¶
Returns or sets the enclosure on the Style object stored on .style.
Exposed directly on the expression for backwards compatibility. Does not create a .style object if one does not exist and the value is None.
>>> te = expressions.TextExpression('Bridge') >>> te.enclosure is None True >>> te.enclosure = style.Enclosure.RECTANGLE >>> te.enclosure <Enclosure.RECTANGLE>
Note that this is also set on .style.
>>> te.style.enclosure <Enclosure.RECTANGLE>
Read/write properties inherited from Music21Object
:
TextExpression
methods
- TextExpression.getRepeatExpression()¶
If this TextExpression can be a RepeatExpression, return a new
RepeatExpression
. object, otherwise, return None.
- TextExpression.getTempoText()¶
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
TextExpression
instance variables
- TextExpression.placement¶
Staff placement: ‘above’, ‘below’, or None.
A setting of None implies that the placement will be determined by notation software and no particular placement is demanded.
This is not placed in the .style property, since for some expressions, the placement above or below an object has semantic meaning and is not purely presentational.
Instance variables inherited from Music21Object
:
Appoggiatura¶
- class music21.expressions.Appoggiatura¶
Appoggiatura
bases
Appoggiatura
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Appoggiatura
read/write properties
Read/write properties inherited from Music21Object
:
Appoggiatura
methods
Methods inherited from GeneralAppoggiatura
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Appoggiatura
instance variables
Instance variables inherited from Music21Object
:
ArpeggioMark¶
- class music21.expressions.ArpeggioMark(arpeggioType: str | None = None)¶
ArpeggioMark must be applied to a Chord (not to a single Note).
The parameter arpeggioType can be ‘normal’ (a squiggly line), ‘up’ (a squiggly line with an up arrow), ‘down’ (a squiggly line with a down arrow), or ‘non-arpeggio’ (a bracket instead of a squiggly line, used to indicate a non-arpeggiated chord intervening in a sequence of arpeggiated ones).
>>> am = expressions.ArpeggioMark('normal') >>> am.type 'normal'
>>> am = expressions.ArpeggioMark('down') >>> am.type 'down'
ArpeggioMark
bases
ArpeggioMark
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
ArpeggioMark
read/write properties
Read/write properties inherited from Music21Object
:
ArpeggioMark
methods
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
ArpeggioMark
instance variables
Instance variables inherited from Music21Object
:
ArpeggioMarkSpanner¶
- class music21.expressions.ArpeggioMarkSpanner(*spannedElements, arpeggioType: str = 'normal', **keywords)¶
ArpeggioMarkSpanner is a multi-staff or multi-voice (i.e. multi-chord) arpeggio. The spanner should contain all the simultaneous Chords that are to be arpeggiated together. If there is only one arpeggiated note in a particular staff or voice (i.e. the rest are in other staves/voices), then in that case only the spanner can contain a Note. Do not ever put a Note that is within a Chord into a spanner; put the Chord in instead. And do not ever put an ArpeggioMark in a note or chord’s .expressions.
The parameter arpeggioType can be ‘normal’ (a squiggly line), ‘up’ (a squiggly line with an up arrow), ‘down’ (a squiggly line with a down arrow), or ‘non-arpeggio’ (a bracket instead of a squiggly line, used to indicate a non-arpeggiated multi-chord intervening in a sequence of arpeggiated ones).
>>> ams = expressions.ArpeggioMarkSpanner(arpeggioType='non-arpeggio') >>> c1 = chord.Chord('C3 E3 G3') >>> c2 = chord.Chord('C4 E4 G4') >>> ams.addSpannedElements([c1, c2]) >>> ams.type 'non-arpeggio' >>> ams <music21.expressions.ArpeggioMarkSpanner <music21.chord.Chord C3 E3 G3><music21.chord.Chord C4 E4 G4>>
ArpeggioMarkSpanner
bases
ArpeggioMarkSpanner
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
ArpeggioMarkSpanner
read/write properties
Read/write properties inherited from Music21Object
:
ArpeggioMarkSpanner
methods
- ArpeggioMarkSpanner.noteExtremes() Tuple[music21.note.Note | None, music21.note.Note | None] ¶
Return the lowest and highest note spanned by the element, extracting them from Chords if need be.
>>> ch = chord.Chord(['C4', 'E4', 'G4']) >>> n = note.Note('C#3') >>> nonArp = expressions.ArpeggioMarkSpanner([ch, n]) >>> nonArp.noteExtremes() (<music21.note.Note C#>, <music21.note.Note G>)
Methods inherited from Spanner
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
ArpeggioMarkSpanner
instance variables
Instance variables inherited from Music21Object
:
Expression¶
- class music21.expressions.Expression¶
This base class is inherited by many diverse expressions.
Expression
bases
Expression
read-only properties
- Expression.name¶
returns the name of the expression, which is generally the class name lowercased and spaces where a new capital occurs.
Subclasses can override this as necessary.
>>> sc = expressions.Schleifer() >>> sc.name 'schleifer'
>>> iTurn = expressions.InvertedTurn() >>> iTurn.name 'inverted turn'
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Expression
read/write properties
Read/write properties inherited from Music21Object
:
Expression
methods
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Expression
instance variables
Instance variables inherited from Music21Object
:
Fermata¶
- 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’.
>>> 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() .. image:: images/expressionsFermata.* :width: 193
Fermata
bases
Fermata
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Fermata
read/write properties
Read/write properties inherited from Music21Object
:
Fermata
methods
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Fermata
instance variables
Instance variables inherited from Music21Object
:
GeneralAppoggiatura¶
- class music21.expressions.GeneralAppoggiatura¶
GeneralAppoggiatura
bases
GeneralAppoggiatura
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
GeneralAppoggiatura
read/write properties
Read/write properties inherited from Music21Object
:
GeneralAppoggiatura
methods
- GeneralAppoggiatura.realize(srcObj: music21.note.Note, *, inPlace=False)¶
realize an appoggiatura
returns a three-element tuple. The first is the list of 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)
>>> n1 = note.Note('C4') >>> n1.quarterLength = 0.5 >>> a1 = expressions.Appoggiatura() >>> a1.realize(n1) ([<music21.note.Note D>], <music21.note.Note C>, [])
>>> n2 = note.Note('C4') >>> n2.quarterLength = 1 >>> a2 = expressions.HalfStepInvertedAppoggiatura() >>> a2.realize(n2) ([<music21.note.Note B>], <music21.note.Note C>, [])
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
GeneralAppoggiatura
instance variables
Instance variables inherited from Music21Object
:
GeneralMordent¶
- class music21.expressions.GeneralMordent¶
Base class for all Mordent types.
GeneralMordent
bases
GeneralMordent
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
GeneralMordent
read/write properties
Read/write properties inherited from Music21Object
:
GeneralMordent
methods
- GeneralMordent.realize(srcObj: music21.note.Note, *, inPlace=False)¶
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)
>>> 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>, [])
Note: use one of the subclasses, not the GeneralMordent class
>>> n2 = note.Note('C4') >>> n2.quarterLength = 0.125 >>> m2 = expressions.GeneralMordent() >>> m2.realize(n2) Traceback (most recent call last): music21.expressions.ExpressionException: Cannot realize a mordent if I do not know its direction
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
GeneralMordent
instance variables
Instance variables inherited from Music21Object
:
HalfStepAppoggiatura¶
- class music21.expressions.HalfStepAppoggiatura¶
HalfStepAppoggiatura
bases
HalfStepAppoggiatura
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
HalfStepAppoggiatura
read/write properties
Read/write properties inherited from Music21Object
:
HalfStepAppoggiatura
methods
Methods inherited from GeneralAppoggiatura
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
HalfStepAppoggiatura
instance variables
Instance variables inherited from Music21Object
:
HalfStepInvertedAppoggiatura¶
- class music21.expressions.HalfStepInvertedAppoggiatura¶
HalfStepInvertedAppoggiatura
bases
HalfStepInvertedAppoggiatura
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
HalfStepInvertedAppoggiatura
read/write properties
Read/write properties inherited from Music21Object
:
HalfStepInvertedAppoggiatura
methods
Methods inherited from GeneralAppoggiatura
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
HalfStepInvertedAppoggiatura
instance variables
Instance variables inherited from Music21Object
:
HalfStepInvertedMordent¶
- class music21.expressions.HalfStepInvertedMordent¶
A half-step inverted Mordent.
>>> m = expressions.HalfStepInvertedMordent() >>> m.direction 'up' >>> m.size <music21.interval.Interval m2>
HalfStepInvertedMordent
bases
HalfStepInvertedMordent
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
HalfStepInvertedMordent
read/write properties
Read/write properties inherited from Music21Object
:
HalfStepInvertedMordent
methods
Methods inherited from GeneralMordent
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
HalfStepInvertedMordent
instance variables
Instance variables inherited from Music21Object
:
HalfStepMordent¶
- class music21.expressions.HalfStepMordent¶
A half step normal Mordent.
>>> m = expressions.HalfStepMordent() >>> m.direction 'down' >>> m.size <music21.interval.Interval m2>
HalfStepMordent
bases
HalfStepMordent
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
HalfStepMordent
read/write properties
Read/write properties inherited from Music21Object
:
HalfStepMordent
methods
Methods inherited from GeneralMordent
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
HalfStepMordent
instance variables
Instance variables inherited from Music21Object
:
HalfStepTrill¶
- class music21.expressions.HalfStepTrill¶
A trill confined to half steps.
>>> halfTrill = expressions.HalfStepTrill() >>> halfTrill.placement 'above' >>> halfTrill.size <music21.interval.Interval m2>
Here the key signature of 2 sharps will not affect the trill:
>>> n = note.Note('B4', type='eighth') >>> m = stream.Measure() >>> m.insert(0, key.KeySignature(2)) >>> m.append(n) >>> halfTrill.realize(n) ([<music21.note.Note B>, <music21.note.Note C>, <music21.note.Note B>, <music21.note.Note C>], None, [])
HalfStepTrill
bases
HalfStepTrill
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
HalfStepTrill
read/write properties
Read/write properties inherited from Music21Object
:
HalfStepTrill
methods
Methods inherited from Trill
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
HalfStepTrill
instance variables
Instance variables inherited from Music21Object
:
InvertedAppoggiatura¶
- class music21.expressions.InvertedAppoggiatura¶
InvertedAppoggiatura
bases
InvertedAppoggiatura
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
InvertedAppoggiatura
read/write properties
Read/write properties inherited from Music21Object
:
InvertedAppoggiatura
methods
Methods inherited from GeneralAppoggiatura
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
InvertedAppoggiatura
instance variables
Instance variables inherited from Music21Object
:
InvertedMordent¶
- class music21.expressions.InvertedMordent¶
An inverted Mordent – goes upwards and has no line through it.
Note that some computer terminology calls this one a (normal) mordent, but this is a modern term. See Apel, Harvard Dictionary of Music, “Inverted Mordent”:
An 18th-century ornament involving alternation of the written note with the note immediately above it.
An inverted mordent has the size of a generic second, of some form.
>>> m = expressions.InvertedMordent() >>> m.direction 'up' >>> m.size <music21.interval.GenericInterval 2>
Changed in v7: InvertedMordent sizes are GenericIntervals – as was originally intended but programmed incorrectly.
InvertedMordent
bases
InvertedMordent
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
InvertedMordent
read/write properties
Read/write properties inherited from Music21Object
:
InvertedMordent
methods
Methods inherited from GeneralMordent
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
InvertedMordent
instance variables
Instance variables inherited from Music21Object
:
InvertedTurn¶
- class music21.expressions.InvertedTurn¶
InvertedTurn
bases
InvertedTurn
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
InvertedTurn
read/write properties
Read/write properties inherited from Music21Object
:
InvertedTurn
methods
Methods inherited from Turn
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
InvertedTurn
instance variables
Instance variables inherited from Music21Object
:
Mordent¶
- class music21.expressions.Mordent¶
A normal Mordent – goes downwards and has a line through it.
Note that some computer terminology calls this one an inverted mordent, but this is a modern term. See Apel, Harvard Dictionary of Music, “Mordent”:
A musical ornament consisting of the alternation of the written note with the note immediately below it.
>>> m = expressions.Mordent() >>> m.direction 'down' >>> m.size <music21.interval.GenericInterval 2>
Changed in v7: Mordent sizes are GenericIntervals – as was originally intended but programmed incorrectly.
Mordent
bases
Mordent
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Mordent
read/write properties
Read/write properties inherited from Music21Object
:
Mordent
methods
Methods inherited from GeneralMordent
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Mordent
instance variables
Instance variables inherited from Music21Object
:
Ornament¶
- class music21.expressions.Ornament¶
Ornament
bases
Ornament
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Ornament
read/write properties
Read/write properties inherited from Music21Object
:
Ornament
methods
- Ornament.fillListOfRealizedNotes(srcObj: music21.note.Note, fillObjects: List[music21.note.Note], transposeInterval: IntervalBase, *, useQL: float | Fraction | None = None) None ¶
Used by trills and mordents to fill out their realization.
- Ornament.realize(srcObj: music21.note.Note, *, inPlace: bool = False) Tuple[List[music21.note.Note], music21.note.Note | None, List[music21.note.Note]] ¶
subclassable method call that takes a sourceObject and returns a three-element tuple of a list of notes before the “main note” or the result of the expression if it gobbles up the entire note, the “main note” itself (or None) to keep processing for ornaments, and a list of notes after the “main note”.
Added in v.8 – inPlace boolean; note that some ornaments might not return a Note in the second position at all (such as trills) so inPlace does nothing.
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Ornament
instance variables
Instance variables inherited from Music21Object
:
RehearsalMark¶
- class music21.expressions.RehearsalMark(content=None, *, numbering=None)¶
A rehearsal mark is a type of Expression that designates a rehearsal marking, such as A., B., etc.
Takes two inputs, content (‘B’, 5, ‘III’) and an optional numbering system which is helpful for getting the next rehearsal mark.
>>> rm = expressions.RehearsalMark('B') >>> rm <music21.expressions.RehearsalMark 'B'>
RehearsalMark
bases
RehearsalMark
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
RehearsalMark
read/write properties
Read/write properties inherited from Music21Object
:
RehearsalMark
methods
- RehearsalMark.nextContent()¶
Return the next content based on the numbering
>>> expressions.RehearsalMark('A').nextContent() 'B'
>>> expressions.RehearsalMark('II').nextContent() 'III'
>>> expressions.RehearsalMark('IV').nextContent() 'V'
>>> expressions.RehearsalMark(7).nextContent() 8
>>> expressions.RehearsalMark('Z').nextContent() 'AA'
With rehearsal mark ‘I’ default is to consider it as a roman numeral:
>>> expressions.RehearsalMark('I').nextContent() 'II'
Specify numbering directly to avoid problems:
>>> expressions.RehearsalMark('I', numbering='alphabetical').nextContent() 'J'
- RehearsalMark.nextMark()¶
Return the next rehearsal mark.
>>> rm = expressions.RehearsalMark('C') >>> rm.nextMark() <music21.expressions.RehearsalMark 'D'>
>>> rm = expressions.RehearsalMark('IV', numbering='roman') >>> nm = rm.nextMark() >>> nm.content 'V' >>> nm.numbering 'roman'
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
RehearsalMark
instance variables
Instance variables inherited from Music21Object
:
Schleifer¶
- class music21.expressions.Schleifer¶
A slide or culee
Changed in v.7 – size is a Generic second. removed unused nachschlag component.
Schleifer
bases
Schleifer
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Schleifer
read/write properties
Read/write properties inherited from Music21Object
:
Schleifer
methods
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Schleifer
instance variables
Instance variables inherited from Music21Object
:
Shake¶
- class music21.expressions.Shake¶
A slower trill.
>>> shake = expressions.Shake() >>> shake.quarterLength 0.25
Shake
bases
Shake
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Shake
read/write properties
Read/write properties inherited from Music21Object
:
Shake
methods
Methods inherited from Trill
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Shake
instance variables
Instance variables inherited from Music21Object
:
Tremolo¶
- class music21.expressions.Tremolo¶
A tremolo ornament represents a single-note tremolo, whether measured or unmeasured.
>>> n = note.Note(type='quarter') >>> trem = expressions.Tremolo() >>> trem.measured = True # default >>> trem.numberOfMarks = 3 # default
>>> trem.numberOfMarks = 'Hi' Traceback (most recent call last): music21.expressions.TremoloException: Number of marks must be a number from 0 to 8
>>> trem.numberOfMarks = -1 Traceback (most recent call last): music21.expressions.TremoloException: Number of marks must be a number from 0 to 8
TODO: (someday) realize triplet Tremolos, etc. differently from other tremolos. TODO: deal with unmeasured tremolos.
Tremolo
bases
Tremolo
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Tremolo
read/write properties
- Tremolo.numberOfMarks¶
The number of marks on the note. Currently, completely controls playback.
Read/write properties inherited from Music21Object
:
Tremolo
methods
- Tremolo.realize(srcObj: music21.note.Note, *, inPlace=False)¶
Realize the ornament
>>> n = note.Note(type='quarter') >>> trem = expressions.Tremolo() >>> trem.measured = True # default >>> trem.numberOfMarks = 3 # default >>> trem.realize(n) ([<music21.note.Note C>, <music21.note.Note C>, <music21.note.Note C>, <music21.note.Note C>, <music21.note.Note C>, <music21.note.Note C>, <music21.note.Note C>, <music21.note.Note C>], None, []) >>> c2 = trem.realize(n)[0] >>> [ts.quarterLength for ts in c2] [0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125]
Same thing with Streams:
>>> n = note.Note(type='quarter') >>> trem = expressions.Tremolo() >>> n.expressions.append(trem) >>> s = stream.Stream() >>> s.append(n) >>> s.show('text') {0.0} <music21.note.Note C>
>>> y = stream.makeNotation.realizeOrnaments(s) >>> y.show('text') {0.0} <music21.note.Note C> {0.125} <music21.note.Note C> {0.25} <music21.note.Note C> {0.375} <music21.note.Note C> {0.5} <music21.note.Note C> {0.625} <music21.note.Note C> {0.75} <music21.note.Note C> {0.875} <music21.note.Note C>
>>> trem.numberOfMarks = 1 >>> y = stream.makeNotation.realizeOrnaments(s) >>> y.show('text') {0.0} <music21.note.Note C> {0.5} <music21.note.Note C>
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Tremolo
instance variables
Instance variables inherited from Music21Object
:
TremoloSpanner¶
- class music21.expressions.TremoloSpanner(*spannedElements, **keywords)¶
A tremolo that spans multiple notes
>>> ts = expressions.TremoloSpanner() >>> n1 = note.Note('C') >>> n2 = note.Note('D') >>> ts.addSpannedElements([n1, n2]) >>> ts.numberOfMarks = 2 >>> ts <music21.expressions.TremoloSpanner <music21.note.Note C><music21.note.Note D>>
>>> ts.numberOfMarks = -1 Traceback (most recent call last): music21.expressions.TremoloException: Number of marks must be a number from 0 to 8
TremoloSpanner
bases
TremoloSpanner
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
TremoloSpanner
read/write properties
- TremoloSpanner.numberOfMarks¶
The number of marks on the note. Will eventually control playback.
Read/write properties inherited from Music21Object
:
TremoloSpanner
methods
Methods inherited from Spanner
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
TremoloSpanner
instance variables
Instance variables inherited from Music21Object
:
Trill¶
- class music21.expressions.Trill¶
A basic trill marker without the trill extension
>>> tr = expressions.Trill() >>> tr.placement 'above' >>> tr.size <music21.interval.GenericInterval 2>
Trills have a .nachschlag attribute which determines whether there should be extra gracenotes at the end of the trill.
>>> tr.nachschlag False >>> tr.nachschlag = True
The Trill also has a “quarterLength” attribute that sets how long each trill note should be. Defaults to 32nd note:
>>> tr.quarterLength 0.125 >>> tr.quarterLength == duration.Duration('32nd').quarterLength True
Changed in v.7 – the size should be a generic second.
Trill
bases
Trill
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Trill
read/write properties
Read/write properties inherited from Music21Object
:
Trill
methods
- Trill.realize(srcObj: music21.note.Note, *, inPlace=False) Tuple[List[music21.note.Note], None, List[music21.note.Note]] ¶
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.
>>> n1 = note.Note('C4') >>> n1.duration.type = 'eighth' >>> t1 = expressions.Trill() >>> n1.expressions.append(t1) >>> realization = t1.realize(n1) >>> realization ([<music21.note.Note C>, <music21.note.Note D>, <music21.note.Note C>, <music21.note.Note D>], None, []) >>> realization[0][0].quarterLength 0.125 >>> realization[0][0].pitch.octave 4
When inside a stream, the realizations will consult the current key to see if it should be a whole-step or half-step trill:
>>> m = stream.Measure() >>> k1 = key.Key('D-') >>> m.insert(0, k1) >>> m.append(n1) >>> t1.realize(n1) ([<music21.note.Note C>, <music21.note.Note D->, <music21.note.Note C>, <music21.note.Note D->], None, [])
Note that if the key contradicts the note of the trill, for instance, here having a C-natural rather than a C-sharp, we do not correct the C to C#.
>>> k2 = key.Key('A') >>> m.replace(k1, k2) >>> t1.realize(n1) ([<music21.note.Note C>, <music21.note.Note D>, <music21.note.Note C>, <music21.note.Note D>], None, [])
This can lead to certain unusual circumstances such as augmented second trills which are technically correct, but probably not what a performer exprects.
>>> k3 = key.Key('E') >>> m.replace(k2, k3) >>> t1.realize(n1) ([<music21.note.Note C>, <music21.note.Note D#>, <music21.note.Note C>, <music21.note.Note D#>], None, [])
To avoid this case, create a
HalfStepTrill
orWholeStepTrill
.If there is a nachschlag, it will appear in the third element of the list.
>>> n1.duration.type = 'quarter' >>> m.replace(k3, k1) # back to D-flat major >>> t1.nachschlag = True >>> t1.realize(n1) ([<music21.note.Note C>, <music21.note.Note D->, <music21.note.Note C>, <music21.note.Note D->, <music21.note.Note C>, <music21.note.Note D->], None, [<music21.note.Note C>, <music21.note.Note B->])
Some notes can be too short to realize if autoscale is off.
>>> n2 = note.Note('D4') >>> n2.duration.type = '32nd' >>> t2 = expressions.Trill() >>> t2.autoScale = False >>> t2.realize(n2) Traceback (most recent call last): music21.expressions.ExpressionException: The note is not long enough to realize a trill
A quicker trill makes it possible:
>>> t2.quarterLength = duration.Duration('64th').quarterLength >>> t2.realize(n2) ([<music21.note.Note D>, <music21.note.Note E>], None, [])
inPlace is not used for Trills.
- Trill.splitClient(noteList)¶
splitClient is called by base.splitAtQuarterLength() to support splitting trills.
>>> n = note.Note(type='whole') >>> n.expressions.append(expressions.Trill()) >>> st = n.splitAtQuarterLength(3.0) >>> n1, n2 = st >>> st.spannerList [<music21.expressions.TrillExtension <music21.note.Note C><music21.note.Note C>>] >>> n1.getSpannerSites() [<music21.expressions.TrillExtension <music21.note.Note C><music21.note.Note C>>]
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Trill
instance variables
Instance variables inherited from Music21Object
:
TrillExtension¶
- class music21.expressions.TrillExtension(*spannedElements, **keywords)¶
A wavy line trill extension, placed between two notes. N ote that some MusicXML readers include a trill symbol with the wavy line.
>>> s = stream.Stream() >>> s.repeatAppend(note.Note(), 8)
Create TrillExtension between notes 2 and 3
>>> te = expressions.TrillExtension(s.notes[1], s.notes[2]) >>> s.append(te) # spanner can go anywhere in the Stream >>> print(te) <music21.expressions.TrillExtension <music21.note.Note C><music21.note.Note C>>
TrillExtension
bases
TrillExtension
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
TrillExtension
read/write properties
- TrillExtension.placement¶
Get or set the placement as either above, below, or None.
>>> s = stream.Stream() >>> s.repeatAppend(note.Note(), 8) >>> te = expressions.TrillExtension(s.notes[1], s.notes[2]) >>> te.placement = 'above' >>> te.placement 'above'
A setting of None implies that the placement will be determined by notation software and no particular placement is demanded.
Read/write properties inherited from Music21Object
:
TrillExtension
methods
Methods inherited from Spanner
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
TrillExtension
instance variables
Instance variables inherited from Music21Object
:
Turn¶
- class music21.expressions.Turn¶
A turn or Gruppetto.
Changed in v.7 – size is a Generic second. removed unused nachschlag component.
Turn
bases
Turn
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Turn
read/write properties
Read/write properties inherited from Music21Object
:
Turn
methods
- Turn.realize(srcObj: music21.note.Note, *, inPlace=False)¶
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>])
>>> m2 = stream.Measure() >>> m2.append(key.KeySignature(5)) >>> n2 = note.Note('B4', type='quarter') >>> m2.append(n2) >>> t2 = expressions.InvertedTurn() >>> n2.expressions.append(t2) >>> t2.realize(n2) ([], <music21.note.Note B>, [<music21.note.Note A#>, <music21.note.Note B>, <music21.note.Note C#>, <music21.note.Note B>])
Realizing an expression leaves the original note and expression alone
>>> n2.duration.type 'quarter' >>> n2.expressions [<music21.expressions.InvertedTurn>]
If inPlace is True then the note is affected and the turn is removed from .expressions:
>>> n2 = note.Note('C4') >>> n2.duration.type = '32nd' >>> t2 = expressions.Turn() >>> _empty, _, turnNotes = t2.realize(n2, inPlace=True) >>> for turnNote in turnNotes: ... print(turnNote, turnNote.duration.type) <music21.note.Note D> 128th <music21.note.Note C> 128th <music21.note.Note B> 128th <music21.note.Note C> 128th >>> n2.duration.type 'zero' >>> n2.expressions []
If .autoScale is off and the note is not long enough to realize 4 32nd notes, then an exception is raised.
>>> n2 = note.Note('C4') >>> n2.duration.type = '32nd' >>> t2 = expressions.Turn() >>> t2.autoScale = False >>> t2.realize(n2) Traceback (most recent call last): music21.expressions.ExpressionException: The note is not long enough to realize a turn
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Turn
instance variables
Instance variables inherited from Music21Object
:
WholeStepAppoggiatura¶
- class music21.expressions.WholeStepAppoggiatura¶
WholeStepAppoggiatura
bases
WholeStepAppoggiatura
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
WholeStepAppoggiatura
read/write properties
Read/write properties inherited from Music21Object
:
WholeStepAppoggiatura
methods
Methods inherited from GeneralAppoggiatura
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
WholeStepAppoggiatura
instance variables
Instance variables inherited from Music21Object
:
WholeStepInvertedAppoggiatura¶
- class music21.expressions.WholeStepInvertedAppoggiatura¶
WholeStepInvertedAppoggiatura
bases
WholeStepInvertedAppoggiatura
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
WholeStepInvertedAppoggiatura
read/write properties
Read/write properties inherited from Music21Object
:
WholeStepInvertedAppoggiatura
methods
Methods inherited from GeneralAppoggiatura
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
WholeStepInvertedAppoggiatura
instance variables
Instance variables inherited from Music21Object
:
WholeStepInvertedMordent¶
- class music21.expressions.WholeStepInvertedMordent¶
A whole-step inverted Mordent.
>>> m = expressions.WholeStepInvertedMordent() >>> m.direction 'up' >>> m.size <music21.interval.Interval M2>
WholeStepInvertedMordent
bases
WholeStepInvertedMordent
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
WholeStepInvertedMordent
read/write properties
Read/write properties inherited from Music21Object
:
WholeStepInvertedMordent
methods
Methods inherited from GeneralMordent
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
WholeStepInvertedMordent
instance variables
Instance variables inherited from Music21Object
:
WholeStepMordent¶
- class music21.expressions.WholeStepMordent¶
A whole step normal Mordent.
>>> m = expressions.WholeStepMordent() >>> m.direction 'down' >>> m.size <music21.interval.Interval M2>
WholeStepMordent
bases
WholeStepMordent
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
WholeStepMordent
read/write properties
Read/write properties inherited from Music21Object
:
WholeStepMordent
methods
Methods inherited from GeneralMordent
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
WholeStepMordent
instance variables
Instance variables inherited from Music21Object
:
WholeStepTrill¶
- class music21.expressions.WholeStepTrill¶
A trill that yields whole steps no matter what.
>>> wholeTrill = expressions.WholeStepTrill() >>> wholeTrill.placement 'above' >>> wholeTrill.size <music21.interval.Interval M2>
Here the key signature of one sharp will not affect the trill:
>>> n = note.Note('B4', type='eighth') >>> m = stream.Measure() >>> m.insert(0, key.KeySignature(1)) >>> m.append(n) >>> wholeTrill.realize(n) ([<music21.note.Note B>, <music21.note.Note C#>, <music21.note.Note B>, <music21.note.Note C#>], None, [])
WholeStepTrill
bases
WholeStepTrill
read-only properties
Read-only properties inherited from Expression
:
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
WholeStepTrill
read/write properties
Read/write properties inherited from Music21Object
:
WholeStepTrill
methods
Methods inherited from Trill
:
Methods inherited from Ornament
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
WholeStepTrill
instance variables
Instance variables inherited from Music21Object
:
Functions¶
- 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:
>>> n1 = note.Note('D5') >>> n1.quarterLength = 1 >>> n1.expressions.append(expressions.WholeStepMordent()) >>> expList = expressions.realizeOrnaments(n1) >>> st1 = stream.Stream() >>> st1.append(expList) >>> st1.show()