Classes and functions for creating and manipulating dynamic symbols. Rather than subclasses, the Dynamic object is often specialized by parameters.
Given a decimal from 0 to 1, return a string representing a dynamic with 0 being the softest (0.01 = ‘ppp’) and 1 being the loudest (0.9+ = ‘fff’) 0 returns “n” (niente), while ppp and fff are the loudest dynamics used.
>>> dynamics.dynamicStrFromDecimal(0.25)
'pp'
>>> dynamics.dynamicStrFromDecimal(1)
'fff'
Object representation of Dynamics.
>>> pp1 = dynamics.Dynamic('pp')
>>> pp1.value
'pp'
>>> pp1.longName
'pianissimo'
>>> pp1.englishName
'very soft'
Dynamics can also be specified on a 0 to 1 scale with 1 being the loudest (see dynamicStrFromDecimal() above)
>>> pp2 = dynamics.Dynamic(0.15) # on 0 to 1 scale
>>> pp2.value
'ppp'
>>> print '%.2f' % pp2.volumeScalar
0.15
Dynamics can be placed anywhere in a stream.
>>> s = stream.Stream()
>>> s.insert(0, note.HalfNote('E-4'))
>>> s.insert(2, note.HalfNote('F#5'))
>>> s.insert(0, dynamics.Dynamic('pp'))
>>> s.insert(1, dynamics.Dynamic('mf'))
>>> s.insert(3, dynamics.Dynamic('fff'))
>>> s.show()
Dynamic bases
Dynamic read-only properties
Read-only properties inherited from Music21Object:
Dynamic read/write properties
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.
>>> te = expressions.TextExpression()
>>> te.positionVertical = 10
>>> te.positionVertical
10.0
Get or set the value of this dynamic, which sets the long and english names of this Dynamic. The value is a string specification.
Get or set the volume scalar for this dynamic. If not explicitly set, a default volume scalar will be provided. Any number between 0 and 1 can be used to set the volume scalar, overriding the expected behavior.
As mezzo is at .5, the unit interval range is doubled for generating final output. The default output is .5.
>>> d = dynamics.Dynamic('mf')
>>> d.volumeScalar
0.55...
int(volumeScalar * 127) gives the MusicXML <sound dynamics=”x”/> tag
>>> print musicxml.m21ToString.fromMusic21Object(d)
<?xml...
<direction>
<direction-type>
<dynamics default-x="-36" default-y="-80">
<mf/>
</dynamics>
</direction-type>
<offset>0</offset>
<sound dynamics="69"/>
</direction>...
Read/write properties inherited from Music21Object:
Dynamic methods
Methods inherited from Music21Object:
Dynamic instance variables
the name of this dynamic in English.
>>> d = dynamics.Dynamic('pp')
>>> d.englishName
'very soft'
the name of this dynamic in Italian.
>>> d = dynamic.Dynamic('pp')
>>> d.longName
'pianissimo'
Instance variables inherited from Music21Object:
A spanner crescendo wedge.
>>> from music21 import dynamics
>>> d = dynamics.Crescendo()
>>> d.getStartParameters()
{'spread': 0, 'type': 'crescendo'}
>>> d.getEndParameters()
{'spread': 15, 'type': 'stop'}
Crescendo bases
Crescendo read-only properties
Read-only properties inherited from Music21Object:
Crescendo read/write properties
Read/write properties inherited from Music21Object:
Crescendo methods
Return the parameters for the start of this spanner
Return the parameters for the start of this spanner
Methods inherited from Spanner:
Methods inherited from Music21Object:
Crescendo instance variables
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
>>> m21o = base.Music21Object()
>>> m21o.classSortOrder
20
>>> 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
An instance of a Group object which describes arbitrary Groups that this object belongs to.
if set to True will not print upon output (only used in MusicXML output at this point and Lilypond for notes, chords, and rests).
A unique identification string (not to be confused with the default .id() method.
if set, defines the display x-position from the start of the container (in musicxml “tenths” by default)
Instance variables inherited from DynamicWedge:
Instance variables inherited from Spanner:
Instance variables inherited from Music21Object:
A spanner diminuendo wedge.
>>> from music21 import dynamics
>>> d = dynamics.Diminuendo()
>>> d.getStartParameters()
{'spread': 15, 'type': 'diminuendo'}
>>> d.getEndParameters()
{'spread': 0, 'type': 'stop'}
Diminuendo bases
Diminuendo read-only properties
Read-only properties inherited from Music21Object:
Diminuendo read/write properties
Read/write properties inherited from Music21Object:
Diminuendo methods
Return the parameters for the start of this spanner
Return the parameters for the start of this spanner
Methods inherited from Spanner:
Methods inherited from Music21Object:
Diminuendo instance variables
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
>>> m21o = base.Music21Object()
>>> m21o.classSortOrder
20
>>> 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
An instance of a Group object which describes arbitrary Groups that this object belongs to.
if set to True will not print upon output (only used in MusicXML output at this point and Lilypond for notes, chords, and rests).
A unique identification string (not to be confused with the default .id() method.
if set, defines the display x-position from the start of the container (in musicxml “tenths” by default)
Instance variables inherited from DynamicWedge:
Instance variables inherited from Spanner:
Instance variables inherited from Music21Object:
Common base-class for Crescendo and Diminuendo.
DynamicWedge bases
DynamicWedge read-only properties
Read-only properties inherited from Music21Object:
DynamicWedge read/write properties
Read/write properties inherited from Music21Object:
DynamicWedge methods
Methods inherited from Spanner:
Methods inherited from Music21Object:
DynamicWedge instance variables
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
>>> m21o = base.Music21Object()
>>> m21o.classSortOrder
20
>>> 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
An instance of a Group object which describes arbitrary Groups that this object belongs to.
if set to True will not print upon output (only used in MusicXML output at this point and Lilypond for notes, chords, and rests).
A unique identification string (not to be confused with the default .id() method.
if set, defines the display x-position from the start of the container (in musicxml “tenths” by default)
Instance variables inherited from Spanner:
Instance variables inherited from Music21Object: