pitchtypes.enharmonic.EnharmonicPitchClass

class pitchtypes.enharmonic.EnharmonicPitchClass(value)

Bases: Enharmonic, AbstractEnharmonicPitch, Pitch

__init__(value)

Takes a string consisting of the form <letter><accidentals?>, e.g. "C#", "E", or "Dbb". Accidentals may be written as ASCII symbols (#/b) or with unicode symbols (♯/♭), but not mixed within the same note.

Parameters:

value – a string or internal numeric representation of the pitch class

Methods

__init__(value)

Takes a string consisting of the form <letter><accidentals?>, e.g. "C#", "E", or "Dbb".

compare(other)

Comparison between two enharmonic pitch classes according to enharmonic semitone ordering.

convert_to(other_type)

convert_to_logfreq()

create_subtypes()

embed()

For a pitch class, returns the corresponding pitch in a (type-dependent) default octave.

freq()

from_semitones(semitones)

interval_from(other)

Computes the interval from another pitch to this pitch.

interval_to(other)

Computes the interval from this pitch to another pitch.

link_interval_class_type([skip_name_check, ...])

A decorator to link an interval class type to its base type.

link_interval_type([skip_name_check, ...])

A decorator to link an interval type to its base type.

link_pitch_class_type([skip_name_check, ...])

A decorator to link a pitch class type to its base type.

link_pitch_type([skip_name_check, ...])

A decorator to link a pitch type to its base type.

midi()

Return the MIDI value of the pitch class, a value in the range [0, 11].

name([as_int, flat_sharp])

name_check(cls, sub_type, suffix, ...)

Check if sub_type follows the standard naming convention.

octaves()

parse_pitch(s)

Parse a string as a spelled pitch or spelled pitch class.

pc()

Returns the pitch class corresponding to the pitch.

pitch_class_name_from_midi(midi_pitch, ...)

Return the pitch class name for the given pitch in MIDI integer.

print_options([as_int, flat_sharp])

semitones()

Equivalent to the MIDI value of the pitch class.

set_func_attr(sub_type, flags, names, funcs)

Add functions funcs as methods with names to class sub_type, controlled by flags.

steps()

Return the number of diatonic steps corresponding to the pitch.

to_class()

Alias for pc(), but also supported by interval types.

Interval

alias of EnharmonicInterval

IntervalClass

alias of EnharmonicIntervalClass

Pitch

alias of EnharmonicPitch

PitchClass

alias of EnharmonicPitchClass

__add__(other)

Returns the pitch transposed by an interval

Parameters:

other – an interval of matching type

Returns:

the pitch transposed by other

__eq__(other)

Return self==value.

__ge__(other, NotImplemented=NotImplemented)

Return a >= b. Computed by @total_ordering from (not a < b).

__gt__(other, NotImplemented=NotImplemented)

Return a > b. Computed by @total_ordering from (not a < b) and (a != b).

__hash__ = None
__le__(other, NotImplemented=NotImplemented)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

__lt__(other)

Return self<value.

__repr__()

Return repr(self).

__setattr__(key, value)

Implement setattr(self, name, value).

__str__()

Return str(self).

__sub__(other)

When subtracting another pitch (p1 - p2), return the interval from p2 to p1. When subtracting an interval (p - i), transpose the pitch by the inverse interval (p + -i).

Parameters:

other – pitch or interval

Returns:

if other is an interval, the transposed pitch; if other is a pitch, the interval between both pitches

__weakref__

list of weak references to the object (if defined)

compare(other)

Comparison between two enharmonic pitch classes according to enharmonic semitone ordering.

Returns 0 if the objects are equal, 1 if the first pitch class (self) is higher, and -1 if the second pitch class (other) is higher.

This method can be indirectly used through binary comparison operators (including ==, < etc.).

Parameters:

other – a pitch class to compare to (EnharmonicPitchClass)

Returns:

-1 / 0 / 1 (integer)

embed()

For a pitch class, returns the corresponding pitch in a (type-dependent) default octave. For non-class pitches, returns the pitch itself.

Returns:

a non-class version of this pitch

interval_from(other)

Computes the interval from another pitch to this pitch.

Parameters:

other – another pitch

Returns:

the interval from other to self

interval_to(other)

Computes the interval from this pitch to another pitch.

Parameters:

other – another pitch

Returns:

the interval from self to other

midi()

Return the MIDI value of the pitch class, a value in the range [0, 11].

pc()

Returns the pitch class corresponding to the pitch. For pitch classes, it returns the pitch class itself.

Returns:

the pitch class that corresponds to this pitch

static pitch_class_name_from_midi(midi_pitch, flat_sharp)

Return the pitch class name for the given pitch in MIDI integer. :type midi_pitch: :param midi_pitch: MIDI pitch :type flat_sharp: :param flat_sharp: whether to use flats or sharps for accidentals :return: pitch class

semitones()

Equivalent to the MIDI value of the pitch class.

steps()

Return the number of diatonic steps corresponding to the pitch.

to_class()

Alias for pc(), but also supported by interval types.

Returns:

the pitch class that corresponds to this pitch