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 pattern
BNBNBNBBNBNB
repeated six times, and finally the final pattern BNBNBNBB.
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 century
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. The 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 27 = 128. 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.
Let'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:
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 above
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# F
K=(3/2)12/27 = 312/219 = 1.01364…
This interval is called the enharmonic comma. Although very small, it is perfectly audible.
4. How 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 21/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 K1/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 interval
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.
6. Conclusion: imagine your temperament
To sum up, an enharmonic comma (i.e. 12r) 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 11r) must be subtracted from a Pythagorean third to obtain a pure major third.
In equal temperament, the major thirds are all equal, shortened by 4r compared to the Pythagorean major third, but still exceeding the pure major third by 7r. In any temperament, this 7r 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
Contact
Find out more:
- Dominique Manchon's personal page
- Editorial & list of Maths & Music articles