# Maths & Music #2: Mathematics of keyboard tuning, by Dominique Manchon

**1. ****Keyboard instruments**

The keyboard of a modern piano consists of 88 keys, divided into 52 consecutive white keys and 36 black keys interspersed between the white keys, in a periodic pattern. Moving across the keyboard from left to right, we first encounter the initial pattern BNBBNBNB, then the central pattern1

BNBNBNBBNBNB

repeated six times, and finally the final pattern BNBNBNBB.

- 1Un bon moyen de se rappeler ce motif de douze lettres est de faire défiler les mois de l’année de janvier à décembre. Les touches blanches correspondent exactement aux mois de 31 jours, les touches noires aux mois courts.

The keyboards of organs, harpsichords, spinets, pianos and today's electronic keyboards vary in length, but all adopt this structure, which has remained essentially unchanged since the 15th century2 . Each key corresponds to the emission of a sound with a well-defined pitch, a musical note. The central motif describes the chromatic scale

F **F#** G **G#** A **A#** B C **C#** D **D#** E

from low to high. The black keys are shown in bold. The next white key is again an F, forming an octave interval with the first F, and the pattern is repeated in every octave.

Why are there twelve notes in an octave, arranged in this way, and how are keyboard instruments tuned? A good starting point for answering these vast questions is the nature of sound. On a stringed instrument, a musical note corresponds to the vibration of a string at a specific frequency: for example, the third F from the left vibrates around 176 times per second (176 Hertz). The next F vibrates at twice the frequency, 352 times a second.

**2. T****he fifths cycle**

Over 2,500 years ago, Pythagoras observed that when the ratio between two frequencies is expressed as the quotient of two sufficiently small positive integers, the interval formed by these two frequencies is consonant. Restricting ourselves to numbers between *1* and *2*, the simplest ratio after *1 *(the unison) and* 2* (the octave) is *3/2*, the corresponding interval being called the right fifth. Then there's the fourth, represented by *4/3*, the major sixth (*5/3*), the major third (*5/4*), the minor third (*6/5*), the minor sixth (*8/5*), the minor seventh (*9/5*), etc.

If we double the interval of a fifth, we must* multiply* *3/2* with itself, which gives *9/4=2,25*. In other words, two superimposed fifths form an interval slightly larger than the octave. What happens if we continue to stack successive fifths? Multiplying *3/2* twelve times by itself gives *(3/2) ^{12 }= 129,746*… That's pretty close to

*2*. In other words, there are roughly twelve fifths in seven octaves. By dividing twelve notes into an octave, the fifth corresponds to an interval comprising seven notes.

^{7}= 128Let's start from the first Fa at the very left of the keyboard (the first white key of the leftmost central motif), and work our way up, hitting every seventh note. We obtain the following sequence

F C G D A E B F# C# G# D# A# (F)

The last Fa in brackets vibrates at around 5632 Hz, 128 times faster than the starting F (44 Hz), and exceeds the limits of a piano keyboard, and is shown here to close the cycle:

- 2A ma connaissance, la plus ancienne représentation d’un clavier semblable au clavier moderne se trouve dans un traité d’Arnaut de Zwolle, daté approximativement de 1440.

Since the numbers *7* and *12 *are prime, all twelve notes are represented in this sequence. Note that the first seven notes correspond to the white keys, with the black keys coming later.

We can therefore fix the frequencies of all the notes by starting from a reference F, and successively tuning all the octaves and fifths. In practice, for example, we start with an F in the middle of the keyboard, tune C to the fifth above3 . Repeat the operation with the G above the C, and then tune the octave between this G and the one just below it, then tune the fifth G-D, and so on. Continuing this process, we tune the twelve notes from the starting F to the E just above, ending with the A#. The entire keyboard is then tuned by adjusting the octaves.

**3. ****The wolf fifth and enharmonic comma**

But it's not that simple! This so-called* Pythagorean* chord reveals its weaknesses when we test the last fifth A# F4
((remember that F is given from the start), which turns out to be really wrong! This is hardly surprising: as we've seen, 12 fifths don't quite fit into 7 octaves, so the last fifth is significantly out of tune. The error is measured by the ratio

*K=(3/2) ^{12}/2^{7} = 3^{12}/2^{19} = 1.01364*…

This interval is called the enharmonic comma. Although very small, it is perfectly audible.

**4. H****ow to tune a keyboard: temperament**

Theorists and tuners soon came up with the idea of spreading this defect over several fifths instead of concentrating it on a single one. As early as the end of the 16th century, Simon Stevin, a few decades ahead of the Chinese, proposed to shorten each fifth by one-twelfth of the enharmonic comma *K*. Twelve of these slightly shortened fifths make exactly seven octaves. Two consecutive keys are always separated by a tempered semitone worth exactly one-twelfth of an octave, i.e. a ratio of *2 ^{1/12}=1,05946*…

*Equal*

*temperament*was born! It has dominated all Western musical life for a good century, but it has only imposed itself at the price of a long and strong resistance. Hundreds of unequal temperaments have coexisted with it over the centuries, some of which are still used in early music.

**5. ****The major third and the syntonic comma**

By adding a fourth (represented by the frequency ratio *4/3*) to a fifth, we obtain an octave. This is the musical translation of the simple equality *(3/2)x(4/3)=2*. After the fifth and fourth, the next consonant interval is the major third, corresponding to the ratio *5/4*. Furthermore, four successive fifths produce an interval represented by the ratio *81/16*. Subtracting two octaves, we arrive at *81/64*, close enough to *5/4=80/64*. This interval, called diton or Pythagorean major third, sounds quite harsh to the ear. The error is measured by the syntonic comma represented by the ratio *k=81/80=1.0125*. It is therefore close to the enharmonic comma *K=1.01364*... but a little smaller. The difference between the two intervals, represented by the ratio *𝜎=K/k*, is the *schisma*, which can be identified as *K ^{1/12}* with an excellent approximation: the difference between the twelfth of enharmonic comma (which we'll note

*r*for convenience) and the schisma is a tiny, perfectly undetectable interval5 .

**6. ****Conclusion: imagine your temperament**

- 3à l’oreille, une quinte un peu fausse fait entendre de lentes oscillations, les
*battements*. L’accordeur ajuste la tension de manière à ce que les battements disparaissent, obtenant ainsi une quinte juste. - 4C’est plus précisément une sixte diminuée, mais ne pinaillons pas…
- 5Représenté par le rapport de fréquences k/(K^{11/12})=1,0000007394… C’est le douzième d’un atome de Kirnberger, appelé d’après son découvreur Johann Philipp Kirnberger (1721-1783). Il se représente par le rapport k^{12}/K^{11}= 2^{161}3^{-84}5^{-12}= 1,00000887286…

Le lecteur attentif aura remarqué que nous sommes souvent passés de la multiplication à l’addition et vice-versa. L’addition de deux intervalles se traduit en effet par la multiplication de leurs rapports de fréquences respectifs. On passe facilement d’un point de vue à l’autre par l’utilisation du logarithme en base 2.

To sum up, an enharmonic comma (i.e. 12*r*) must be subtracted from the cycle of fifths to complete it, this comma being distributed among the twelve fifths of the cycle. A syntonic comma (almost exactly 11*r*) must be subtracted from a Pythagorean third to obtain a pure major third.

In equal temperament, the major thirds are all equal, shortened by 4*r *compared to the Pythagorean major third, but still exceeding the pure major third by 7*r*. In any temperament, this 7*r* excess over the pure major third is always verified on average. The difference with equal temperament lies in a different choice of error distribution. Suppose, for example, that we wish to obtain a pure major third Fa-La. This can be achieved by shortening the four fifths F-C, C-G, G-D and D-A by *11r/4=2.75r*. You can also choose to shorten all the fifths (except the last one) by this* 2.75r* value: this is the mesotonic temperament with *pure major thirds*, particularly suited to Renaissance music. The price to pay for all these beautiful major thirds is a huge wolf fifth (exceeding the pure fifth by *18.25r*), making it impossible to play in certain keys.

The exercise becomes even more complicated when we take into account the minor third, represented by the frequency ratio *6/5*. Taking into account more exotic consonant intervals such as the natural seventh (*7/4*) or the natural eleventh (*11/4*) is impossible without enormous distortion of the other intervals. The accuracy of a keyboard instrument will always be a matter of compromise.

**Further information**

Bradley Lehman's website provides a comprehensive description of a very fine temperament, which may well be that advocated by J. S. Bach for his *Well-Tempered Clavier**6
* . For a general presentation of many early temperaments, Pierre-Yves Asselin's book (*Musique et tempérament*, Editions Jobert, Paris, 2000) is a very good introduction. I also recommend the excellent website of Gunnar Tungland, inventor of a beautiful graphic representation of temperaments. On the small and very small intervals mentioned in this article, see John Baez's recent post on *The n-category café*.

- 6Ce point a fait l’objet de nombreuses et vives controverses. Difficile d’affirmer que B. Lehman a effectivement découvert
*le*tempérament utilisé par Bach, mais l’auteur de cet article l’a adopté avec bonheur sur tous ses instruments à clavier !

## Contact

### Find out more:

- Dominique Manchon's personal page
- Editorial & list of Maths & Music articles