CompoundTemporalUnit
CompoundTemporalUnit(units: Iterable[Measurable])An ordered series of Measurables, measured as their total length.
It is a sequence of its members (length, indexing, membership, iteration), and a Measurable of their sum.
>>> from openmusickit.systems.wsmn.temporal.symbols import quarter, eighth
>>> bar = CompoundTemporalUnit([TemporalUnit(2, quarter), TemporalUnit(3, eighth)])
>>> bar.rational_length, len(bar), TemporalUnit(2, quarter) in bar
(Fraction(7, 8), 2, True)
>>> bar[1]
TemporalUnit(3, MetricalDuration(1, 8))Attributes
| Name | Description |
|---|---|
__slots__ |
|
| units | |
| temporal_system | The system of the first member (an empty series belongs to every system). |
| rational_length |
Methods
| Name | Description |
|---|---|
__eq__ |
|
__lt__ |
Shorter than other, by rational length, within compatible systems. |
__hash__ |
|
__init__ |
|
__iter__ |
|
__getitem__ |
|
__len__ |
|
__contains__ |
|
| index | The position of the first member equal to item. |
| count | How many members equal item. |
__repr__ |
|
| remainder | Returns the length of self minus the total length of series. |
| first_out_of_bounds | Returns the index of the first item in series |
| scale | Scales every member. |
__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__()__init__
__init__(units: Iterable[Measurable])__iter__
__iter__()__getitem__
__getitem__(index)__len__
__len__()__contains__
__contains__(item)index
index(item: Measurable)The position of the first member equal to item.
>>> from openmusickit.systems.wsmn.temporal.symbols import quarter, eighth
>>> CompoundTemporalUnit([TemporalUnit(2, quarter), TemporalUnit(3, eighth)]).index(TemporalUnit(3, eighth))
1count
count(item: Measurable)How many members equal item.
>>> from openmusickit.systems.wsmn.temporal.symbols import quarter
>>> CompoundTemporalUnit([TemporalUnit(2, quarter), TemporalUnit(2, quarter)]).count(TemporalUnit(2, quarter))
2__repr__
__repr__()remainder
remainder(series: Iterable[Measurable])Returns the length of self minus the total length of series. Negative if series overflows self.
>>> from openmusickit.systems.wsmn.temporal.symbols import three_four, quarter, half
>>> three_four.remainder([quarter, quarter])
Fraction(1, 4)
>>> three_four.remainder([half, half])
Fraction(-1, 4)first_out_of_bounds
first_out_of_bounds(series: Iterable[Measurable])Returns the index of the first item in series that exceeds the length of self. Returns None if the total length of series is <= length of self.
>>> from openmusickit.systems.wsmn.temporal.symbols import three_four, quarter
>>> three_four.first_out_of_bounds([quarter] * 4)
3
>>> three_four.first_out_of_bounds([quarter] * 3) is None
Truescale
scale(scalar: int | Fraction)Scales every member.
>>> from openmusickit.systems.wsmn.temporal.symbols import quarter, eighth
>>> CompoundTemporalUnit([TemporalUnit(2, quarter), TemporalUnit(3, eighth)]).scale(2)
CompoundTemporalUnit([TemporalUnit(4, MetricalDuration(1, 4)), TemporalUnit(6, MetricalDuration(1, 8))])Raises
| Name | Type | Description |
|---|---|---|
| ScalingError | if any member cannot be scaled by scalar. |