neoscore.western.duration

class neoscore.western.duration.Duration[source]

Bases: object

A metered non-tuplet duration.

The duration fraction indicates duration as a fraction of a whole note. The actual written denomination of duration is deduced from the reduced fraction. For instance:

  • Duration(1, 4) indicates a quarter note value

  • Duration(1, 1) indicates a whole note value

  • Duration(3, 8) indicates a dotted quarter note value

numerator: dataclasses.InitVar
denominator: dataclasses.InitVar
fraction: fractions.Fraction

The reduced fraction representation of the duration

display: Optional[DurationDisplay]

The appearance spec of the duration when written in notes or rests.

This is None if the duration cannot be represented without ties.

classmethod from_def(duration_def: DurationDef) Duration[source]
classmethod from_description(base_division: int, dots: int) Duration[source]

Create a Duration from a base division and a number of dots.

Durations created with this will always have a valid DurationDisplay.

Parameters
  • base_division – Must be 0 (double whole note) or a power of 2

  • dots – Must be >= 0

property requires_tie: bool

If this Duration requires a tie to be written.

__init__(numerator: InitVar, denominator: InitVar) None
neoscore.western.duration.DurationDef

A Duration or a shorthand tuple for one.

alias of Union[Duration, Tuple[int, int]]