TiedDuration

TiedDuration(members: Iterable[Duration])

A single sounding duration notated as two or more tied symbols, e.g. quarter tied to sixteenth (5/16).

Produced by adding MetricalDurations whose sum is not a single notatable value. Adding to a TiedDuration merges neighbouring members wherever possible, and collapses back to a plain MetricalDuration when the total becomes notatable.

A tie is a sequence of its members and a Measurable of their sum:

>>> from openmusickit.systems.wsmn.temporal.symbols import half, eighth
>>> tied = TiedDuration([half, eighth])
>>> tied.rational_length, len(tied), tied[0]
(Fraction(5, 8), 2, MetricalDuration(1, 2))
>>> list(tied) == [half, eighth]
True
>>> tied == MetricalDuration.from_length(F(5, 8))
True

Attributes

Name Description
__slots__
members
temporal_system
rational_length The sum of the members’ real lengths.

Methods

Name Description
__eq__
__lt__ Shorter than other, by rational length, within compatible systems.
__hash__
__sub__ self + (-other): the difference of two durations, in whatever notation it takes.
__init__
__iter__
__len__
__getitem__
scale Scale every member; the result is re-merged, so it may collapse to a single symbol.
__neg__ Every member in the opposite direction.
__add__ Adds to the tail, merging back through the members as far as it can.
__radd__ Lets sum start from 0, and sum(tied) rebuild the tie from its members.
__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__()

__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))

__init__

__init__(members: Iterable[Duration])

__iter__

__iter__()

__len__

__len__()

__getitem__

__getitem__(index)

scale

scale(scalar)

Scale every member; the result is re-merged, so it may collapse to a single symbol.

>>> from openmusickit.systems.wsmn.temporal.symbols import half, eighth
>>> TiedDuration([half, eighth]).scale(2)
TiedDuration([MetricalDuration(1, 1), MetricalDuration(1, 4)])
>>> TiedDuration([half, eighth]).scale(3)
MetricalDuration(1, 1, dots=3)

__neg__

__neg__()

Every member in the opposite direction.

>>> from openmusickit.systems.wsmn.temporal.symbols import half, eighth
>>> -TiedDuration([half, eighth])
TiedDuration([MetricalDuration(-1, 2), MetricalDuration(-1, 8)])

__add__

__add__(other)

Adds to the tail, merging back through the members as far as it can.

>>> from openmusickit.systems.wsmn.temporal.symbols import half, eighth, sixteenth, quarter
>>> TiedDuration([half, eighth]) + eighth
MetricalDuration(1, 2, dots=1)
>>> TiedDuration([half, eighth]) + sixteenth
TiedDuration([MetricalDuration(1, 2), MetricalDuration(1, 8, dots=1)])
>>> TiedDuration([half, eighth]) + quarter
MetricalDuration(1, 2, dots=2)

Raises TemporalCompatibilityError for a Duration of another system, as MetricalDuration.__add__ does.

__radd__

__radd__(other)

Lets sum start from 0, and sum(tied) rebuild the tie from its members.

>>> from openmusickit.systems.wsmn.temporal.symbols import half, eighth
>>> sum(TiedDuration([half, eighth]))
TiedDuration([MetricalDuration(1, 2), MetricalDuration(1, 8)])

__repr__

__repr__()