Note

class paeonia.Note(pitches: 'tuple[Pitch, ...]' = (), duration: 'Fraction' = Fraction(1, 4), velocity: 'float' = 0.75, tie_in: 'bool' = False, tie_out: 'bool' = False)[source]

Bases: object

Parameters:
  • pitches (tuple[Pitch, ...])

  • duration (Fraction)

  • velocity (float)

  • tie_in (bool)

  • tie_out (bool)

is_rest()[source]

Return whether this event has no sounding pitches.

Return type:

bool

stretch(factor, *, quantize=True)[source]

Return a copy whose duration is multiplied by factor.

The factor is converted to an exact fractions.Fraction before multiplication. Decimal float literals therefore retain their written value: for example, 0.5 is treated as Fraction(1, 2). Pitches, velocity, and tie metadata are unchanged. By default, the result is quantized to the nearest duration that the current LilyPond renderer can express as one token: a power-of-two value from a maxima through a 128th note, with zero, one, or two dots. Equidistant values choose the shorter duration, and values outside the supported range clamp to its nearest endpoint.

Parameters:
  • factor (int | float | Fraction) – Finite, strictly positive duration multiplier.

  • quantize (bool, default=True) – Snap the result to the nearest directly notatable duration. When false, retain the exact multiplied duration even if notation rendering cannot express it as one token.

Returns:

A new note with the stretched duration.

Return type:

Note

Raises:
  • TypeError – If factor is not an integer, float, or fraction, or if quantize is not Boolean.

  • ValueError – If factor is non-finite or not strictly positive.

pitch_order_key()[source]

Return a pitch-based sorting key, placing rests last.

Return type:

tuple[int, tuple[int, …]]

to_lilypond()[source]

Delegate spelling-aware notation rendering to lilypond.py.

Return type:

str

merge_pitches(other)[source]

Merge the pitches of two notes (into a chord).

Parameters:

other (Note) – Another note to merge with.

Returns:

A copy carrying this note’s metadata and both pitch sequences.

Return type:

Note

Raises:

ValueError – If the notes have different durations.