TimeSignature

TimeSignature(
    spec: TemporalUnit | Iterable[TemporalUnit] | CompoundTemporalUnit,
    presentation: tuple[str, str] | None = None,
)

A WSMN time signature: an ordered series of TemporalUnits (one for simple meters, several for additive meters such as 2+2+3/8), with an optional presentation (the numbers as printed).

>>> from openmusickit.systems.wsmn.temporal.symbols import quarter, eighth
>>> four_four = TimeSignature(TemporalUnit(4, quarter), presentation=("4", "4"))
>>> seven_eight = TimeSignature(
...     [TemporalUnit(2, eighth), TemporalUnit(2, eighth), TemporalUnit(3, eighth)],
...     presentation=("2+2+3", "8"))
>>> seven_eight.rational_length
Fraction(7, 8)

A TimeSignature compares equal to anything of the same total length, so 4/4 == 2/2 == 8/8.

>>> from openmusickit.systems.wsmn.temporal.symbols import two_two
>>> four_four == two_two
True

Attributes

Name Description
__slots__
temporal_system The system of the first member (an empty series belongs to every system).
rational_length
units
presentation

Methods

Name Description
__eq__
__lt__ Shorter than other, by rational length, within compatible systems.
__hash__
__iter__
__getitem__
__len__
__contains__
index The position of the first member equal to item.
count How many members equal item.
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
__init__
scale Scale the time signature.
__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__()

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

count

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

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
True

__init__

__init__(
    spec: TemporalUnit | Iterable[TemporalUnit] | CompoundTemporalUnit,
    presentation: tuple[str, str] | None = None,
)

scale

scale(scalar)

Scale the time signature.

Counts are scaled when they stay whole (4/4 * 2 = 8/4; 6/8 / 2 = 3/8), otherwise the denominator changes (3/8 / 2 = 3/16). An odd factor (4/4 / 3) gives a tupleted denominator (4 triplet eighths). The presentation is scaled the same way when it is numeric and the result can be written as plain numbers; otherwise it is dropped.

>>> from openmusickit.systems.wsmn.temporal.symbols import four_four, three_eight
>>> four_four.scale(2)
TimeSignature([TemporalUnit(8, MetricalDuration(1, 4))], ('8', '4'))
>>> three_eight.scale(Fraction(1, 2))
TimeSignature([TemporalUnit(3, MetricalDuration(1, 16))], ('3', '16'))
>>> third = four_four.scale(Fraction(1, 3))
>>> third.rational_length, third.presentation
(Fraction(1, 3), None)

Raises

Name Type Description
ScalingError if the scalar is not positive.

__repr__

__repr__()