pyabc2.Pitch¶
- class pyabc2.Pitch(value)¶
A pitch with value relative to C0.
- Parameters:
value (int) – Chromatic distance from C0 in semitones (half steps). For example, C4 (middle C) is 48, A4 is 57.
Examples
>>> from pyabc2 import Pitch >>> Pitch(48) Pitch(value=48, name='C4') >>> Pitch(57) Pitch(value=57, name='A4')
>>> Pitch.from_name('E#3') Pitch(value=41, name='E#3') >>> Pitch(41) Pitch(value=41, name='F3')
>>> Pitch.from_etf(440) # Hz Pitch(value=57, name='A4')
Methods
__init__(value)from_class_name(class_name, octave)From pitch class name and octave.
from_class_value(value, octave)From pitch class chromatic value and octave.
from_etf(f)From frequency, rounding to the nearest piano key.
from_helmholtz(helmholtz_name)From Helmholtz pitch notation.
from_name(name)From scientific pitch notation (SPN).
from_pitch_class(pc, octave)From pitch class instance.
to_note(*[, duration])Convert to note (eighth note by default).
to_pitch_class()Convert to pitch class, preserving the class name.
unicode()String repr using unicode accidental symbols and unicode subscripts for octave.
Attributes
class_nameNote name (pitch class).
class_valueChromatic note value of the corresponding pitch class, relative to C.
equal_temperament_frequencyPiano key frequency.
etfAlias for
equal_temperament_frequency.helmholtzPitch name in Helmholtz pitch notation, e.g.
C,andc'(ASCII).nAlias for
piano_key_number.nameNote (pitch) name with octave, e.g., C4, Bb2.
octaveOctave number (e.g., A4/A440 is in octave 4).
piano_key_numberFor example, middle C (C4) is 40.
valuePitch value (integer chromatic distance from C0 in semitones (half steps)).