Music, mathematics and colour

Why twelve?

Twelve perfect fifths should bring you back to the note you started on. They miss by this much.

A piano repeats itself every twelve keys. That number is not an arbitrary custom. For music built on the perfect fifth, it is the best small answer to a problem in arithmetic that has no exact answer at all, and the circle of fifths is where you can see it.

Every sound on this page starts only when you tap. Headphones help in chapter 2.

1

Twice as fast is the same note

Pluck a string, then press it down at its middle and pluck again. The half-length string vibrates twice as fast, and you hear the same note, higher. Men and women singing “the same” tune are usually an octave apart, and in most musical traditions notes an octave apart share a name.

So pitch goes round in a circle. On the ring, clockwise is higher. One full turn doubles the frequency and lands on the same spot, an octave up. Drag the dot and listen.

The ring counts ratios, not hertz. From 262 to 523 vibrations a second is one turn; 523 to 1,047 is another turn of exactly the same size. Human hearing spans about ten turns, and a piano’s 88 keys about seven and a quarter.

Colour goes round as well. Red shades into orange, yellow, green, blue and violet, and painters close the loop with purple, which is not in the rainbow. But the eye’s range is short. From 750 to 380 nanometres, the frequency of light rises by a factor of 1.97: about one octave, against roughly ten for hearing.

So no colour is the natural partner of a note. Isaac Newton divided the spectrum into seven colours in 1704 partly to match the seven steps of a musical scale. This page makes its own choice in chapter 7, and says why.

2

Simple ratios sound smooth

Play two notes together and their vibrations either line up or drift. When one vibrates exactly three times for every two of the other, the combined pattern repeats about 130 times a second around middle C, and the two notes fuse into one smooth sound: a perfect fifth.

Send one note left and right and the other up and down, and the pattern draws itself. Pick a ratio below the ring.

The simpler the ratio, the simpler the figure and the smoother the sound: 2:1 is the octave, 3:2 the fifth, 4:3 the fourth, 5:4 the major third. Try 45:32, a tritone, and the figure becomes a thicket.

Now switch on piano tuning. A piano’s fifth is not exactly 3:2, so the figure turns slowly and the sound wavers about once a second around middle C. Its major third is further off and wavers about 10 times a second. Remember that number for chapter 4.

Pythagoras is said to have found these ratios in a smithy, from hammers whose weights stood as 12, 9, 8 and 6. The story is told by Nicomachus and by Boethius, and it is a legend: a hammer’s weight does not set its pitch that way. Strings do. Halve a string and you get the octave; take two thirds of it and you get the fifth.

3

Build a scale out of fifths

The fifth is the simplest interval after the octave, so use it to make notes. Start on F. Go up a fifth, multiplying the frequency by 3/2, and you reach C. Another fifth gives G, then D, A, E and B. Whenever a note climbs past the top of the ring, drop it an octave: its place on the ring does not change.

Each fifth moves round 0.585 of a turn. Press Add a fifth, or keep reading.

Five notes: F, C, G, D, A. Look at the gaps between them. There are only two sizes. This is the pentatonic scale, the five-note scale of a great many folk tunes, and the pattern of the black keys.

Seven notes, and again only two sizes of gap: five large ones and two small ones. Large is a whole tone, small is a semitone. These seven notes are the white keys of a piano, the scale you get by playing from C to C on white keys alone.

The piano’s groups of two and three black keys were not a design decision. They are what seven fifths look like when folded into one octave.

Five more fifths, F♯, C♯, G♯, D♯ and A♯, fall one into each large gap: they are the black keys. Twelve notes, and the gaps are almost even.

The next fifth should land back on F. It overshoots. Twelve fifths multiply the frequency by 129.75; seven octaves multiply it by 128. The difference is 23.46 cents (a cent is a hundredth of a piano semitone), and it is called the Pythagorean comma. It is drawn here at true size, 7.04° of the ring, and magnified in the loupe.

Carry on and the spiral never closes, because no whole number of fifths equals a whole number of octaves. The gaps keep falling into two sizes at particular moments: after 2, 3, 5, 7, 12, 17, 29, 41 and 53 notes. At every other count there are three sizes, never four. That is a theorem, the three-gap theorem, proved in the late 1950s.

Those moments are the candidates for a scale. Five and seven became the pentatonic and the white keys. Twelve became the piano.

4

Why not ten, or nineteen?

Twelve is not the only place to stop. It is the first good one. Divide the octave into some number of equal steps and ask how close the nearest step comes to a perfect fifth. The chart shows the miss, in cents, for every number of steps up to 60.

Ten equal steps miss the fifth by 18 cents and eleven by 47: anyone can hear that. Twelve miss by 1.96. No division into fewer than 29 steps does better. Nineteen steps, which some theorists have championed, give a sweeter major third but a fifth 7 cents flat.

Behind the chart is a single number. A fifth is 0.58496 of an octave, and its best approximations by fractions are 1/2, 3/5, 7/12, 24/41 and 31/53. Read 7/12 as “seven piano steps make a fifth, twelve make an octave”. 3/5 is the pentatonic. In the first century BC the Chinese theorist Jing Fang found that 53 fifths come within 3.6 cents of 31 octaves. In the 17th century Nicholas Mercator proposed dividing the octave into 53 equal steps; their fifth is out by only 0.07 cents.

Fifty-three keys an octave is too many for ten fingers. Twelve is the smallest number that brings the fifth within about a fiftieth of a semitone.

Twelve has one weakness. The fifth is nearly perfect, but the major third, 5:4, is not: twelve steps make it 13.69 cents too wide. That is the wavering you heard in chapter 2. Drag the number of steps and listen to its fifth and its third.

5

Hiding the gap

A keyboard has twelve keys an octave, and twelve pure fifths do not fit into seven octaves. The comma has to go somewhere. Every tuning is a decision about where. The whiskers show how far each note sits from today’s piano, magnified three times.

Pythagorean tuning keeps eleven fifths pure and puts the whole comma into the twelfth, a fifth of 678.5 cents that howls. It is called the wolf. Medieval music, built on fifths and fourths, could steer around it.

Quarter-comma meantone narrows every fifth a little so that most major thirds come out pure, at 5:4. It was the usual keyboard tuning in Europe for much of the 16th and 17th centuries. The leftover piles up between G♯ and E♭ in a wolf of 737.6 cents. Play A♭ major and hear it.

Well temperament spreads the comma unevenly so that every key can be played. In Andreas Werckmeister’s third tuning of 1691, four fifths are narrowed and the other eight left pure. No key howls, but no two keys are alike: C major’s third is 390.2 cents, F♯ major’s 407.8. Musicians of the time described keys as having characters, and this is one reason.

Equal temperament narrows every fifth by the same 1.96 cents, so all twelve keys are identical and no key is pure. It was worked out independently by Zhu Zaiyu in China in 1584 and by Simon Stevin in the Low Countries around 1605. It spread slowly, and became the usual way to tune keyboards between the late 18th and the mid-19th century, depending on the country.

6

Hear it in Bach

In 1722 Johann Sebastian Bach finished a book of preludes and fugues in all 24 major and minor keys and called it The Well-Tempered Clavier. “Well-tempered” does not mean equal. It means a keyboard tuned so that every key can be played. Which tuning Bach used himself is not known and is still argued about.

Play the first prelude, in C major, and switch tuning while it plays. Werckmeister’s well temperament stands in for the tunings of Bach’s time. Listen to the long chords in the middle; each sounding note lights its place on the ring.

In C major the well-tempered thirds are narrower than the piano’s, so the chords sound calmer and the slow waver is gentler. Equal temperament makes every key sound like this one: a little rough, and identical. Try meantone too: its pure thirds glow, until a chord needs an A♭, which meantone can only play as a mistuned G♯ (listen around bar 23).

7

The circle of fifths, in colour

Now fold the ring. Move every note to seven times its position, counting round past twelve as many times as needed. C stays put. G, seven steps up, lands next to C. D, fourteen steps up, lands next to G. The piano’s ring becomes the circle of fifths.

Because seven and twelve share no factor, each note gets a place of its own, and the order is the order in which the fifths were stacked in chapter 3.

On this ring, neighbours have the most in common. Keys a step apart share six of their seven notes; a major scale is seven neighbours in a row, and changing key slides the arc along by one. The two ends of the C major arc, F and B, sit straight across from each other: they are the scale’s tritone.

So give each note a colour in this order, with equal lightness and equal strength so that no note stands out. Neighbouring keys get neighbouring colours. The tritone, the most unstable interval in the scale, lands straight across the ring on the opposite colour. This is a choice, like Newton’s. It is not a new one: for the light keyboard in his Prometheus (1910), the composer Alexander Scriabin also ran his colours round the circle of fifths, roughly in rainbow order, from red C through orange G and yellow D to green A. The point of it is to make the relationships between notes visible at a glance.

8

Draw a chord

Tap notes on the ring to build a chord or a scale, or pick one below. A major or minor chord sits on one side of the wheel, in a narrow triangle of related colours. A diminished chord spreads across it. The major scale is one unbroken arc, and the black keys are the arc that is left over.

The shape you draw is in the page’s address, so you can send it.

Twelve, then

Twelve is a compromise: the smallest number of notes that gets the fifth almost right. The black keys, the circle of fifths, the tunings and the arguments about them all come from the 23.46 cents that do not fit.