Skip to content
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ True
## TODOs

- ~~modes~~
- ~~ midi note numbers (see https://musicinformationretrieval.com/midi_conversion_table.html and https://www.inspiredacoustics.com/en/MIDI_note_numbers_and_center_frequencies)~~
- ~~midi note numbers (see https://musicinformationretrieval.com/midi_conversion_table.html and https://www.inspiredacoustics.com/en/MIDI_note_numbers_and_center_frequencies)~~
- ~~init note from midi number~~
- intervals
- addition and subtraction in scale
- finding qualities of interval in scale (notation - https://en.wikipedia.org/wiki/Interval_(music)#Shorthand_notation, quality - https://en.wikipedia.org/wiki/Interval_(music)#Main_intervals)
- add and subtract intervals within a context of a scale
- chords with scales, chord names and notes they consist of (don't forget octaves and root notes) - https://en.wikipedia.org/wiki/List_of_chords
- chords in given scales (similar to notes_in_scale method)
- check interval between two notes in scale
- consonance and dissonance of intervals
- chords with scales, chord names and notes they consist of (don't forget octaves and root notes) - https://en.wikipedia.org/wiki/List_of_chords - also https://en.wikipedia.org/wiki/Interval_(music)#Chord_qualities_and_interval_qualities
- consonance and dissonance of scales
- interval inversion
- chords in given scales (similar to notes_in_scale method)
- chord transposing by adding or subtracting tonedeltas
- init chord from given notes (check if matches any formula)
- find nearest note to a given frequency
Expand Down
20 changes: 19 additions & 1 deletion pyscales/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ def __eq__(self, other):

def __add__(self, other):

from pyscales import IntervalInScale
from pyscales import Interval
if isinstance(other, IntervalInScale):
return other.add_to_note(self)
elif isinstance(other, Interval):
return other.add_to_note(self)

# assume other is ToneDelta
# TODO: cache this somewhere
notes_order = NoteArray(NoteArray.DEFAULT_NOTE_ORDER)

Expand All @@ -118,6 +126,9 @@ def __sub__(self, other):

this_note_index = notes_order.index(self)

from pyscales import IntervalInScale

from pyscales import Interval
if hasattr(other, 'semitones'):

return notes_order[this_note_index-other.semitones]
Expand All @@ -128,7 +139,14 @@ def __sub__(self, other):

return ToneDelta(this_note_index-other_not_index)

raise ValueError("Can only subtract ToneDelta or other Note")
elif isinstance(other, IntervalInScale):

return other.subtract_from_note(self)

elif isinstance(other, Interval):
return other.subtract_from_note(self)

raise ValueError("Can only subtract ToneDelta, IntervalInScale or other Note")


def __str__(self):
Expand Down
Loading