By Oli Freke
The equivalent of a writer staring at a blank page, wondering how to fill it, is a composer staring at the 88 black and white notes on a piano wondering how to compose a melody that’s never been heard before. How can one possibly take the eight notes of a standard scale and write a brand new melody when so many great melodies have already been written? Perhaps they’ve all been taken!
I thought it would be interesting to examine the number of melodies available to a composer looking at his blank stave to see how many there potentially are. The first thing to do is to lay down some ground rules. The melodies will be a single stream of notes — no chords, counter-melodies or basslines — just a single line of music. Remember the ‘old grey whistle test’? If it can be played on a tin whistle, it’s a melody. For the first section, I’ve discounted rhythm so as to focus only on the permutations of notes.
All melodies should be contained within an octave: C to C’ inclusive. Any of the 13 chromatic notes of the octave can be used. I’ve not restricted this to just a major or minor scale as many great melodies use accidentals (the black notes in a C major scale). So we can include all of the notes within the octave, including the octave jump (from C to C’)—otherwise ‘Over the Rainbow’ would not count as a melody! The notes are: C, C#, D, D#, E, F, F#, G, G#, A, A#, B, C’.
We will tackle this problem by starting with the simplest possible melody—one consisting of two notes—and then building up the melody length, one note at a time, until we see a pattern that can be turned into a formula.
Two-note melodies
How many two-note melodies can be written within an octave? This one is easy and all combinations can be written out:
Melodies going up in pitch
First note
C
C
C
C
C
C
C
C
C
C
C
C
C
Second note
C
C#
D
D#
E
F
F#
G
G#
A
A#
B
C’
Pitch diff (semi-tones)
0
1
2
3
4
5
6
7
8
9
10
11
12
Melodies going down in pitch
First note
C’
C’
C’
C’
C’
C’
C’
C’
C’
C’
C’
C’
C’
Second note
C’
B
A#
A
G#
G
F#
F
E
D#
D
C#
C
Pitch diff (semi-tones)
0
1
2
3
4
5
6
7
8
9
10
11
12
Now, you might be wondering why combinations like G#–F and E–A are not included. This is because we are only interested in relative pitch, not absolute notes. For the purposes of this exercise, the melody C–C is identical to D–D or G–G as they are all unison melodies (i.e. their pitch difference is 0). That’s why we won’t count the unison melody C’–C’: because unison was already covered in the first table by C–C. Having excluded C’–C’ we have a total of 25 exciting two-note melodies!
Three-note melodies
The number of three-note melodies rises quite sharply. We can start by listing all possible combinations of three notes and then crossing out those that are duplicates. It turns out that it’s easy to find duplicates: they are exactly those sequences of notes that don’t have any C in them. Any melody without a C can always be moved down the scale until its lowest note becomes a C. Therefore, any melody without a C is a duplicate of a melody that does contain a C. To count all melodies, all we have to do is to count all sequences of notes than contain a C. There are exactly 2,197 three-note combinations, out of which 1,728 don’t contain a C. So there is a total of 2,197 – 1,728 = 469 three-note melodies.
Four to infinity
Now, writing down all possible combinations of notes and picking out the ones with a C is not a very efficient way of exploring further, so we need an equation that will describe the increase in melodies. Suppose we are counting melodies made out of n notes (so we’ve already covered n=2 and n=3). There are 13 choices for what the first note could be (one of C through to C’), 13 choices for the second note, and so on. This means that the number of all sequences of n notes is:
(13 x 13 x…x 13 )/n = 13n
From this we need to subtract the sequences that don’t have a C in them. For such a sequence there are 12 choices for the first note, 12 choices for the second note, and so on. So the number of all sequences of n notes that don’t contain a C is:
(12 x 12 x … x 12)/n = 12n
Which tells us that the number of n sequences of notes that do contain a C (the number of melodies) is:
13n-12n
We can even be more general and find the number of melodies for any scale. If the number of notes in the scale is s (so, in our case s=13) then the number of melodies that contain n notes is:
Sn-(s-1)n
But let’s return to our example with s=13. Substituting ever larger numbers for n—the length of the melody—gives us the following answer to our original question, the number of potential melodies within an octave:
Length of melody
2
3
4
5
6
7
8
9
10
No. of possible melodies
25
469
7,825
122,461
ca. 184 million
ca. 26.9 million
ca. 385 million
ca. 5.4 billion
ca. 75 billion
So, a mere ten-note melody will produce over 75 billion potential melodies of 13 notes within the octave! It’s going to take our composer a while to work their way through those. A computer would find it easier. In fact, earlier this year Damien Riehl, an American lawyer and musician, created a program to do just that, generating all possible original melodies and copywriting them, before releasing them into the public domain for common use! So I think the message is: there is no excuse for writers’ block.
If it’s been six months or more since your piano’s been tuned click here to find a PTA piano tuner near you or call us now on 07752 478082
Oli Freke is a London based musician and composer who’s variously supported the Human League, written for TV and has studied Brazilian drumming for over a decade. He is currently looking forward to working through all 8.25 x 1019 melodies on his Elysian upright! This article is reprinted with kind permission of Plus Magazine.