TemporalUnit
TemporalUnit(count: int, base: Measurable)A length of musical time defined as n number of a Measurable Duration. This is used to represent (among other things) time signatures and tuple definitions.
Example: WSMN Time Signatures
A time signature has: - a numerator (top number), which defines “how many” of some MetricalDuration. - a denominator (bottom number), which defines some MetricalDuration.
So 4/4 time is 4 quarter notes and is expressed as:
>>> from openmusickit.systems.wsmn.temporal.metrical_duration import MetricalDuration
>>> TemporalUnit(4, MetricalDuration(1, 4)).rational_length
Fraction(1, 1)Compound meters such as 6/8 can be expressed using the dotted duration or the base duration:
>>> TemporalUnit(6, MetricalDuration(1, 8)) == TemporalUnit(2, MetricalDuration(1, 4, dots=1))
TrueMore exotic time signatures can be achieved by using tupleted durations as the denominator.
Tuplets
Musically, a tuplet is defined as a ratio of notated notes (expressed as nominal Durations) to the amount of time those notes take up as expressed in the surrounding musical context.
A standard quarter note triplet, then, is: - three quarter notes, which take up the time of - two quarter notes.
Each of these (nominal and actual) is defined as a TemporalUnit, and combined into a tuplet definition using a TemporalRatio.
Attributes
| Name | Description |
|---|---|
__slots__ |
|
| count | |
| base | |
| temporal_system | |
| rational_length | The count times the base: three eighths are three eighths of a whole note. |
Methods
| Name | Description |
|---|---|
__eq__ |
|
__lt__ |
Shorter than other, by rational length, within compatible systems. |
__hash__ |
|
| scale | Scale the Temporal Unit. |
__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__()scale
scale(scalar: int | Fraction)Scale the Temporal Unit.
The count is scaled whenever the result is a whole number (4 quarters * 2 = 8 quarters; 6 eighths / 2 = 3 eighths). Otherwise the remaining factor is pushed into the base duration (3 eighths / 2 = 3 sixteenths; 1 quarter * 3/2 = 3 eighths; 4 quarters / 3 = 4 triplet eighths, if the base supports tuplets).
>>> from openmusickit.systems.wsmn.temporal.symbols import quarter, eighth
>>> TemporalUnit(4, quarter).scale(2)
TemporalUnit(8, MetricalDuration(1, 4))
>>> TemporalUnit(3, eighth).scale(Fraction(1, 2))
TemporalUnit(3, MetricalDuration(1, 16))
>>> TemporalUnit(4, quarter).scale(Fraction(1, 3)).base.rational_length
Fraction(1, 12)Raises
| Name | Type | Description |
|---|---|---|
| ScalingError | if the scalar is not positive, or if the base cannot absorb the leftover factor. |
__repr__
__repr__()