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.