10.1.13.3. Pitch

Classes for representing and manipulating pitches, pitch-space, and accidentals.

class Musica.Theory.Pitch.Accidental(accidental_value)[source]

Bases: object

Accidental class, representing the symbolic and numerical representation of pitch deviation from a pitch name (e.g. C).

__eq__(other)[source]
__str__()[source]
clone()[source]
classmethod parse_accidental(value)[source]

Return an alteration from a Alteration instance, an alteration name or a modifier string.

__alteration_to_name__ = {0: 'natural', 1: 'sharp', 2: 'double-sharp', 3: 'triple-sharp', 4: 'quadruple-sharp', -1: 'flat', -2: 'double-flat', -3: 'triple-flat', -4: 'quadruple-flat', 0.5: 'half-flat', 1.5: 'one-and-a-half-sharp', -1.5: 'one-and-a-half-flat'}
__hash__ = None
__modifier_regexp__ = re.compile('[#-]*')
__name_to_alteration__ = {'natural': 0, 'sharp': 1, 'double-sharp': 2, 'triple-sharp': 3, 'quadruple-sharp': 4, 'flat': -1, 'double-flat': -2, 'triple-flat': -3, 'quadruple-flat': -4, 'half-sharp': 0.5, 'one-and-a-half-sharp': 1.5, 'half-flat': 0.5, 'one-and-a-half-flat': -1.5}
__name_to_modifier__ = {'natural': '', 'sharp': '#', 'double-sharp': '##', 'triple-sharp': '###', 'quadruple-sharp': '####', 'flat': '-', 'double-flat': '--', 'triple-flat': '---', 'quadruple-flat': '----', 'half-sharp': '~', 'one-and-a-half-sharp': '#~', 'half-flat': '`', 'one-and-a-half-flat': '-`'}
alteration
is_flat
is_normal
is_sharp
modifier
name
unicode_name
class Musica.Theory.Pitch.Pitch(name=None, **kwargs)[source]

Bases: object

Class to represents a pitch.

__eq__(other)[source]
__float__()[source]
__ge__(other)[source]
__gt__(other)[source]
__int__()[source]
__le__(other)[source]
__lt__(other)[source]
__str__()[source]
_compute_float_value(octave, add_microtone=True)[source]
_init_from_clone(other)[source]
_init_from_kwargs(kwargs)[source]
_init_from_number(step_number, kwargs)[source]
_init_from_string(name, kwargs)[source]
_locale(natural=False)[source]
_prev_next_pitch(offset)[source]
clone()[source]
get_enharmonic()[source]

Returns a new Pitch that is the enharmonic equivalent of this Pitch.

is_enharmonic(other)[source]
next_pitch()[source]
classmethod parse_pitch(name, return_dict=False)[source]
pitch_iterator(until=None)[source]
prev_pitch()[source]
simplify_accidental()[source]
str(locale=None, latin=False, unicode=False, octave=False)[source]
__hash__ = None
__implicit_octave__ = 4
__pitch_regexp__ = re.compile('(?P<note>[abcdefg])(?P<accidental>[#-]*)(?P<octave_sign>(/-)?)(?P<octave>\\d*)')
__temperament__ = <Musica.Theory.Temperament.UsualEqualTemperament object>
accidental
alteration
degree
english_locale
french_locale
frequency
full_name
implicit_octave
is_altered
latin_unicode_name
latin_unicode_name_with_octave
locale
midi

Return the closest midi code.

The MIDI specification only defines note number 60 as “Middle C” (C4, Do3), and all other notes are relative. Note are encoded by a 7-bit non signed integer, ranging from 0 to 127. Consequently, Midi map note C/-1 to 0, C#0 to 1, … and G9 to 127.

midi_float
name
natural_locale
octave
pitch_class

Returns the integer value for the pitch, between 0 and 11, where C=0, C#=1, D=2, … B=11.

spelling_is_inferred
step

The diatonic name of the note; i.e. it does not give the accidental and octave.

step_number
temperament
unicode_name
unicode_name_with_octave