First warning: This article contains math.
Second warning: I’m not very good at math.
I don’t know why, but tonight I found myself pondering the question “How many melodies are there?” Maybe I was worried that we’re running out of them. (A quick survey of recent pop music might suggest this.)
Human beings have been writing songs for as long as there have been human beings. The oldest written song is the Hurrian Song to Nikkal, written around 1400 BC, but even in prehistoric times there were no doubt songwriters, whose melodies are now lost to us.
There are now more than 7 billion people in the world, so there must be more songwriters living now than at any other time in history. Heck, there are probably more songwriters now than there were people at some point in the past.
And all those songwriters are using up melodies. Not always of course, since imitation and blatant thievery are well-established parts of the creative process. But unless we’re all just endlessly recycling the same melodies, some of us must be inventing new ones and therefore depleting the supply of melodies not heard before.
How long until there are no new melodies?
OK, here’s where the math comes in. For the sake of this discussion, let’s limit ourselves to the Western chromatic scale, i.e. all the keys on a piano. But two melodies that are different only by shifting some of the notes to a different octave aren’t going to be heard as different melodies. For example, consider these two melodies:
If you tried to claim that the second melody is original, I’m afraid people would laugh at you, and if you took it too far, Mozart might sue you.
So we’re really only dealing with 12 notes, because every other note is just one of those notes shifted to a different octave.
How many melodies can we make with 12 notes? It depends on how long the melody is. If our melody is only one note long, then obviously there are only 12 possible melodies. If our melody is two notes long, then there are 12×12, or 144, possible melodies. Here are the first 36 of them; you can probably figure out the rest:
Now, what about a melody that’s 3 notes long? There are 12x12x12, or 1728 possibilites. Similarly, there are 12x12x12x12 (20736) 4-note melodies, 12x12x12x12x12 (248832) 5-note melodies, and so on. The formula to calculate the number of possible melodies using N notes is 12^N, meaning 12 multiplied by itself N times. So if we want to know how many possible 20-note melodies there are, we just multiple 12 by itself 20 times. The result of that calculation is 3,833,759,992,447,500,000,000.
Now we’re getting into some big numbers, and I’m starting to feel a little better about the remaining supply of melodies. In fact, the number of possible 22-note melodies is roughly the same as the number of stars in the universe. Now I’m feeling safe.
But so far we haven’t tried to draw any distinctions between good and bad melodies. Those 144 two-note melodies, for example, are probably not very interesting. And a random collection of 22 notes generated by a computer program might be a melody but is not likely to be a good melody.
So even though on a theoretical level we’ll never run out of melodies, the more important question is “will we ever run out of good melodies?” I don’t know. But here’s a melody, which I think is a pretty good one:
It has 22 notes, so it’s like one out of all the stars in the universe. And if you hum it, there’s a good chance that you and I and other readers of this article are the only human beings who have ever lived who have ever heard this melody.
That’s pretty cool.