Saturday, April 20, 2013

The Math of Music (part 3)

In the previous post, I derived the frequencies for the notes in all of the scales from Gb up to F#. In many cases, the pitches were close enough to call the same note but not quite correct. So which pitch do we choose?  We come up with a compromise called the "Equal Tempered Scale".

We know that between C and high C we need to jump from a pitch of 1 to a pitch of 2. From counting the notes in between C and high C we can see that we have 12 distinct notes.  Let's come up with a multiplier x that we can use to calculate the frequency of each of those notes.  Here's what we know:

  C = 1
  C# = 1 * x
  D = 1 * x * x
  D# = 1 * x * x * x
  ...
  C = 1 * x * x * x * x * x * x * x * x * x * x * x * x

But we know that high C = 2 so:
  x^12 = 2
  x is the 12th root of 2.

How can you calculate 12th roots?  Lets try to calculate the 4th root of 100,000,000.  Notice that there are 8 zeros.  We call 8 the log of 100,000,000 because 10 ^ 8 is 100,000,000.  If we divide 8 by 4, we get 2.  10^2 = 100 so 100 is the 4th root of 100,000,000.

We can do the same thing to calculate the 12th root of 2 by taking the log of 2 (0.30103) dividing it by 12 (0.025086) then raising 10 to that power (1.059463).  You can do the same thing with ln and exp if you're familiar with those.

So, by taking the frequency for C as 1, you can keep multiplying by 1.059463 to get each successive note until you get to high C.
C1
C#/Db1.059463094
D1.122462048
D#/Eb1.189207115
E1.25992105
F1.334839854
F#/Gb1.414213562
G1.498307077
G#/Ab1.587401052
A1.681792831
A#/Bb1.781797436
B1.887748625
C2

Each of these pitches is close to the right note but not quite.  In the case of the black notes that could be used as sharps or flats, the pitch we calculated this way is between the sharp pitch and the flat pitch so it makes a good compromise.

All that remains is to set the actual frequencies.  By international convention, the note A is exactly 440Hz.  Given that frequency and the multiplier of 1.059463, you can calculate the pitches of every note on the piano keyboard.

1 comment: