pitchtypes.generic.Generic
- class pitchtypes.generic.Generic(value, is_pitch, is_class, **kwargs)
Bases:
AbstractBase
A common base class for generic pitch and interval types. See below for a set of common operations.
- __init__(value, is_pitch, is_class, **kwargs)
Methods
__init__
(value, is_pitch, is_class, **kwargs)compare
(other)Comparison between two generic types.
convert_to
(other_type)create_subtypes
()degree
()Return the "relative scale degree" (0-6) to which the interval points (unison=0, 2nd=1, octave=0, 2nd down=6, etc.).
generic_interval_class_from_fifths
(fifth_steps)Return the generic interval class corresponding to the given number of fifths.
Return the internal octave representation of a pitch
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
()The name of the pitch or interval in string notation
name_check
(cls, sub_type, suffix, ...)Check if
sub_type
follows the standard naming convention.octaves
()For intervals, return the number of octaves the interval spans.
onehot
()Return a one-hot encoded tensor representing the object.
pitch_class_from_diatonic_steps
(diatonic_steps)Return the pitch class given the number of steps
pitch_class_name_from_steps
(step_pitch)Return the pitch class name for the given pitch in steps, alias for pitch_class_from_diatonic_steps
print_options
([as_int])set_func_attr
(sub_type, flags, names, funcs)Add functions
funcs
as methods withnames
to classsub_type
, controlled byflags
.steps
()Return the position of the interval in diatonic steps.
- Interval
alias of
GenericInterval
- IntervalClass
alias of
GenericIntervalClass
- Pitch
alias of
GenericPitch
- PitchClass
alias of
GenericPitchClass
- __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.
- __repr__()
Return repr(self).
- __setattr__(key, value)
Implement setattr(self, name, value).
- __str__()
Return str(self).
- __weakref__
list of weak references to the object (if defined)
- compare(other)
Comparison between two generic types.
Returns 0 if the objects are equal, 1 if the first object (
self
) is greater, and -1 if the second object (other
) is greater.This method can be indirectly used through binary comparison operators (including
==
,<
etc.).- Parameters:
other – an object to compare to (same type as
self
)- Returns:
-1
/0
/1
(integer)
- degree()
Return the “relative scale degree” (0-6) to which the interval points (unison=0, 2nd=1, octave=0, 2nd down=6, etc.). For pitches, return the integer that corresponds to the letter (C=0, D=1, …).
- Returns:
degree (integer)
- internal_octaves()
Return the internal octave representation of a pitch
Only use this if you know what you are doing.
- Returns:
internal/dependent octave (integer)
- name()
The name of the pitch or interval in string notation
- Returns:
the object’s notation name (string)
- octaves()
For intervals, return the number of octaves the interval spans. Negative intervals start with -1, decreasing. For pitches, return the absolute octave of the pitch.
- Returns:
external/independent octave (integer)
- onehot()
Return a one-hot encoded tensor representing the object. Specialized versions of this method take ranges for their respective dimensions.
- Returns:
one-hot encoding of the object (numpy array)
- static pitch_class_from_diatonic_steps(diatonic_steps)
Return the pitch class given the number of steps
- Parameters:
diatonic_steps – number of diatonic steps
- Returns:
pitch class (C, D, E, F, G, A, B)
- static pitch_class_name_from_steps(step_pitch)
Return the pitch class name for the given pitch in steps, alias for pitch_class_from_diatonic_steps
- Parameters:
step_pitch – step pitch
- Returns:
pitch class
- abstract steps()
Return the position of the interval in diatonic steps.
- Returns:
fifth position (integer)