Saturday, April 20, 2013

The Math of Music (part 2)

In part 1, we derived the ratios of frequencies in a major scale. This gives us all the white notes on a piano but, as it turns out, they are tuned slightly differently than a piano is tuned.  The scale we derived is a "pure" scale where the tuning of all the notes is perfect and the notes make perfect harmonies.  Pianos aren't tuned to pure scales.  Each note is slightly out of tune. To discover why, we have to answer another question - why does a piano have black notes?

There are 7 notes in the C major scale (C, D, E, F, G, A, B) then the scale repeats starting back at C.  The ratios of those notes (as explained in the previous post) are shown in the table below. I've provided the fractions as well as the decimal values. Remember that we'll always divide or multiply by 2 until the answer lies in the range 1 .. 2.
NoteFractionDecimal
C11
D9 / 81.125
E5 / 41.25
F4 / 31.3333
G3 / 21.5
A5 / 31.6666
B15 / 81.875

This works well for playing tunes in the key of C but sometimes you want to make the pitch higher or lower. Let's choose a higher pitch.  The simplest fraction in the scale is for G (1.5 = 3/2). To create a scale in the key of G, we need to multiply all the frequencies by 1.5 like this:
NoteCalculationPitch
G1 * 1.51.5
A1.125 * 1.51.6875
B1.25 * 1.51.875
C1.3333 * 1.5 / 21
D1.5 * 1.5 / 21.125
E1.6666 * 1.5 / 21.25
F#1.875 * 1.5 / 21.40625

Note that there are two pitches that don't match the C scale.  Our value for A is 1.6875 in the G scale but it's 1.6666 in the C scale.  It's close but still off.  The value for F, however, is really off.  In the C scale we have 1.3333 but in the G scale we're up to 1.40625. This is such a dramatic difference that you can definitely hear it and, in fact is close to halfway between the F and G in the C scale.  We'll call this note F# since it's  higher than an F but we'd like to use the letter F to have all the letters in our scale.

Now we do the same thing again.  We pick the note halfway between G (1.5) and the next G (3.0) which is D (2.25) then divide by two to get it into the 1..2 range to give D (1.125).  We multiply all the frequencies in the G scale by 1.5 (or 3/2) to create the D scale:

NoteCalculationPitch
D1.5 * 1.5 / 21.125
E1.6875 * 1.5 / 21.2656
F#1.875 * 1.5 / 21.40625
G1 * 1.51.5
A1.125 * 1.51.6875
B1.25 * 1.5 / 21.875
C#1.40625 * 1.5 / 21.0547

Once again, our note for E is a little off from the C scale but the note for C is way off - it's about halfway between a C and a D.  We'll call it C#.

The note halfway between D and high D is A so the next key to generate is A.  I'll save you the calculations and just give the results for the remaining keys.


Notice that by the time we reach the scale of F#, we've introduced a new note called E# (1.3348) but this is so close to F (1.3333) that the notes would be virtually indistinguishable.  If we did keep going more, we'd introduce new notes that are repeats of previous notes, so we'll stop at the scale of F#.

What notes do we have?  Lets collect them up in order:
  C
  C#
  D
  D#
  E
  F
  F#
  G
  G#
  A
  A#
  B

Putting the sharp notes on black keys, you get 5 black keys and 7 white keys in every octave before it repeats.

We can run the same pattern in reverse.  Starting at the scale of C (at the right side of the table below), we can divide each pitch by 1.5 (going right to left). Now, we create new notes that we'll call Flats.  If you check the frequencies, though, the flats are almost the same frequencies as the corresponding sharps - Bb (1.7777) is the same as almost A# (1.7797), Eb (1.1852) is almost the same as D# (1.1865). 


We're left with a problem.  If we want to play in any scale with perfect tuning, we need an infinite number of keys.  Fortunately, some of the pitches end up being close enough to other notes that we can use the other note instead.

So how do we come up with a compromise?  That's the subject of part 3 in this series.

No comments:

Post a Comment