# Is there physics behind the layout of a piano keyboard?

We have 12 different 'notes' per octave on a musical keyboard. They are set up so that every 'note' (A, B,C etc) is a second harmonic of the same 'note' in the next higher octave. With this ratio in place, it seems that everything on a keyboard should be divided up into equal groups of 2,3,4 or 6. However, the keyboard seems to be divided up into groups of 5 and 7 (one group of 2 black & 3 white keys, and another group of 3 black & 4 white keys). This does not make much sense to me. However, when I play scales, the layout is very helpful. I'm guessing that the design of the scale is related to physics and therefor the layout of the keys must be too. What is the connection between physics, scales and the layout of the piano keyboard?

• I don't understand the motivation for the down votes. May 27, 2014 at 2:15
• This question appears to be off-topic because it is about grouping of musical notes on a piano and not physics. May 27, 2014 at 2:18
• @KyleKanos, it's an honest and reasonable question: What is the (or is there a) connection between physics, scales and the layout of the piano keyboard?. Frankly, I still don't understand the motivation for the down votes. May 27, 2014 at 2:21
• @Nathaniel: The piano was designed for convenience of playing, not "because of physics." And claiming you're right because someone you don't know a thing about is "ignorant about the subject" is rather rude. Please refrain from making such completely unfounded accusations in the future. May 27, 2014 at 3:09
• There is very interesting music theory behind the piano layout, coming from the tension between logarithmic equality in note spacings (12 notes/octave) vs. Western preference for only using close tones sparingly at choice moments in music (7 keys are selected as special - the white ones). There is also a distinct UX component to the question. All this said, there really isn't a physics answer to be given. Look instead to perception and ergonomics.
– user10851
May 27, 2014 at 4:22

12 notes per octave comes from the history of Western music. Other cultures are different. For example, Arabic music has 5 notes per octave. India has 22.

The physiology/physics is that pleasing chords are produced by frequencies that can be expressed as the ratios of small numbers. If two frequencies have a ratio of 2:1, they are an octave apart. 3:2 is a fifth. A slightly different ratio produces beats.

This makes it difficult to tune a piano satisfactorily. Equally spaced frequencies do not produce perfect chords. But the piano can be played in any key equally well. Or perhaps equally not so well.

Tuning was a controversial question among musician in the time of J. S. Bach. Bach took an active interest in it. He developed his own tuning. He wrote the Well Tempered (i.e. well tuned) Clavier, a set of 24 short pieces in all 24 keys, to show the advantages of his preferred tuning.

Today, frequencies are in theory equally spaced on a logarithmic scale. In practice, a piano tuner may "stretch" some notes.

Some references:

The Ongoing Quest for Bach's Temperament

There is plenty of physics behind the modern piano, particularly in the different tunings and where a hammer should strike the string.

The tuning problem has to do with what sounds good to the ear. Octaves sound good and so do "5ths", ratios of frequency of 3:2. On a keyboard an example is from C to G - the 5 white and 3 black you noticed. The problem arises when you try to make octaves and 5ths work together. If you use 12 "perfect 5ths" of ratio 3:2, it will almost equal 7 octaves. You have to "temper" the tuning by cheating a little to spread out the bad news. There have been many temperings tried over the ages, probably starting with harps. See http://en.wikipedia.org/wiki/Circle_of_fifths and the work of the monk Mersene on vibrating strings and proof that the octave is a doubling of frequency. Modern 20th century tempering changes each tone a little bit. Occasionally pianos are tempered with old tunings to play period music.

I suspect a great choral group can sound very pure because the singers can perform nearly perfect tempering.

As for your question about the 12 keys, these are called semitones and are based on pleasing ratios found in Western music, fifths, thirds, sevenths, and octaves. (In medieval liturgical chants and music, some of the ratios are missing.) If you move up a keyboard by 5ths for 7 octaves (seven keys from where you start for each fifth), you will find you have landed on the 12 semitones into which every octave is divided and that is the source of the division of the octave into 12 parts.

Which keys are white and which black has reversed over time.

Piano keyboard layout was "designed" since ancient times. The layout reminds people of law of octaves (law of seven). Nowdays almost nobody knows the hidden meaning of this law.

• Just as a note of the terminology used by historians, the design of the pianofote keyboard dates to the "early modern". May 27, 2014 at 14:01