scales
None
_intervals_from_numerics
Returns a list of intervals comprising a scale formula derived from a step
formula. Essentially converts a step formula into a interval formula.
e.g. _intervals_from_numerics(['1', '2', 'b3', '4', '5', 'b6', '7'])
[Unison, M2, m3, P4, P5, m6, M7]
Args:
formula:
The numeric formula to construct the Interval sequence.
Returns:
A list of Intervals.
_intervals_from_steps
Returns a list of intervals comprising a scale formula derived from a step
formula. Essentially converts a step formula into a interval formula.
e.g. _intervals_from_steps(['w', 'w', 'h', 'w', 'w', 'w', 'h'])
[Unison, M2, M3, P4, P5, M6, M7]
Args:
formula:
The step formula to construct the Interval sequence. Made of h's and w's.
(half and whole steps).
Returns:
A list of Intervals.
_notes_from_intervals
Returns a list of notes comprising a scale from a root note and a interval
formula.
e.g. _notes_from_intervals(Note.C [Unison, M2, M3, P4, P5, M6, M7])
[C, D, E, F, G, A, B]
Args:
formula:
The interval formula to construct the Note sequence.
Returns:
A list of Notes.
_notes_from_steps
Returns a list of notes comprising a scale from a root note and a step
formula.
e.g. _notes_from_steps(Note.Bb, ['w', 'w', 'h', 'w', 'w', 'h', 'w'])
[Note.Bb, Note.C, Note.D, Note.Eb, Note.F, Note.G, Note.Ab]
Args:
root:
The root Note to build the scale from.
formula:
The step formula to construct the note sequence. Made of h's and w's.
(half and whole steps).
Returns:
A list of Notes.
modes_from_note
Returns a list of Scales depicting all the modes from a starting note.
Each subsequent mode starts from the next note in the scale (effectively
shifts the notes up). This repeats until it wraps back to the start.
There are always 7 modes and they are always in the same order. Theyare
named (note -> mode).
e.g. Mode 1 - C Ionian - C D E F G A B
Mode 2 - D Dorian - D E F G A B C
Mode 3 - E Phrygian: E, F, G, A, B, C, D
Mode 4 - F Lydian: F, G, A, B, C, D, E
Mode 5 - G Mixolydian: G, A, B, C, D, E, F
Mode 6 - A Aeolian: A, B, C, D, E, F, G
Mode 7 - B Locrian: B, C, D, E, F, G, A
Args:
note:
The note to build the modes from.
Returns:
A list of 7 Scales.
Scale
A class representing a Scale (A collection of musical notes).
Note: There isn't a step_fomula attribute, because not every scale can
represent them. The pentatonic scale for example, will cover steps
greater than a whole (2 semi-tones).
Attributes:
root:
The root Note of the scale.
type:
The type of scale (e.g. minor, major, blues, lydian, etc...).
notes:
A list of notes for the scale
creation_formula:
The formula used to create the scale.
interval_formula:
A list of intervals describing the scale.
numeric_formula:
A list of numerics describing the scale.
name:
A property that returns the name of the scale.
num_notes:
A property that returns the number of notes in the scale.
num_flats:
A property that returns the number of flats in the scale.
Methods:
__init__(self, root, scale_type):
Initialises the root and scale type, then calls _construct().
_construct(self):
Constructs the scale from the root and scale type in __init__().
Put into it's own private method so that __init__() remains readable.
__eq__(self, other):
Compares two scales.
random(cls):
A class method to return a random scale (root and type).
__str__(self):
returns a string representation of the scale, type and notes.
__repr__(self):
Returns a string representation of the scale and type.
Scale.__init__
Builds the scale from a root note and a scale type.
Args:
root:
The note to build the scale from.
scale_type:
The type of scale (e.g. minor, major, blues, lydian, etc...
Returns:
None.
Scale._construct
Method is private so not to pollute the __init__() method.
Build the scale from 3 different ways. Some scales are defined by intervals,
some are defined by steps and some are defined by numerics. They can also
have a different number of notes in them.
Args:
None.
Returns:
None.
Raises:
ValueError:
Raised if the Scale's type is not in any dictionaries.
Scale.__eq__
Equality operator to check that both the note and scale type match.
e.g. Key(Note.F, ScaleType.Major) == Key(Note.F, ScaleType.Major)
Args:
other:
The other Scale to compare.
Returns:
A bool. True if this and another scale are the same.
Scale.random
A class method to return a random Scale from a random note and type.
Args:
None.
Returns:
A Scale.
Scale.__str__
Returns a string representing the Scale name, type and notes.
e.g. str(Scale(Note.E, ScaleType.Dorian)) -> E Dorian: E, Gb, G, A, B, Db, D
Args:
None.
Returns:
A string.
Scale.__repr__
Returns a string representing the Scale name and type.
e.g. repr(Scale(Note.E, ScaleType.Dorian)) -> Scale(Note.E, ScaleType.Dorian)
Args:
None.
Returns:
A string.