Desafinado, Part One: Eric Continues His Obsession With The Greeks

Desafinado, Part One: Eric Continues His Obsession With The Greeks

Rate This
• Comments 9

Whew.  That's enough wacky VBScript for a while.

As I said a long, long time ago now, I came up with the idea of doing a little "wacky VBScript" quiz in order to illustrate some of the weird corner cases in language design.  I want to do a long -- potentially very long -- series on some of the more computer sciency fundamental issues in the theory of programming languages and what "computation" means. These quirks are just the fun corner cases.

But I feel like changing gears for a bit before I get into that heavy lifting, if you'll pardon the mixed metaphor.

So for the next little while, music! No computers!

Well, ok, maybe some computers. In parts one through three, we'll build up some musical theory starting from the Ancient Greeks. In Part Four, we'll write a program that illustrates what I'm talking about. In Part Five, weird psychoacoustics!

*********************************************

One of my many dilletantish hobbies is playing the piano.  I've got an upright at home with a lovely case and a terrible action, and it's not really in tune.  I have all the equipment I need to tune it myself, I just don't have the time right now, or the temperament.

Ha ha ha ha, little piano tuner joke there.  It'll become clear why that's so funny in a bit.

The ironic thing about tuning a piano is this: all pianos are out of tune. On purpose.

In fact, almost all music you've ever heard on all instruments has been deliberately out of tune.

How is that possible?  Surely you'd have noticed!

To explain, we have to go way, way back to the time of Pythagoras, that mystic ancient Greek whose dour band of crazy math geeks violently suppressed information about dodecahedra and the irrationality of root two.  Amongst the Pythagoreans' many fundamental discoveries in mathematics is that if you pluck tightened strings of equal tension and different lengths, the sound is most consonant -- pleasing to the ear -- when the ratio between the string lengths is a ratio of small whole numbers.

For instance, take a string under tension and press down on it like you would on a guitar, dividing it into two strings, one twice as long as the other.  Or, equivalently, get two strings under the same tension, one twice as long as the other.  If you pluck them at the same time then you get a very pleasing sound.  The ratio is 1:2, and this is a "perfect octave".   Find yourself a piano and hit middle C and the next higher or lower C and you'll hear what I mean.  In some very strong sense the human ear hears these two tones as extremely similar. We hear it as "the same tone, only higher".

Clearly "octave" has something to do with the number eight -- what exactly will become clear later.

Why it is that humans find small ratios pleasant is an interesting question that I might explore in another post.  But for now, just accept that small whole number ratios sound really good.

If 1:2 sounds good, what about other small-number ratios?  Doubling/halving the string length gives you an octave. What about making the string 50% longer -- a ratio of 2:3?  Yes, that also sounds really good.  If you play C on a piano and then hit the G below it, that's a ratio of 2:3 in terms of string length (again, assuming that the strings are under the same tension, etc.)

This is the ratio used in Gregorian chants.  This ratio is called a "fifth", again, for reasons which will become clear later.

We know nowadays something that the Pythagoreans did not: that what really matters is not the lengths of the strings, but the speed at which they vibrate.  It just happens that a string that is twice as long vibrates half as slowly, all other things being equal, so basically the ratios are the same whether you're talking about string length or vibration frequency, they're just opposite in order.

From now on we'll talk only about ratios in terms of their vibrations per second, and stop worrying about string length. A piano has eight octaves. If the longest string had to be 128 times longer than the shortest string then you'd need a big room!  Therefore we vary the thickness, weight and tension of the strings so that they can be a reasonable length and yet vibrate at the right frequency. It's the vibrations that matter. (The variance in thickness of the strings leads to practical problems with inharmonicity in the short strings, but we probably won't get into that level of detail in this series.)

Next time we'll mentally build a stringed instrument from scratch and figure out how to tune it to perfect Pythagorean pitches.

• Great post, Eric. And a killer idea for a series, too.

Being a music geek too (piano, too), I think it's exciting to see others interested by the mathematics of music.
• Since you bring up math and music it seems only fitting to bring up Euler who developed a mathematical theory of music, but I understand that the mathematicians considered his theory too musical and the musicians considered it too mathematical! :)
• Very funny joke. I get it.

The first time I heard about temperment was years after I started (and stopped) playing piano. It really tripped me out as I thought I knew all about how stringed instruments worked.
• Eric Lippert, explainer extraordinnaire, has started a series that we might call &quot;Fabulous Adventures in Music.&quot; Knowing Eric, we can assume that his descriptions of, say, the physics of music will be as enlightening and entertaining as his exegeses on ...
• Oh, finally Mr. Lippert managed to write an interesting article ;)

(I'm just trying to get rid of DirectMusic in VB.Net--not that it has something to the content of this post, but is somewhat symptomatic to speak about VB and Music generation in the same context.. Btw, i still miss that once someone decided to strip BASIC of the fabulous `PLAY "cdefgab"`...)
• I don't have anything in particular to contribute to the discussion other than that I can't wait to read more of this miniseries... as a musician and a programmer it's great to hear someone discussing all of this from a similar perspective :)

and haha at the temperament joke ;) I think i'm of ... equal temperament ... too, so i fully understand!
• Great, this will be a good series, I teach guitar on the side just for fun, one of the things that is hard to get students to understand is that there is also mathmatics in music.

Many people just think they can carry a tune and not understand it. Now if I could only get my father to understand this maybe he will forgive me finally for taking Classical Guitar in College While majoring in Computer Science. He never bought the mathmatics.
• Now if only Donald Duck in Mathmagic Land were available on DVD....
• how do we rate this article? i clicked on rate this and there was no effect

Page 1 of 1 (9 items)