23 Eylül 2012 Pazar

What is the difference between Just Intonation and Equal Temperament?

Music has many connections with mathematics. Approximately 2500 years ago, the ancient Greek mathematician Pythagoras and his students observed that the sounds of two plucked strings blend nicely if the ratio of their lengths is a ratio of small whole numbers. Today I want to explore the way our modern Western 12-note musical scale relates to that observation.

The white keys on a piano are traditionally labeled by the letters Athrough G. The black keys alternate between groups of two and three;the white key just to the left of a group of two black ones is calledC. Together, the twelve keys starting with C are calledan octave. The other white keys are named alphabetically, in acircular recurring pattern, as shown. The black keys are named afterthe adjacent white keys using the terms sharp and flatfor the black key to the right and left of a white key,respectively. For instance, the black key between F and G can equallywell be called F-sharp or G-flat.To distinguish keys with the same letter name, we number theoctaves beginning with each C. For instance, A3 sits between C3 and C4.

Inside the piano are tightly stretched strings. When you hit akey, a mechanical arm hits the corresponding string, making itvibrate. If you measure the lengths of the strings, you willfind that the strings for low (deep) notes (on the left side of thepiano keyboard) are longer than those for high (shrill) notes(on the right side).

If all the strings were identical except for length, each successive Cstring would be twice as long as the previous C. The same would betrue for each letter: each D would be twice as long as the previous D,and so forth. A piano includes just over 7 octaves, so the longeststring would be more than 2^7 times longer than the shortest one.Recallfrom Powersof Two Back in Time that 2^7 means 2 to the seventh power,i.e. seven copies of the number 2 multiplied together, or 128.

So, if the shortest string were 2 inches long, the longest would beover 256 inches, or more than 21 feet long. Such a huge sizedifference is impractical, so real pianos use tricks like thickerstrings (or wrapping one wire string with another) to achieve lownotes with reasonable length strings. They also use multiple stringsfor certain notes, and they connect the strings to a soundboard. Thesedetails give piano notes a characteristic sound different from that ofother stringed instruments like the guitar and the harp.

Even though the lengths of the strings in a modernpiano do not follow simple integer ratios, the frequencies ofthe sounds they generate do. When a string vibrates, it moves back andforth quite rapidly - hundreds or even thousands of times persecond. This rate of oscillation is called the frequency, and ismeasured in Hertz (Hz), with one Hertz equal to one completeback-and-forth cycle per second.

Middle C is C4, the C key near the center of the piano. The Aabove it (called A4) is generally tuned to have a frequency of 440 Hz.The shorter the string, the higher the vibrational frequency, and thehigher the pitch of the sound. The frequency doubles each time we movean octave to the right, and halves each time we move an octave to theleft. Moving left from A4, the A3 key has a frequency of 220 Hz, A2is 110 Hz, and A1 is 55 Hz, while moving to the right, A5 is 880 Hzand A6 is 1760 Hz.

The main question I want to discuss today is: how should we choosefrequencies for the other keys?

There are 11 keys (white and black) between A3 and A4, all of whichneed to be assigned frequencies. Once we have done this, the ruleabout doubling across octaves will tell us what frequencies to useover the rest of the piano. For example, once we specify the frequencyfor Middle C, we can get the frequencies for all the other C keys bydoubling or cutting in half, just as we did for A.

The frequency for Middle C must be between 220 and 440, since C4 isbetween A3 and A4 on the keyboard. We need to "leave room" for all 11intermediate keys, with frequency rising as we move left to right fromA3 to A4. One simple approach is to take 440 minus 220, divide by 12to get 18.3, and set the 11 intermediate frequencies to be equallyspaced, 18.3 Hz apart. For instance, starting with A3 at 220 Hz,Middle C is 3 keys further along, giving it a frequency of 220 +3*18.3 = 275 Hz.

However, the ear responds to frequency ratios ratherthan differences. This "equal difference" approach makes thegaps too large at the left side of the octave, and too small at theright side. Moreover, there is a sudden jump in spacing when we movefrom one octave to the next. Tuning the 11 keys this way workspoorly: the resulting music sounds unpleasant. We need a solutionbuilt around frequency ratios instead.

Modern pianos are tuned in such a way that the musical interval(the frequency ratio) between any two adjacent keys (counting bothblack and white keys) is the same. This "equal ratio" solution is knownas equal temperament (ET).

The number 1.059463 is called the 12th root of 2, because if you take12 copies of 1.059463 and multiply them together, you get 2. On anequal tempered instrument like the piano, if we know the frequency forone key, then the frequency for the next key will be 5.9% larger, andafter a 12 key octave (7 white and 5 black), the frequency will havedoubled.Thus ET is a completely symmetrical solution,in the sense that no matter what note you start from, the frequency ofthe next note is always 5.9% larger.

For instance, starting with A3 at 220 Hz, Middle C is 3 keys furtheralong, giving it a frequency of 220*1.0595^3 = 261.6 Hz.

We can write a simple formula for the frequency 'f' of each note on anequal tempered instrument. Number the notes (including both white andblack keys) sequentially. Let n0 be the number for the note A4. The equal-tempered frequency f(n) for any note n is given by:
f(n) = 440 * 2^((n - n0)/12).
The divide by twelve is there because we want 12 notes per octave. Forexample, the note A5 is one octave higher than A4, so it is numbern0+12. Plugging this in, we have f(A5) = 440 * 2^(12/12) = 880,because 2^1 is just 2. Similarly, f(A3) = 440 * 2^(-12/12) = 220,because 2^(-1) just means 1/2.

Working with twelfth-roots and all the other complexities ofthis formula is a bit tedious. Fortunately, we can simplify things.

The exponent is linear in n. All the real action in thisformula comes from the 2^(n/12) part. This means it will be easier towork directly in terms of n (a whole number) rather than do all thesemultiplications and divisions and raising to powers. In other words,you can forget about this formula and just think of note frequenciesbeing determined by their note number, relative to some starting pointlike A4.

That's exactly what musicians do: they express everything in termsof semitones. One semitone is the interval between two adjacentnotes (including both black and white keys), corresponding to a 5.9%increase in frequency on an ET piano. We can compute the intervalbetween any two notes simply by counting keys. For instance, the gapfrom C to D is two semitones long, but from B to C is just one, sincethere is no black key between them. If we draw a number line, we canplot the equal tempered piano keys on it as whole numbers, without anycomplicated math.

In math terms, we are really working with thebase-two logarithmof frequency. As you may recall from high school math,
log2( 2^a ) = a
In other words, the log function gives you the thing in the exponent.Whenever you have a multiplicative concept (such as frequencies thatgo up by a constant multiple with each semitone), taking logs reducesit to an additive concept (such as counting semitones). This isbecause of the rule for multiplying powers:
x^a * x^b = x^(a+b)
which in log terms says that
log(r*s) = log(r) + log(s)
Logs convert products into sums.

The frequencies of the notes in ET transform into whole numbers ofsemitones if we plot n instead of f. Reversing the original formula f = 440 * 2^((n - n0)/12) tells us that we should plot
n = n0 + 12*log2(f/440)
n0 is just a constant, so we ignore it and begin our number line atzero.

Now for the interesting bit: if we assign frequencies to notesusing some other system, we can plot the results on the same numberline, but now, the keys will have moved a little bit: they might notbe at whole numbers any more! ET is not the only way to do it,and a plethora of other temperaments have been used over the ages.

Going back to the Pythagorean ratio idea: certain musical intervalsplay a prominent role in Western music, so we might want them toinvolve simple integer ratios. The most important interval is theoctave, which does use a simple ratio, namely 2-to-1 (written 2:1, or2/1, or simply 2), even in equal temperament. But consider the interval from C to G. This isknown as a 5th, and it plays a central role in most music. Countingblack and white keys, G is 7 semitones above C, so the ET frequency ratioG/C is 1.059463^7 = 1.4983. This is very close to 1.5, alsoknown as 3/2. Indeed, in a tuning based on small integer ratios, G/Cwill be set to exactly 3/2. Now, 1.4983 is quite close to 1.5,so perhaps we will not hear the difference. But other simple-rationotes on the scale may not be as close to their ET counterparts. Let'sexplore.

We want to construct a graph showing small integerratios and how they compare to the equal tempered frequency ratios.One easy way is to use the free, high quality, open source programminglanguage called R, widely used in industry and academiabecause it is both easy and powerful. Download the latest version for Windows, Mac, orLinux from The R Project forStatistical Computing. Click on "Download R" and select a nearbymirror site to speed up the download. Then just double click the installerand accept the default selections. You should now have a desktop iconor Start menu entry for starting R. You can copy and paste the samplecode from this blog post right into the R console window, and it willprint answers and draw graphs right on your computer screen.

First, paste in the following commands:

plot(c(0,12), c(1,9), type="n", cex.axis=1.5,      cex.lab=1.5, xlab="Semitones", ylab="Denominator")text(c(0, 2, 4, 5, 7, 9, 11, 12), 1+0*(1:8),     c('C', 'D', 'E', 'F', 'G', 'A', 'B', 'C'),      cex=2, pos=3)

This plots the equal-tempered letter names on a logarithmicscale, as semitones, just like in the previous diagram. Next, add thefollowing commands:

for(y in 2:9)  for(k in 1:(y-1))  points(12*log2(1+k/y), y, pch=16, cex=2, col="blue")

The result should look like this:

For each denominator from 2 through 9, we look at thefrequency ratio 1+k/y, which is the same as (y+k)/y, and plot it as adot. The height is the denominator y, and the horizontal position isthe frequency ratio converted to the equal-tempered logarithmic scale.For example, the lowest row of dots has just one member, near thecenter, above G: it is the 3/2 ratio, so we plot it along the y=2line. The horizontal position is 12*log2(3/2) = 7.0196, just a tinybit to the right of G, which lives at 7.0000.

The top row corresponds to a denominator of 9, so the leftmost dot is the 10/9 frequency ratio, plotted at 12*log2(10/9)=1.8240, just to the left of D (at 2). The right most dot is the 17/9ratio, plotted at 12*log2(17/9) = 11.0104, just to the right of B (at11).

As mentioned earlier, we see that G/C really wants to be at3/2. Also, F/C matches up with 4/3, and A/C looks pretty close to 5/3,although the match is less exact. Similarly, we suspect that 5/4 is agood choice for E, though again, the match is less than exact. But Dis harder to judge from this diagram, and so is B.

The problem is that this diagram is not well suited to the task ofdetermining how close each small integer ratio is to the correspondingequal-tempered note. Even if we add grid lines, or push all the dotsonto the horizontal axis, it will still be hard to tell them apart. Weneed a better visualization method.

Here's a better idea: for each integer ratio, determine (by roundingto the nearest integer) which equal-tempered note it is closestto. Then, plot its distance from that equal-tempered note.Here's the resulting image; the code follows it.

To draw this image, paste in the following R code:

detail <- function(ratio, name) {  lf <- 12*log2(ratio)  x <- floor(lf+0.5)  y <- lf-x  text(x, y, name, pch=16, cex=2, col="blue")}gcd <- function(x,y) {  if(x>y) { z <- x            x <- y            y <- z }  if(x==y) return(x)  if(x==0) return(y)  gcd(y - floor(y/x)*x, x)}plot(c(0,12), c(-0.5,0.5), type="n", cex.axis=1.5,      cex.lab=1.5, xlab="Semitones", ylab="Discrepancy")text(c(0, 2, 4, 5, 7, 9, 11, 12), -0.5+0*(1:8),     c('C', 'D', 'E', 'F', 'G', 'A', 'B', 'C'),     cex=2, pos=3)for(y in 2:10)  for(k in 1:(y-1))    if(gcd(y,y+k)==1)       detail(1+k/y, paste(y+k,':',y,sep=''))detail(1, '1:1')detail(2, '2:1')abline(0,0)

This code uses two functions: detail, which plots asmall integer ratio, and gcd, which computes the greatestcommon divisor of two integers via Euclid's algorithm. We use the gcdfunction to avoid duplicate labels; for instance, both 3:2 and 6:4correspond to the same 1.5 frequency ratio, but we only want todisplay the former.

This new plot makes it much easier to see what is going on. Take the3:2 ratio to start with. In the earlier chart, 3/2 mapped toa horizontal position of 12*log2(3/2) = 7.0196, just a tinybit to the right of G=7 on the semitone scale. That was hard to seevisually, so this time, we round the value to 7, and plot only thediscrepancy, 0.0196, as the vertical coordinate.

Ratios like 1:1 and 2:1 that exactly match the equal-tempered scaleshow up as a discrepancy of zero, on the central horizontalline. 3:2 is a little higher frequency than G, so it plots in the Gcolumn a little above the center line. 4:3 is close to but slightlylower in frequency than F, so it plots in the F column a little belowthe center line.

Now we can easily see what ratios are close to what notes. Forexample, D is closer to 9:8 than to any of the other small integerratios shown on the plot. E is fairly close to 5:4, F is 4:3, G is3:2, A is 5:3, and B is 17:9. We can even get some of the "black keys"this way: nothing shows up for C-sharp, but D-sharp is close to 6:5,and F-sharp is close to 7:5, G-sharp is close to 8:5, and A-sharp isclose to 16:9.

The term "Just Intonation" refers to tuning a piano or other musicalinstrument so that the frequencies between notes match small integerratios. As this diagram shows, there is more than one way to dothis. For instance, B could be 17:9 or 15:8. The former, 17:9, is muchcloser to the equal-tempered value, but in fact, traditional JustIntonation tunings use 15:8 instead. Why? Because in additionto the small integer ratio criterion, they add another criterion: thatthe "major triads" (C-E-G, F-A-C, and G-B-D) all use a 4:5:6 frequencyratio. This forces B/G = 5/4, so B/C = 5/4 * G/C = 5/4*3/2 = 15/8.

In fact, over the centuries people have experimented with a widevariety of tunings and scales. Equal tempering came along relativelylate, since it involves irrational numbers (the twelfth root of two),which makes tuning by ear difficult. In contrast, tunings based onsmall integer ratios were developed earlier, since they are mucheasier to tune by ear.

Now for the question that I have trouble answering. As amathematician, I am intrigued by all these different patterns andcriteria for assigning frequencies to notes. But: does it make an audible difference?

Sufficiently big changes in the frequencies do produce audibledifferences. A really interesting book by William A. Setharescalled TuningTimbre Spectrum Scale touches on these and many relatedissues and includes audio demonstrations (some of which may beavailable as MP3 files on the book's website). These demonstrate anumber of interesting effects based on changing both the frequenciesassigned to notes, and the timbre of the instrument that plays them.For example, you can create instruments where an octave does notdouble the frequency, or where it is split into not 12 but 10 or someother number of equal parts.

What I am less certain about (as a non-musician) iswhether small changes - like using 17:9 instead of 15:8 for B - makemuch audible difference. The fascinatingbook Music:a Mathematical Offering by David J. Benson (which you can downloadon the web from his page) describes an enormous variety ofother scales and tunings, all using different mathematical criteriafor selecting the frequencies of the notes. I would be delighted tolearn whether ordinary (untrained) listeners can hear the differencesbetween them, and if so, which ones they prefer. If you createa synthesized sound example that helps answer these questions, I hopeyou will post it to the comment section.

As usual, please post questions, comments and other suggestions using the box below, or G-mail me directly at the address mentioned in the Welcome post. You can sign up for email alerts about new posts by entering your address in the widget on the sidebar, or follow @ingThruMath on Twitter, for a tweet about each new post. The Contents page has a complete list of previous articles in historical order. You may also want to use the 'Topic' and 'Search' widgets in the side-bar to find other articles of related interest.

If you enjoyed this article, click the "M"button below to email it to a friend, or the "t" button toTweet the link, or the "f" button to share it on Facebook.Thanks for reading - I hope you visit again next month!

Hiç yorum yok:

Yorum Gönder