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')
__init__(value)
Parameters:

value (int)

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_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.

value

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