intervals
None
interval_distance
Takes two notes and calculates the interval distance between them,
either up or down.
NOTE: A perfect 5th up is the same as a perfect 4th down and vice-versa
e.g. Note.C, Note.G, 'u' -> interval.P5
Note.C, Note.G, 'd' -> interval.P4
Args:
first_note:
The note to start measuring from.
second_note:
The note above or below the first.
direction:
Can either check distance up or down in pitch. acceptable values are
"u", "up", "above", "d", "down" or "below" in any case.
Returns:
A Interval representing the difference between two notes.
Raises:
ValueError:
If the direction string is not recognized.
intervals_to_string
Takes a list of intervals and returns a string of interval names.
e.g. [Interval.M3, Interval.P4, Interval.P5] -> "M3, P4, P5"
Args:
note_list:
The list of intervals to be converted to a string.
Returns:
The string of interval names.
Interval
Represents a interval (diffence between two notes). Derived from the
Enum class.
Attributes:
interval attributes:
12 class attributes representing interval enumerations.
Methods:
items(cls):
A class method to return the enums as a list.
all(cls):
An alias for items(), returning the enums as a list.
from_index(cls, index):
A class method to return a enum based upon an index.
from_numeric(cls, numeric):
A class method to construct an interval from a numeric.
to_numeric(self):
Converts an interval to a numeric.
random(cls):
A class method that returns a random interval.
__str__(self):
Returns the name of the interval.
__repr__(self):
Returns the Enum name.
Interval.items
A class method that returns a list of the interval enumerations.
e.g. [Interval.Unison, Interval.m2, ... ]
Args:
None.
Returns:
A list of intervals.
Interval.all
A class method that returns a list of the interval enumerations.
e.g. [Interval.Unison, Interval.m2, ... ]
Args:
None.
Returns:
A list of intervals.
Interval.from_index
A class methd that returns a interval based upon it's enumeration
value (positive or negative). Positive indices are counted from the
start and negative indices are counted from the end.
e.g. from_index(8) -> Interval.m6
from_index(-8) -> Interval.M3
Args:
index:
The index of the value to be retrieved. Can be positive or
negative.
Returns:
A Interval.
Interval.from_numeric
A class method that returns a interval based upon a numeric interval
value.
('1', 'b2', '2', 'b3', '3', '4', 'b5', '5', 'b6', '6', 'b7', '7')
e.g. from_numeric('b3') -> Interval.m3
Args:
numeric:
The numeric interval to be translated.
Returns:
A Interval.
Interval.to_numeric
Returns the numeric value of an interval.
e.g. Interval.P4.to_numeric() -> '4'
Args:
None.
Returns:
A string representing the numeric value.
Interval.random
A class method that returns a random interval.
e.g. Interval.P4
Args:
None.
Returns:
A interval.
Interval.__str__
Returns a string representing the interval name.
e.g. str(Interval.P5) -> 'P5'
Args:
None.
Returns:
A string representing a interval's name.
Interval.__repr__
Returns a string representing the interval.
e.g. repr(Interval.P5) -> 'Interval.P5'
Args:
None.
Returns:
A string representing a interval.