```On Tue, 2003-02-11 at 00:57, William Djaja Tjokroaminata wrote:
> Hal E. Fulton <hal9000 / hypermetrics.com> wrote:
> > [...] It turns out, yes,
> > it is arbitrary (like our base-ten system)... and yet
> > not arbitrary at all. It has to do with things "working
> > out" mathematically in a "nice" way. [...]

On Tue, 2003-02-11 at 00:57, William Djaja Tjokroaminata wrote:
> [...]  So
> when a string with fundamental tone C1 is played, actually we get all
> these overtones:
>
>     C1 C2 G2 C3 E3 G3 B&3 C4 ...
>
> Therefore, although it is true we can create any arbitrary scale, my guess
> is that they will not sound as natural... (probably I should some day
> experiment this in my Roland synthesizer...)

Notes whose ratio of frequencies are small integer fractions sound
"pleasing" to our ears.  For example, three notes whose frequencies have
the following ratios ...

1   5/4  3/2

make a pleasing sound called a major chord.  If the frequency of the
root note is 440 Hz (an A note), then an A major chord has the following
frequencies ...

A   440    1/1
C#  550    5/4
E   660    3/2

It turns out, that if we divide an octave into twelve equal steps
(musicians call the steps "half-steps" ... go figure), then we have the
following values for frequencies and approximate ratios for each of the
half steps ...

APPROX
NOTE FREQ       RATIO   ERROR
A  = 440.00     1 /  1 (0.0000)
A# = 466.16    10 /  9 (0.0516)
B  = 493.88     9 /  8 (0.0025)
C  = 523.25     6 /  5 (0.0108)
C# = 554.37     5 /  4 (0.0099)
D  = 587.33     4 /  3 (0.0015)
D# = 622.25     7 /  5 (0.0142)
E  = 659.26     3 /  2 (0.0017)
F  = 698.46     8 /  5 (0.0126)
F# = 739.99     5 /  3 (0.0151)
G  = 783.99     9 /  5 (0.0182)
G# = 830.61    11 /  6 (0.0544)
A  = 880.00     2 /  1 (0.0000)

With the tweleve equal steps, the A, C# And E notes turn out to have
(almost) the right frequency ratios to make the pleasing major chord
sound.

This system of notes (where all the ratio between half steps is
constant) is called "Equal Tempered".  The big advantage to equal
tempering is all scales sound equally good (or bad), no matter where you
start.  Most instruments today are equal tempered.

But equal tempering is not perfect.  The ratios are off just a little
bit.  Back in the old days (i.e. Bach's time), there was a great deal of
effort spent on finding the best possible tempering.  The problem was
that a tempering that sounded great in the key of C would sound REALLY
aweful in a different key.  A "Well Tempered" tuning is one that
maximizes the keys that sound good.  Different keys had slightly
different feelings to them (so I am told ... _my_ ear could never hear
the difference).  That (at least in part) is why so many classical
pieces announce their key in the title (e.g. Concerto in B flat major,
or whatever).  My understanding is that when Bach wrote "The Well
Tempered Clavier", he used a tuning of his own design.

Bill> (probably I should some day experiment this in my Roland
Bill> synthesizer...)

When I was playing around with synthesizer (mumble mumble) years ago, I
recall seeing programs that would setup the synth in well tempered
tunings.  You might want to check that out.

Finally, to make sure we don't get too far off topic, here is the Ruby
program I used to generate the frequency list ...

------------------------------------------------------------------------
#!/usr/bin/env ruby

HALFSTEP = 2 ** (1.0/12.0)

def freq(tonic, halfsteps)
tonic * HALFSTEP**(halfsteps)
end

def close_ratio(f)
n = 1
d = 1
best = [n, d, 10*100]
while n+d < 20
ratio = (n.to_f / d.to_f)
delta = (f - ratio).abs
best = [n, d, delta] if delta < best[2]
if ratio > f
d += 1
else
n += 1
end
end
best
end

def show_note(sym, val, tonic)
printf "%-2s = %6.2f    %2d / %2d (%6.4f)\n",
sym, val, *close_ratio(val / tonic)
end

A=440.0
%w(A A# B C C# D D# E F F# G G# A).each_with_index do |name, index|
show_note(name, freq(A,index), A)
end
------------------------------------------------------------------------

--
-- Jim Weirich     jweirich / one.net    http://w3.one.net/~jweirich
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

```