pitchtypes.basetypes.Pitch

class pitchtypes.basetypes.Pitch

Bases: ABC

The basic interface that is implemented by every pitch (and pitch class) type.

__init__()

Methods

__init__()

embed()

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

interval_from(other)

Computes the interval from another pitch to this pitch.

interval_to(other)

Computes the interval from this pitch to another pitch.

midi()

Return the MIDI number corresponding to the pitch.

parse_pitch(s)

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

pc()

Returns the pitch class corresponding to the pitch.

semitones()

Return the number of chromatic semitones corresponding to the pitch.

steps()

Return the number of diatonic steps corresponding to the pitch.

to_class()

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

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

__hash__ = None
__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)

abstract 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

abstract 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

abstract midi()

Return the MIDI number corresponding to the pitch.

abstract 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

abstract semitones()

Return the number of chromatic semitones corresponding to the pitch.

abstract 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