NOTES = ['c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g', 'g#', 'a', 'a#', 'b']
# 2 is a whole step, 1 is a half step
MAJOR_STEPS = [2,2,1,2,2,2,1]
# returns the scale in the given key with the given steps
def scale(key, steps)
note = NOTES.index(key)
step = 0
notes = []
while step < steps.length
notes << NOTES[note % NOTES.length]
note += steps[step]
step += 1
end
notes
end
scale('d', MAJOR_STEPS) #=> ["d", "e", "f#", "g", "a", "b", "c#"]
I think this shows how a scale is just a list of steps applied to the notes from a certain key :)