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.
>>> from music21 import *
>>> dynamics.dynamicStrFromDecimal(0.25)
'pp'
>>> dynamics.dynamicStrFromDecimal(1)
'fff'
Inherits from: Music21Object
Object representation of Dynamics.
>>> 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
'ppp'
>>> 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 attributes
- longName¶
the name of this dynamic in Italian.
>>> from music21 import * >>> d = dynamic.Dynamic('pp') >>> d.longName 'pianissimo'
- englishName¶
the name of this dynamic in English.
>>> from music21 import * >>> d = dynamics.Dynamic('pp') >>> d.englishName 'very soft'Attributes without Documentation: classSortOrder
Attributes inherited from Music21Object: isSpanner, isStream, isVariant, xPosition, id, sites, groups, hideObjectOnPrint
Dynamic properties
- 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.0
- value¶
Get or set the value of this dynamic, which sets the long and english names of this Dynamic. The value is a string specification.
- volumeScalar¶
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.
>>> from music21 import * >>> 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>...Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, fullyQualifiedClasses, isGrace, measureNumber, offset, priority, seconds
Dynamic methods
Methods inherited from Music21Object: addContext(), addLocation(), findAttributeInHierarchy(), getAllContextsByClass(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), removeLocationBySite(), removeLocationBySiteId(), setContextAttr(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: DynamicWedge, Spanner, 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 attributes
Attributes inherited from DynamicWedge: spread, placement, type
Attributes inherited from Spanner: isSpanner, spannedElements, idLocal, completeStatus
Attributes inherited from Music21Object: classSortOrder, isStream, isVariant, hideObjectOnPrint, xPosition, sites, groups, id
Crescendo properties
Properties inherited from Music21Object: classes, fullyQualifiedClasses, activeSite, beat, beatDuration, beatStr, beatStrength, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
Crescendo methods
- getEndParameters()¶
Return the parameters for the start of this spanner
- getStartParameters()¶
Return the parameters for the start of this spanner
Methods inherited from Spanner: addSpannedElements(), getDurationBySite(), getDurationSpanBySite(), getFirst(), getLast(), getOffsetSpanBySite(), getOffsetsBySite(), getSpannedElementIds(), getSpannedElements(), getSpannedElementsByClass(), getSpannerStorageId(), hasSpannedElement(), isFirst(), isLast(), purgeLocations(), purgeOrphans(), replaceSpannedElement(), unwrapWeakref(), wrapWeakref()
Methods inherited from Music21Object: findAttributeInHierarchy(), getContextAttr(), setContextAttr(), addContext(), addLocation(), getAllContextsByClass(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), write()
Inherits from: DynamicWedge, Spanner, 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 attributes
Attributes inherited from DynamicWedge: spread, placement, type
Attributes inherited from Spanner: isSpanner, spannedElements, idLocal, completeStatus
Attributes inherited from Music21Object: classSortOrder, isStream, isVariant, hideObjectOnPrint, xPosition, sites, groups, id
Diminuendo properties
Properties inherited from Music21Object: classes, fullyQualifiedClasses, activeSite, beat, beatDuration, beatStr, beatStrength, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
Diminuendo methods
- getEndParameters()¶
Return the parameters for the start of this spanner
- getStartParameters()¶
Return the parameters for the start of this spanner
Methods inherited from Spanner: addSpannedElements(), getDurationBySite(), getDurationSpanBySite(), getFirst(), getLast(), getOffsetSpanBySite(), getOffsetsBySite(), getSpannedElementIds(), getSpannedElements(), getSpannedElementsByClass(), getSpannerStorageId(), hasSpannedElement(), isFirst(), isLast(), purgeLocations(), purgeOrphans(), replaceSpannedElement(), unwrapWeakref(), wrapWeakref()
Methods inherited from Music21Object: findAttributeInHierarchy(), getContextAttr(), setContextAttr(), addContext(), addLocation(), getAllContextsByClass(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), write()
Inherits from: Spanner, Music21Object
Common base-class for Crescendo and Diminuendo.
DynamicWedge attributes
Attributes without Documentation: spread, placement, type
Attributes inherited from Spanner: isSpanner, spannedElements, idLocal, completeStatus
Attributes inherited from Music21Object: classSortOrder, isStream, isVariant, hideObjectOnPrint, xPosition, sites, groups, id
DynamicWedge properties
Properties inherited from Music21Object: classes, fullyQualifiedClasses, activeSite, beat, beatDuration, beatStr, beatStrength, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
DynamicWedge methods
Methods inherited from Spanner: addSpannedElements(), getDurationBySite(), getDurationSpanBySite(), getFirst(), getLast(), getOffsetSpanBySite(), getOffsetsBySite(), getSpannedElementIds(), getSpannedElements(), getSpannedElementsByClass(), getSpannerStorageId(), hasSpannedElement(), isFirst(), isLast(), purgeLocations(), purgeOrphans(), replaceSpannedElement(), unwrapWeakref(), wrapWeakref()
Methods inherited from Music21Object: findAttributeInHierarchy(), getContextAttr(), setContextAttr(), addContext(), addLocation(), getAllContextsByClass(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), write()