GraceDuration
GraceDuration(nominal: Duration, on_beat: bool = False)A notated duration that takes no metrical time: a grace note.
nominal is the symbol written (an eighth, a sixteenth); the width of the event in its line is zero, so a run of grace notes adds nothing to the length of a line, and a grace note stays in the NEXT chain like any other event. How much time it actually steals, and from which neighbour, is a matter of realization, outside core.
on_beat records the semantic distinction that notation marks with a slash: False for the acciaccatura (before the beat, stealing from the preceding note), True for the appoggiatura (on the beat, stealing from the note it decorates).
Like every Measurable, a grace compares and hashes by its length, which is zero, so all graces are equal to each other and to ZeroDuration; compare nominal to tell them apart:
>>> from openmusickit.systems.wsmn.temporal.symbols import quarter, eighth, sixteenth
>>> GraceDuration(eighth) == GraceDuration(sixteenth)
True
>>> GraceDuration(eighth).nominal == GraceDuration(sixteenth).nominal
False
>>> quarter + GraceDuration(eighth) + GraceDuration(sixteenth) == quarter
True
>>> GraceDuration(eighth).temporal_system.name
'Western Standard Music Notation'
>>> GraceDuration(eighth).scale(2)
GraceDuration(MetricalDuration(1, 4))Attributes
| Name | Description |
|---|---|
__slots__ |
|
| rational_length | |
| nominal | |
| on_beat | |
| temporal_system |
Methods
| Name | Description |
|---|---|
__eq__ |
|
__lt__ |
Shorter than other, by rational length, within compatible systems. |
__hash__ |
|
__neg__ |
|
__sub__ |
self + (-other): the difference of two durations, in whatever notation it takes. |
__add__ |
Zero plus any Duration is that Duration, of any system. |
| scale | Scales the notated symbol; the width stays zero. |
__radd__ |
A grace is absorbed by whatever is on its left, sum’s starting 0 included. |
__repr__ |
__eq__
__eq__(other)__lt__
__lt__(other)Shorter than other, by rational length, within compatible systems.
>>> from openmusickit.systems.wsmn.temporal.symbols import quarter, dotted_quarter
>>> quarter < dotted_quarter, dotted_quarter < quarter
(True, False)__hash__
__hash__()__neg__
__neg__()__sub__
__sub__(other)self + (-other): the difference of two durations, in whatever notation it takes.
>>> from openmusickit.systems.wsmn.temporal.symbols import half, quarter
>>> half - quarter, quarter - half
(MetricalDuration(1, 4), MetricalDuration(-1, 4))__add__
__add__(other: Duration)Zero plus any Duration is that Duration, of any system.
>>> from openmusickit.values.time.clock_time import ClockDuration
>>> ZeroDuration() + ClockDuration(5)
ClockDuration(microseconds=5)scale
scale(scalar: int | Fraction)Scales the notated symbol; the width stays zero.
>>> from openmusickit.systems.wsmn.temporal.symbols import grace_eighth
>>> grace_eighth.scale(2)
GraceDuration(MetricalDuration(1, 4))
>>> grace_eighth.scale(2).rational_length
Fraction(0, 1)__radd__
__radd__(other)A grace is absorbed by whatever is on its left, sum’s starting 0 included.
>>> from openmusickit.systems.wsmn.temporal.symbols import grace_eighth, quarter
>>> sum([grace_eighth, quarter, grace_eighth])
MetricalDuration(1, 4)__repr__
__repr__()