pitchtypes.basetypes.Interval

class pitchtypes.basetypes.Interval

Bases: ABC

The basic interface implemented by every interval (and interval class) type.

__init__()

Methods

__init__()

abs()

For downward intervals, return their upward counterpart, otherwise just return the interval itself.

direction()

Determines the direction of the interval: 1 for up, -1 for down and 0 for neutral.

embed()

For interval classes, return an embedding into the interval space in a (type-dependent) default octave.

ic()

Return the interval class that corresponds to this interval.

octave()

Create the octave interval of this type.

parse_interval(s)

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

semitones()

Return the number of semitones corresponding to the interval.

steps()

Return the number of diatonic steps corresponding to the interval.

to_class()

Alias for ic(), but also supported by pitch types.

unison()

Create the unison interval of this type.

abstract __abs__()

For downward intervals, return their upward counterpart, otherwise just return the interval itself.

__add__(other)

Returns the sum of two intervals.

__eq__(other)

Return self==value.

__hash__ = None
__mul__(other)

Returns an integer multiple of the interval.

__neg__()

Returns the inversion of the interval (same size in the other direction).

__rmul__(other)

Returns an integer multiple of the interval.

__sub__(other)

Returns the difference of two intervals.

__weakref__

list of weak references to the object (if defined)

abs()

For downward intervals, return their upward counterpart, otherwise just return the interval itself.

Returns:

the absolute interval

abstract direction()

Determines the direction of the interval: 1 for up, -1 for down and 0 for neutral. Different types may have different conventions for the direction of an interval.

Returns:

the interval’s direction (-1 / 0 / 1, integer)

abstract embed()

For interval classes, return an embedding into the interval space in a (type-dependent) default octave. For non-class intervals, return the interval itself.

Returns:

a non-class version of this interval

abstract ic()

Return the interval class that corresponds to this interval. If the interval is already an interval class, it is returned itself.

Returns:

the interval’s corresponding interval class

abstract classmethod octave()

Create the octave interval of this type.

Returns:

an octave interval

abstract semitones()

Return the number of semitones corresponding to the interval.

abstract steps()

Return the number of diatonic steps corresponding to the interval.

to_class()

Alias for ic(), but also supported by pitch types.

Returns:

the interval’s corresponding interval class

abstract classmethod unison()

Create the unison interval of this type.

Returns:

a unison interval