The code he wrote for showing how to generate is pretty ugly and left me confused. I think this shows much better the relation between the 12 notes and a scale:
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 :)
Only at the first third and already delighted. He's moving between music, physics, programming in such a simple and pragmatic way, thanks for the bottom-up dynamic evaluation demonstration. Many many thanks.
I agree. That is 1 million times better. Sometimes I wonder why I don't think of these things. I'll probably fix the code and use something like that... except in Python, obv.
Hey, yeah Ruby is a bit easier for me :) Your code is correct so it's not terrible. As to why you didn't think of it.. maybe it's because you practice less at making code look as pretty as possible?
It is something I practice a lot, maybe because it's in Ruby's culture, or just because I enjoy making code look pretty.
When I look at your two for loops that twice make a range, and have a bunch of magic numbers, all kinds of alarm bells go off. It should be one loop if possible, if there are magic numbers they should be in a constant at the top of the file.
Actually, the way you construct the seedList is interesting. A Haskell programmer might have done the same thing, because keeping indexes is ugly in Haskell, and doing operations on infinite lists (which you emulate by appending a copy) are pretty. Perhaps you are just a functional programmer, using a non-functional language :D
Yeah, I am more of a functional programmer and yeah, I sometimes let some ugliness slip in especially in looping in Python. At least there is none of this crap in production somewhere. :) n00b.
It would look better if it was in Scheme or Clojure, but that stuff's too scary for most readers. At least that's the story I'll maintain here.
I would love to see a Scheme or Clojure version of the code. I posted an attempt at it in Haskell, the only functional programming language I know, but it isn't particularily beautiful.
Thanks a ton for the great explanation, I dropped you a line about some typos and other off-topic stuff.
Of all the bits and pieces I've looked at over the years explaining the circle of fifths this is the one that stands out for me as the easiest to remember. Being able to re-derive from basic principles is so much better than memorization.
The following solution defines a function to transpose each scale taking advantage of the mathematical properties of notes:
def notes_name(numbers):
notes = "C C# D D# E F F# G G# A A# B".split()
return [notes[(number % 12)] for number in numbers]
def transposition(notes, start):
index = start - notes[0]
return [(n + index) % 12 for n in notes]
def gen_scales():
c_scale = [0, 2, 4, 5, 7, 9, 11]
return [notes_name(transposition(c_scale, note)) for note in range(0, 12)]
for scale in gen_scales():
print " ".join(scale)
Alright, time to fire up ghci then.. it doesn't work with map or filter, but you get the idea:
notes = concat $ repeat ["c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "b"]
majorSteps = [1,1,0,1,1,1,0]
scale key steps =
key : skip notesFromKey majorSteps
where
(_:notesFromKey) = dropWhile ((/=) key) notes
skip list skips =
fst $ foldl next ([], list) skips
where
next (m, xs) s = (m ++ [xs !! s], drop (s + 1) xs)
edit: cleaned it up a lot. This is Haskell by the way. The loop is replaced by a 'fold' in the skip function that reduces the list by skipping through it taking the skip distances from the skips argument.
We generally treat Gb and F# as the same note, but if you actually count perfect Pythagorean fifths (frequency ratios of 3:2) in both directions from C, Gb and F# don't actually perfectly meet in the middle!
That's the cause of that famous piece being called the Wohl Temperierte Klavier, those little rounding errors add up, once you have settled on a system that works for everybody by convention Gb and F# have to be the same notes (since there is only the one key for them...).
The circle is a Procrustean bed - the real way to derive the scale is to use a line of fifths that never returns to the starting pitch. Circle any group of seven consecutive fifths, and the group's major scale tonic is the one second from the left. This line goes into double and triple sharps/flats, etc.
"Perfect" pitch isn't necessary, as slight deviations produce interesting sounds related to the "flanger" effect. It's the reason why pianos have more than one string per key: it is the intention that they are slightly detuned, or else you wouldn't hear that there's more than one string.
The deviation should preferably be less than, say, 1Hz, because you hear the difference in frequency as the beat frequency.
Er... something's terribly wrong in this explanation. because the essential forgotten fact is that, as much as F# is also Gb, C is also B#, F is E#, B is Cb and E is Fb. So the G# scale exists and is perfectly valid, it reads
G# A# B# C# D# E# F##
And it is a very important point, because each scale on the circle of fifth has one more sharp than the previous one when turning in one direction, and one more flat in the other one.
Another point is that there is actually a comma between F# and Gb, and between F## and G, because the chromatic semi-tone is one comma shorter than the diatonic semi-tone -- Though of course the distinction isn't done on a tempered instrument such as a piano or a guitar.
It is all actually quite simple, but not /that/ simple :)
I vaguely remember using this knowledge of the scales to "cheat" on the violin. If you move your hand into whatever position puts your first finger on the first note in the scale then you can always move the rest of the fingers in exactly the same manner - whole whole half, whole whole whole half. My music theory knowledge is crumbling but what I mean is if you move into 2nd position on the A string to play a B scale its much easier than starting in 1st position with the 2nd finger.
I did this at a competition once when given some insane scales (like 3 flats in the clef) without having ever practiced the scale itself and got it right.
Circle of fifths and circle of fourths allows one to algorithmically put together Irish traditional tune sets that mostly work. (Not exactly as stated, because Irish trad is really modal, but close enough for trad.)
Basically, take the home chord of a tune and apply one of the following:
If "major" then switch to the relative minor, or vice versa.
Go Round the circle of fifths or the circLe of fourths either direction, but stay on whichever side of "major/minor."
Go up or down the scale, staying on whichever side of "major/minor."
So for example, a tune set with E minor, G major, A major should work. (Again, not exactly it, but don't want to explain modes.)
You might think that, you'd be wrong. I know what a relative minor is, I play guitar daily. I can play up and down the circle of fifths/fourths and improvise endlessly over the harmonized major/minor scale playing right through the changes. None of that knowledge helps decipher the purpose or meaning of the instructions you gave.
I'll try and walk through it.
> If "major" then switch to the relative minor, or vice versa.
OK, home chord is Em, so we'll use G major.
> Go Round the circle of fifths or the circLe of fourths either direction, but stay on whichever side of "major/minor."
OK, that's C or D given G as the starting point.
> Go up or down the scale, staying on whichever side of "major/minor."
So playing the G, C, or D scale over an E minor progression. G makes sense, same scale as Em; C or D... don't even parse for me. I don't think of chords and scales as separate, changing the scale changes the underlying chords I'd play under them, thus changing the key to something other than Em.
> So for example, a tune set with E minor, G major, A major should work.
What? Nothing you just said would lead me to think A major would work over an Em progression. G major, sure, obvious, it's the relative major of Em and just another name for G major scale, but A... why A, you haven't explained that above, your example doesn't match what the instructions seem to say.
Then what you don't understand is how a trad tune set works. What I'm talking about is how to put together a set of three tunes that work well as one track on an album or one "number" in a performance. Each tune internally has its own progression, which may be different. I'm only talking about the home chord of each tune. (Which I state.)
True, but I wasn't. You really weren't as clear as you seem to think you were. If all you're saying is pick as roots nearby notes on the circle of fifths, you could have been much clearer.
Looks really good (bookmarked to read later). Although maybe some more motivation as to why you start music theory with circle of fifths -- as someone who knows nothing about music, I had never heard of it before.
That's a really good question. The reason why I started at the Circle of Fifths is because it's the foundation and it is highly mathematical. It's a tad bit painful to start with, but I wanted to start from the ground up. This will make the other stuff far more understandable. I can go on all day saying "this is how to make a chord" but starting here will let you understand the later ideas better.
I also started here to demonstrate how logical it all is.
You don't seem to provide any context about what the circle of fifths is, or even what a fifth is for, thus I have no idea why I should care, and in general it makes it very hard to assimilate the article in a useful way.
Yeah I agree. I think there should be some mention of why a "fifth" is important (3:2 ratio of frequencies, which is recognizable, and when this is continued, it eventually "loops back" to the original note (at a 2^n:1 ratio, where n is the number of fifths up until it repeats)
Thanks for all the feedback guys. The links found here are all amazing as well. I know what to improve in this article and the next article will be much better.