Saturday 2 August 2014

Reverse Engineering the Fretboard


Ever wondered how you'd work out the spacing of the frets on a guitar neck? No?

Well, I did and it led me through the maze of (western) music scales and on to an awful truth... there is no single universal harmonious musical scale!

First the Maths

I have no idea what the formal derivation of this is, but wanted to think it through to understand a bit more about the basic building blocks of music. That and, how would I make a guitar if I was stranded on a desert island?

So... the things I know as a starting point:
  • I know that a string with a frequency A (say) will have a frequency A*2 when the string length is halved. That's basic physics.
  • I also know that there are 12 frets between any given note and its double (octave above in music speak). That's twelve frets with the thirteenth being twice the frequency of where we started. Twelve is a western music convention. People have tried other combinations.
But there are many ways of dividing up a length of string into 12 parts. They could be equal, they could be a few percent closer for each fret etc. They could increase and decrease in distance apart. But we also know that the ratio between a string length and the next note up must be the same regardless of the string's length. To understand why this must be so, imagine a string that plays frequency A again. Now assume you play the next note up A' with a string length L'. Now detune the string so that L' now plays A again. To play A' on the L' string you have to move up to L''. Now we know that the frequency is relative to the length (physics again) and so L/L' = L'/L'' etc. So it doesn't matter how long the string is, to get to the next note you have to move up by a fixed ratio (R say) to the length of the string. The next note up on any string is a fixed ratio of  the length of the string regardless of its length. The 'scale' is length invariant as you might expect.


So we have:





That is, to work out how long the string is for the next note up, multiply its length by the inverse of the 12th root of 2. Nice and simple :)

Test Results

If you plug this formula into a spread-sheet and take the first note to be A=440 Hz (it's the standard) then you get the following:

LCalc HzEven tempered scaleMusical Note
0440.0440A
1466.2466.2Bb
2493.9493.9B
3523.3523.3C
4554.4554.4C#
5587.3587.3D
6622.3622.3Eb
7659.3659.3E
8698.5698.5F
9740.0740F#
10784.0784G
11830.6830.6G#
12880.0880A
R0.9438743127
12 root of 1/2

As you can see, the calculated values match those I've found on the internet. So they must be right.

More than one scale?

It turns out there is more than one scale in western music. In fact, people have created quite a number over the years. I've reverse engineered only one, the even tempered scale.

Why would you have more than one? Let's start with the scale we've created above. It turns out that the ratios of the notes to each other cannot be expressed exactly as simple fractions. Why does this matter? Because simple multiples of frequencies played together sound good - they beat together to form harmonious combinations. You could say that's a fundamental aspect of what we think of as music. Conversely, frequencies that are not simple multiples of each other often sound unpleasant when played together. 

It is possible to create a series of notes, similar to the ones above, but based on simple multiples of frequencies only. That is, they do not follow a pre-defined formula but rather they are a hand picked selection of notes that sound good together. Take a look at the just intonation.
The problem with this approach is that music played with these notes cannot be transposed (moved up and down) easily without breaking the simple ratios. But the even tempered scale does allow you to do this - it has that property but is a compromise between the harmonious benefit of simple ratios and the ability to play the same sequence of notes anywhere on the keyboard and sound much the same. Obviously higher or lower in frequency that is. 

So... as much as I'd like to think of the musical scale as something mathematically pure that's straight out of nature, the truth is that what's used in practice is often a compromise between creating harmonious combinations of notes, the physical implications of scale invariance for stringed instruments and man's desire to make the scale even, so that music can be played much the same in any key.

For an comprehensive overview of the history behind the various scales:

And for very good short description of the differences between the scales and their implications: 






No comments:

Post a Comment