Table Of Contents

Previous topic

music21.duration

Next topic

music21.analysis.discrete

This Page

music21.dynamics

Classes and functions for creating and manipulating dynamic symbols. Rather than subclasses, the Dynamic object is often specialized by parameters.

music21.dynamics.dynamicStrFromDecimal(n)

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.

>>> from music21 import *
>>> dynamics.dynamicStrFromDecimal(0.25)
'p'
>>> dynamics.dynamicStrFromDecimal(1)
'fff'

Dynamic

Inherits from: Music21Object, JSONSerializer

class music21.dynamics.Dynamic(value=None)

Object representation of Dyanmics.

>>> from music21 import *
>>> 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
'pp'

Dynamic 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 without Documentation: posPlacement, value, posRelativeY, posDefaultX, posDefaultY, longName, posRelativeX, englishName

Attributes inherited from Music21Object: id, groups

Dynamic properties

musicxml
Provide a complete MusicXML representation.
mx

returns a musicxml.Direction object

>>> from music21 import *
>>> a = dynamics.Dynamic('ppp')
>>> a.posRelativeY = -10
>>> b = a.mx
>>> b[0][0][0].get('tag')
'ppp'
>>> b.get('placement')
'below'

Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority

Properties inherited from JSONSerializer: json

Dynamic methods

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

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

Wedge

Inherits from: Music21Object, JSONSerializer

class music21.dynamics.Wedge(value=None)

Object model of crescendeo/decrescendo wedges.

Wedge attributes

Attributes without Documentation: posPlacement, spread, type

Attributes inherited from Music21Object: classSortOrder, id, groups

Wedge properties

mx

returns a musicxml.Direction object

>>> from music21 import *
>>> a = dynamics.Wedge()
>>> a.type = 'crescendo'
>>> mxDirection = a.mx
>>> mxWedge = mxDirection.getWedge()
>>> mxWedge.get('type')
'crescendo'

Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority

Properties inherited from JSONSerializer: json

Wedge methods

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

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