pyabc2.Note

class pyabc2.Note(value, duration=Fraction(1, 8))

A note has a pitch and a duration.

Parameters:
  • value (int) – Chromatic distance from C0 in semitones (half steps). For example, C4 (middle C) is 48, A4 is 57.

  • duration (Fraction) – The duration of the note, e.g. 1/8 (Fraction('1/8')) for an eighth note, which is the default.

Examples

>>> from pyabc2 import Note
>>> from fractions import Fraction
>>> Note(48)
Note(value=48, name='C4', duration=1/8)
>>> Note(48, Fraction('1/2'))
Note(value=48, name='C4', duration=1/2)
>>> Note.from_abc('C')
Note(value=48, name='C4', duration=1/8)
>>> Note.from_abc('C4')  # 4x unit duration
Note(value=48, name='C4', duration=1/2)
>>> Note.from_abc('D,3', octave_base=3)
Note(value=26, name='D2', duration=3/8)
>>> from pyabc2 import Pitch
>>> p = Pitch.from_name('E#3')
>>> Note.from_pitch(p)
Note(value=41, name='E#3', duration=1/8)
>>> Note(41)
Note(value=41, name='F3', duration=1/8)
__init__(value, duration=Fraction(1, 8))
Parameters:

Methods

__init__(value[, duration])

from_abc(abc, *[, key, octave_base, ...])

Parse ABC string to note.

from_class_name(*args, **kwargs)

not implemented

from_class_value(*args, **kwargs)

not implemented

from_etf(*args, **kwargs)

not implemented

from_helmholtz(*args, **kwargs)

not implemented

from_name(*args, **kwargs)

not implemented

from_pitch(p, *[, duration])

From pitch instance.

from_pitch_class(*args, **kwargs)

not implemented

to_abc(*[, key, octave_base, unit_duration])

Convert to ABC notation string.

to_note()

not implemented

to_pitch()

Convert to pitch, preserving the class name.

to_pitch_class()

Convert to pitch class, preserving the class name.

unicode()

not implemented

Attributes

class_name

Note name (pitch class).

class_value

Chromatic note value of the corresponding pitch class, relative to C.

equal_temperament_frequency

Piano key frequency.

etf

Alias for equal_temperament_frequency.

helmholtz

Pitch name in Helmholtz pitch notation, e.g. C, and c' (ASCII).

n

Alias for piano_key_number.

name

Note (pitch) name with octave, e.g., C4, Bb2.

octave

Octave number (e.g., A4/A440 is in octave 4).

piano_key_number

For example, middle C (C4) is 40.

duration

Note duration.

value

Pitch value (integer chromatic distance from C0 in semitones (half steps)).