Skip to content

Commit

Permalink
Implement awful Scale class and its awful methods
Browse files Browse the repository at this point in the history
fuck this exercise in particular and music theory in general
  • Loading branch information
rneilsen committed Nov 3, 2021
1 parent 460a6e3 commit 988d32f
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions scale-generator/scale_generator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
PITCHES_SH = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']
PITCHES_FL = ['A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab']

FLAT_SCALES = {'F', 'Bb', 'Eb', 'Ab', 'Db', 'Gb', 'd', 'g', 'c', 'f', 'bb', 'eb'}

INTERVALS = {'m': 1, 'M': 2, 'A': 3}


class Scale:
def __init__(self, tonic):
pass
if tonic in FLAT_SCALES:
start = PITCHES_FL.index(tonic[0].upper() + tonic[1:])
self.scale = PITCHES_FL[start:] + PITCHES_FL[:start]
else:
start = PITCHES_SH.index(tonic[0].upper() + tonic[1:])
self.scale = PITCHES_SH[start:] + PITCHES_SH[:start]

def chromatic(self):
pass
return self.scale

def interval(self, intervals):
pass
i = 0
scale = []
for step in intervals:
# note: last step in intervals is *supposed* to be skipped,
# obviously for no apparent reason (classic music theory, amirite)
scale.append(self.scale[i % len(self.scale)])
i += INTERVALS[step]

return scale

0 comments on commit 988d32f

Please sign in to comment.