pitchtypes.enharmonic.EnharmonicIntervalClass

class pitchtypes.enharmonic.EnharmonicIntervalClass(value)

Bases: Enharmonic, AbstractEnharmonicInterval, Interval, Chromatic

__init__(value)

Takes a string consisting of the form -?<quality><generic-size>, e.g. "M6", "-m3", or "aa2", which stand for a major sixth, a minor third down (= major sixth up), and a double-augmented second, respectively. possible qualities are d (diminished), m (minor), M (major), P (perfect), and a (augmented), where d and a can be repeated.

Parameters:

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

Methods

__init__(value)

Takes a string consisting of the form -?<quality><generic-size>, e.g. "M6", "-m3", or "aa2", which stand for a major sixth, a minor third down (= major sixth up), and a double-augmented second, respectively.

abs()

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

chromatic_semitone()

Return a chromatic semitone

compare(other)

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

convert_to(other_type)

convert_to_logfreq()

create_subtypes()

direction()

Returns the direction of the interval (1 = up, 0 = neutral, -1 = down).

embed()

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

from_semitones(semitones)

Create an interval class by directly providing its internal semitones.

ic()

Return the interval class that corresponds to this interval.

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.

name()

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

Check if sub_type follows the standard naming convention.

octave()

Create the octave interval of this type.

octaves()

parse_interval(s)

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

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()

Return the number of semitones corresponding to the interval.

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

to_class()

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

unison()

Return a perfect unison.

Interval

alias of EnharmonicInterval

IntervalClass

alias of EnharmonicIntervalClass

Pitch

alias of EnharmonicPitch

PitchClass

alias of EnharmonicPitchClass

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

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

__mul__(other)

Returns an integer multiple of the interval.

__neg__()

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

__repr__()

Return repr(self).

__rmul__(other)

Returns an integer multiple of the interval.

__setattr__(key, value)

Implement setattr(self, name, value).

__str__()

Return str(self).

__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

classmethod chromatic_semitone()

Return a chromatic semitone

Returns:

a1

compare(other)

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

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

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

Parameters:

other – an interval class to compare to (EnharmonicIntervalClass)

Returns:

-1 / 0 / 1 (integer)

direction()

Returns the direction of the interval (1 = up, 0 = neutral, -1 = down). Only perfect unisons are considered neutral.

Returns:

-1 / 0 / 1 (integer)

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

static from_semitones(semitones)

Create an interval class by directly providing its internal semitones.

Parameters:

semitones – the semitones (= interval class) of the interval (integer)

Returns:

the resulting interval class (EnharmonicIntervalClass)

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

classmethod octave()

Create the octave interval of this type.

Returns:

an octave interval

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()

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.

Returns:

the interval’s corresponding interval class

classmethod unison()

Return a perfect unison.

Returns:

P1