pitchtypes.enharmonic.EnharmonicInterval
- class pitchtypes.enharmonic.EnharmonicInterval(value)
Bases:
Enharmonic
,AbstractEnharmonicInterval
,Interval
,Chromatic
- __init__(value)
Takes a string consisting of the form
-?<quality><generic-size>:<octaves>
, e.g."M6:0"
,"-m3:0"
, or"aa2:1"
, which stand for a major sixth, a minor third down, and a double-augmented ninth, 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
Methods
__init__
(value)Takes a string consisting of the form
-?<quality><generic-size>:<octaves>
, e.g."M6:0"
,"-m3:0"
, or"aa2:1"
, which stand for a major sixth, a minor third down, and a double-augmented ninth, respectively.abs
()For downward intervals, return their upward counterpart, otherwise just return the interval itself.
Create a chromatic semitone.
compare
(other)Comparison between two enharmonic intervals according to enharmonic semitone ordering.
convert_to
(other_type)convert_to_logfreq
()create_subtypes
()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 by directly providing its internal semitone value.
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 a perfect octave.
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])Return the number of semitones corresponding to the interval.
set_func_attr
(sub_type, flags, names, funcs)Add functions
funcs
as methods withnames
to classsub_type
, controlled byflags
.steps
()Return the number of diatonic steps corresponding to the interval.
to_class
()Alias for ic(), but also supported by pitch types.
unison
()Create 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()
Create a chromatic semitone.
- Returns:
a1:0
- compare(other)
Comparison between two enharmonic intervals according to enharmonic semitone ordering.
Returns 0 if the objects are equal, 1 if the first interval (
self
) is greater, and -1 if the second interval (other
) is greater.This method can be indirectly used through binary comparison operators (including
==
,<
etc.).- Parameters:
other – an interval to compare to (EnharmonicInterval)
- 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 by directly providing its internal semitone value.
- Parameters:
semitones – the semitones (= interval class) of the interval (integer)
- Returns:
the resulting interval (EnharmonicInterval)
- 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 a perfect octave.
- Returns:
P1:1
- 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()
Create a perfect unison.
- Returns:
P1:0