pitchtypes.basetypes.AbstractPitch

class pitchtypes.basetypes.AbstractPitch

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.

pc()

Returns the pitch class 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

abstractmethod 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

abstractmethod 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

abstractmethod 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

to_class()

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

Returns:

the pitch class that corresponds to this pitch