Merry Xmas Eve!

I'm not Christian, I'm Mathematician, but I love Xmas, Ymas and Zmas. I'm giving a talk on the math of tuning systems and I thought I'd share it here as a kind of present to y'all.

I'll start with the basics today and do the more advanced part tomorrow. But I hope even the basics contain a few twists that not everyone knows.

You can read my slides here:

http://math.ucr.edu/home/baez/tuning_talk/tuning_talk.pdf

but they don't contain all the stuff I'm saying here... the stuff I'll say out loud in my talk.

(1/n)

If you look at a piano keyboard you'll see groups of 2 black notes alternating with groups of 3. So the pattern repeats after 5 black notes, but if you count you'll see there are also 7 white notes in this repetitive pattern. So: the pattern repeats each 12 notes.

Some people who never play the piano claim it would be easier if had all white keys, or simply white alternating with black. But in fact the pattern makes it easier to keep track of where you are - and it's not arbitrary, it's musically significant.

(2/n)

Starting at any note and going up 12 notes, we reach a note whose frequency is almost exactly double the one we started with. Other spacings correspond to other frequency ratios.

I don't want to overwhelm you with numbers. So I'm only showing you a few of the simplest and most important ratios. These are really worth remembering.

(3/ n)

We give the notes letter names. This goes back at least to Boethius, the guy famous for writing The Consolations of Philosophy before he was tortured and killed at the order of Theodoric the Great. (Yeah, "Great".) Boethius was a counselor to Theodoric, but he really would have done better to stay out of politics - he was quite good at math and music theory.

Boethius may be the reason the lowest note on the piano is called A. We now repeat the names of the white notes as shown in the picture: seven white notes A,B,C,D,E,F,G and then it repeats.

[Whoop, Lisa is making me get up, make breakfast and go to the gym. I'll continue this later.]

(4/n)

So the scale used to start at A, using only white notes. But due to the irregular spacing of white notes, a scale of all white notes sounds different depending on where you start. Starting at A gives you the "minor scale" or "Aeolian mode", which sounds kinda sad. Now we often start at C, since that gives us the scale most people like best: the "major" scale.

(Good musicians start wherever they want, and get different sounds that way. But "C major" is like the vanilla ice cream of scales - now. It wasn't always this way.)

(5/n)

From the late 1100s to about 1600 people called describe pitches that lie outside 7-tone system "musica ficta" ("false" or "fictitious") notes. But gradually these notes - the black keys on the piano if you're playing in C major - became more accepted.

To keep things simple for mathematicians, I'll usually denote these with the "flat" symbol, ♭. For example, G♭ is the black note one down from the white note G.

(Musicians really need both flats and sharps, and they'd also call G♭ something else: F♯. I'll actually need both G♭ and F♯ at some points in this talk!)

(6/n)

Since starting the scale with the letter C takes a little practice, I'll do it a different way that mathematicians may like better. I'll start with 1 and count up. Musicians put little hats on these numbers, and I'll do that.

For example, we'll call the fifth white note up the scale the "fifth" and write it as a 5 with a little hat.

(7/n)

Now for the math of tuning systems!

The big question is: how do we choose the frequency of each note? This is literally how many times per second the air vibrates, when we play that note.

Since 1850, by far the most common method for tuning keyboards has been "12-tone equal temperament". Here we divide each octave into 12 equal parts.

What do I mean by this, exactly? I mean that each note on the piano produces a sound that vibrates faster than the note directly below it by a factor of the 12th root of 2.

But we can contemplate "N-tone equal temperament" for N = 1, 2, 3, .... - and some people do use these other tuning systems!

(8/n)

Here's a picture of the most popular modern tuning system: 12-tone equal temperament. As we march around clockwise, each note has a frequency of 2^{1/12} times the note directly before it.

When we go all the way around the circle, we've gone up an octave. That is, we've reached a frequency that's TWICE the one we started with.

But a note that's an octave higher sounds "the same, only higher". So in a funny way we're back where we started.

(9/n)

But now for a big question: why do we use a scale with 12 notes?

To start answering, notice that we actually use three scales: one with 5 notes (the black keys), one with 7 (the white keys) and one with 12 (all the keys).

As mathematicians we can notice a pattern here.

(10/n)

What's so good about scales with 5, 7 or 12 notes?

A crucial clue seems to be the "fifth". If you go up to the fifth white note here, its frequency is about 3/2 times the first. This is one of the simplest fractions, and it sounds incredibly simple and pure. So it's important. It's a dominant force in western music.

(11/n)

We can make a chart to see how close an approximation to the fraction 3/2 we get in a scale with N equally spaced notes.

N = 5 does better than any scale with fewer notes!

N = 7 does better than any scale with fewer notes!

N = 12 does better than any scale with fewer notes! And it does *way* better. To beat it, we have to go all the way up to N = 29 - and even that is only slightly better.

(12/n)

Here's a chart of how close we can get to a frequency ratio of 3/2 using N-tone equal temperament.

See how great 12-tone equal temperament is?

There are also some neat patterns. See the stripes of even numbers and stripes of odd numbers? That's not a coincidence. For more charts like this, and much more cool stuff along these lines, go here:

https://johncarlosbaez.wordpress.com/2023/10/19/perfect-fifths-in-equal-tempered-scales-part-2/

(13/n)

Here's the "star of fifths" in 12-tone equal temperament!

I'll quit here for now, and continue on Xmas.

(14/n)

Merry Xmas! My dream of the internet includes a lot of people giving each other gifts. Mastodon comes close to that. I'd like to thank everyone on Mastodon for all the you've gifts you've given each other over the year. Here are some presents in return....

Yesterday I talked about 12-tone equal temperament: the tuning system where we chop the octave into 12 equal parts.

This has been the most popular tuning system since maybe 1810, or definitely by 1850. But it's mathematically the most boring of the tuning systems that have dominated Western music since the Middle Ages. Now let's go back much earlier, to Pythagorean tuning.

When you chop the octave into 12 equal parts, the frequency ratios of all your notes are irrational numbers... *except* when you go up or down some number of octaves.

The Pythagoreans disliked irrational numbers. People even say they drowned Hippasus at sea after he proved that the square root of 2 is irrational! That's just a myth, but it illustrates how people connected Pythagoras to a love of rational numbers. In Pythagorean tuning, people wanted a lot of frequency ratios of 3/2.

In equal temperament, where we chop the octave into 12 equal parts, when we start at any note and go up 7 of these parts (a so-called "fifth"), we reach a note that vibrates about 1.4981 times as fast. That's close enough to 3/2 for most ears. But it's not the Pythagorean ideal!

As we'll see, seeking the Pythagorean ideal causes trouble. It will unleash the devil in music.

(15/n)

Start at some note and keep multiplying the frequency by 3/2, like a good Pythagorean. After doing this 12 times, you reach a note that's close to 7 octaves higher. But not exactly, since the 12th power of 3/2 is

129.746338

which is a bit more than

2⁷ = 128

The ratio of these two is called the 'Pythagorean comma':

p = (3/2)^12 / 2⁷ = 3¹² / 2¹⁹ ≈ 1.0136

This is like an unavoidable lump in the carpet when you use Pythagorean tuning.

It's good to stick the lump in your carpet under your couch. And it's good to stick the Pythagorean comma near the so-called 'tritone' - a very dissonant note that you'd tend to avoid in medieval music. This note is halfway around the circle of fifths.

In Pythagorean tuning, going 6 steps clockwise around the circle of fifths doesn't give you the same note as going 6 steps counterclockwise! We call one of them ♭5 and the other ♯4.

Their frequency ratio is the Pythagorean comma!

(16/n)

In equal temperament, the tritone is exactly halfway up the octave: 6 notes up. Since going up an octave doubles the frequency, going up a tritone multiplies the frequency by √2. It's no coincidence that this is the irrational number that got Hippasus in trouble.

In Pythagorean tuning, going 6 steps up the scale doesn't match jumping up an octave and then going 6 steps down. We call one of them ♭5 and the other ♯4. They're both decent approximations to √2, built from powers of 2 and 3.

Their frequency ratio is the Pythagorean comma!

(17/n)

The tritone is sometimes called 'diabolus in musica' - the devil in music. Some say this interval was actually *banned* by the Catholic church! But that's another myth.

It could have gotten its name because it sounds so dissonant - but mathematically, the 'devil' here is that the square root of 2 is irrational. If we're trying to use only numbers built from powers of 2 and 3, we have to arbitrarily choose one to approximate √2.

In Pythagorean tuning we can choose either

1024/729 ≈ 1.4047

called the sharped fourth, ♯4, or

729/512 ≈ 1.4238

called the flatted fifth, ♭5, to be our tritone. In this chart I've chosen the ♭5.

No matter which you choose, one of the fifths in the circle of fifths will be noticeably smaller than the rest. It's called the 'wolf fifth' because it howls like a wolf.

You can hear a wolf fifth here:

https://www.youtube.com/watch?v=7lWINJ9Dxxg

🐺

(18/n)

If you're playing medieval music, you can easily avoid the wolf fifth: just don't play one of the two fifths that contains the tritone!

A more practical problem concerns the 'third' - the third note in the scale. Ideally this vibrates 5/4 as fast as the first. But in Pythagorean tuning it vibrates 81/64 times as fast. That's annoyingly high!

Sure, 81/64 is a rational number. But it's not the really *simple* rational number our ears are hoping for when we hear a third.

Indeed, Pythagorean tuning punishes the ear with some very complicated fractions. The first, fourth, fifth and octave are great. But the rest of the notes are not. There's no way that 243/128 sounds better than an irrational number!

In the 1300s, when thirds were becoming more important in music, theorists embraced a beautiful solution to this problem, called 'just intonation'.

I'll explain this in some later installments. Maybe tomorrow. The British call it 'Boxing Day', because after Christmas with your relatives you sometimes feel like punching someone. But since I'm having a quiet day with Lisa, tomorrow I'll probably just explain just intonation.

(19/n)

It's an amazing fact that in western composed music, harmony became important only around 1200 AD, when Perotin expanded the brand new use of two-part harmony to four-part harmony.

This put pressure on musicians to use a new tuning system - or rather, to revive an old tuning system. It's often called 'just intonation' (though experts will find that vague). We can get using a cool trick, though I doubt this is how it was originally discovered.

First, draw a hexagonal grid of notes. Put a note with frequency 1 in the middle. Label the other notes by saying that moving one step to the right multiplies the frequency of your note by 3/2, while going up and to the right multiplies it by 5/4.

(20/n)

Next, cut out a portion of the grid to use for our scale. We use this particular parallelogram - you'll soon see what's so great about it.

(21/n)

Now, multiply each number in our parallelogram by whatever power of 2 it takes to get a number between 1 and 2.

We do this because we want frequencies that lie within an octave, to be notes in a scale. Remember: if 1 is the note we started with, 2 is the note an octave up.

(22/n)

Now we want to curl up our parallelogram to get a torus. If we do this, gluing together opposite edges, there will be exactly 12 numbers on our torus - just right for a scale!

There's a problem: the numbers at the corners are not all equal. But they're pretty close! And they're close to √2 - the frequency of the tritone, the 'devil in music'.

25/18 = 1.3888....
45/32 = 1.40625
64/45 = 1.4222....
36/25 = 1.44

So we'll just pick one.

(23/n)

@johncarlosbaez looking forward to the just intonation desserts
@johncarlosbaez looking forward to more on this.
My partner restored the Ellis Harmonical from Bate collection in Oxford. Intended to be an instrument to demonstrate Just Intonation.
@johncarlosbaez @johncarlosbaez but how did the practice of actually tuning instruments work? with just intonation, it's obvious: you can hear simple fractions, and hear the beat frequencies to eliminate to bring two notes into tune. this doesn't work with complicated fractions because you're basically aiming for a particular beat frequency and noisy harmonics. how could musicians 800 years ago accurately punish the ear with pythagorean tuning? I could imagine using external references, like tuning forks, but how could you calibrate these references to begin with?

@johncarlosbaez The Fisk-Nanney organ at Stanford Memorial Chapel is an interesting instrument, with both fifth-comma and well-tempered tunings (in a pipe organ!). The “Brustpositive and the Brustpedalia are fixed in meantone and offer two sub-semitones, or split sharps, per octave, D sharp/E flat and G sharp/A flat”

https://cbfisk.com/opus/opus-85/

https://orsl.stanford.edu/memorial-church-organs

(My Mom, a student of Herb Nanney, loved playing this organ.)

Opus 85 – CB Fisk

@dan131riley - Wow! That sounds really interesting to play. So there were separate rows of keys for the two tuning systems?

Fifth-comma meantone is new to me: I've spent a lot of time studying quarter-comma, and I've see third-comma and sixth-comma. But I now see someone has blogged positively about fifth-comma:

https://www.concertina.net/forums/index.php?%2Ftopic%2F21123-my-experience-with-15-comma-mean-tone-tuning%2F

"Well-tempered" raises the question: which of the many well-tempered systems?

My experience with 1/5 comma mean tone tuning

It's about a year since I asked for others' experience with using fifth comma mean tone tuning in another thread. The answers I received were sufficiently encouraging for me to take the plunge and have my 48 key Crabb Crane duet tuned to this temperament. I haven't regretted it for a moment. A br...

Concertina.net Discussion Forums
Tritone paradox - Wikipedia

@TonyVladusich Nice! Another example of the multistability of audio. Similar to Sine Wave Speech! And Thermal Grill illusion.

@troy_s @TonyVladusich - no, I hadn't heard of the tritone paradox. Thanks! I wonder what kind of person I am. Is there a YouTube video or website that will play the Shephard tone, so I can find out?

Nor have I heard of sine wave speech, nor the thermal grill illusion.

I'm still trying to wrap my head around tritone substitution.

https://johncarlosbaez.wordpress.com/2024/07/27/tritone-substitutions/

@johncarlosbaez
Probably a result of our very varied musical landscape these days, but to me that interval sounds *spicy* , not bad. Something you'd save up for a particularly interesting transition or thematic mood change in a piece.
@johncarlosbaez "lump in the carpet" is a great analogy

@johncarlosbaez This is a fascinating thread!

While my college choir was rehearsing some early music, the conductor said, "Don't sing the tempered scale. It's the downfall to the devil."

@robhughes - Thanks! There's a conductor who took their work seriously.
@johncarlosbaez
Maybe you should stay pure,
but only go two fifth up and two fifths down, i.e.,
{♭7, 4, 1, 5, 2}
Kind of weird pentagram, that.
@christophmaier - I'll get into Pythagorean tuning next time, where they keep going up and down fifths until they hit trouble.

@johncarlosbaez Early tunings (up to 1600±) were based on the concept of pure intervals; perfect 5ths, to start with. The documented history comes from European church music; early folk music may have been different, but there is no way of knowing. But when keyboard instruments became usable, around 1500, tuning became a problem. Working through a circle of perfect 5ths to tune an early harpsichord or organ produced the Pythagorean comma: Starting on middle C and tuning 7 perfect 5ths, the ending C is not a perfect octave. If you use a system of perfect 3rds, then you wind up dealing with the syntonic comma.

So various tempered systems developed to work around the comma. <insert ½ semester on early keyboard tunings> I have tuned instruments in meantone and Werkmeister III systems. The idea of everything except octaves being "not pure" was a compromise to allow music to be played in any key.

The piano mechanism we know was developed by Erard in 1821, and improved through the early 19th century. In the 1840s, builders added a heavy iron frame to support high tension strings. <insert ¼ semester section on the history of keyboard construction>

The final decision to use A440 as a standard was only settled upon in 1939. Early music performers sometimes use A415 or A435.

(/music historian, organist, instrument builder)

@c_merriweather - My talk will get bogged down in the delightful intricacies of just intonation - I'm giving a talk in the math department and I think they'll like that - so it'll never reach quarter-comma meantone or well temperaments. But I had a lot of fun studying those, and should probably return to the latter.

I learned a lot from the website of the harpsichord maker Carey Beebe - maybe you know him:

https://www.hpschd.nu/index.html?nav/nav-4.html&t/welcome.html&https://www.hpschd.nu/tech/tmp/kirnberger.html

He offers distilled descriptions of different tuning systems in a way that a mathematician like myself can quickly absorb.

@johncarlosbaez All the math comes later, the people at the time tuned instruments by ear, as have I. I even built a monochord to illustrate the fractions involved in the overtone series.

The perfect intervals were in many ways easier to tune. And if in the proper key, the keyboards were able to match the singers, who were, and are, not limited by fixed tuning. To hear medieval and Renaissance music performed with historical tunings is amazing in its clarity.

I studied early and Renaissance music and early organ technique, so I got the full lecture.

@johncarlosbaez in the thread you asked about further literature on the topic. A composer who has written on this is late Clarence Barlow (https://clarlow.org/texts/) in his book on Musiquantics. A theorist who is very involved in the topic is William Sethares (the book is Tuning, Timbre, Spectrum, Scale). The main takeaway from these theories is that the consonance of scales depends on the spectral structure of the basic sound. The aesthetics of timbre and scale are culture specific.
Texts – Clarence Barlow

@johncarlosbaez

One of the things that was hardest for me to get my head wrapped around was that we perceive log frequency. Hence the octave is a doubling of frequency, and everything else, where people talk about "adding a semi-tone" is actually *multiplying* by something. (In modern scales, multiplying by a power of 2^(1/12).)

Music theorists are not a mathematical tribe, and for many years I just *could* *not* understand the word salad they wrote about this!

But then some book or other whose title involved "music" and "physicists" explained it all with just a couple equations.

@weekend_editor - I hope that my talk will make sense to mathematicians. When I actually give it, I'll probably find that some things that seem obvious to me aren't obvious to others.

I had a lot of trouble explaining to my sister the concepts of "note" and "key". They sound obvious until you try to explain them - both those words mean at least two things.

@johncarlosbaez I don't know much about music but I am guessing these issues arise because we need to divide octaves into individual frequencies on the basis that this is necessary to create, for example, "keys" on instruments like pianos. You can't have an infinite number of keys in an octave on a piano.

But what about producing music through a computer? How the notation for such a thing would work, I have no clue but in theory I imagine every "chord" could be perfect?

@rozeboosje @johncarlosbaez

A lot of computer music doesn't exactly have notation. Instead it has a user interface.

Let's say you have a computer and want to make a very simple chord over A. You can go look for the frequency of the 5th note in the scale or you could just multiply 440 by 3/2. This direct use of fractions is called "just intonation".

The problem with doing this is that the third note in the scale in 12tet is way off from the ideal just intoned fraction. So if you have a perfectly in tune chord on C and then your melody goes to E, that E is going to sound really wrong.

So you could also just make all the notes in the scale just intoned, but if your music goes onto a key change, it can also sound off, unless you retune all your notes to be the just notes relative to the new key. All your As are now a new frequency. This can sound great, but its fiddly.

Changing all the notes in every chord relative to the bottom note in the chord also often sounds wrong and kind of unmoored. Its often better to stick with the scale that belongs to your key because the notes are more stable and you can more easily tell when you're getting to an important note.

There are many composers who write this way but its extra work so most people stick with 12tet.

@celesteh - do you know anyone who has written about the problems you just mentioned, and their solutions, e.g. how changing all the notes in every chord relative to the bottom note sounds unmoored, etc? I think these are really interesting problems for 21st-century music.

@johncarlosbaez

I need to look through my notes and can't today and theres a risk I may forget in the chaos I expect later today. I'll make a note, bit if you want to remind me that would be great.

I ran into these problems with my own experimentation and then talked about it with Ellen Fullman who told me about the unmoored thing and somewhere I do know where she learned this.

There's also keyboard tuning software from the late 80s and early 90s in MAX that had an octave of the keyboard set aside to tune the key, but this is another thing I need to search to find.

@johncarlosbaez

I think this also impacts organ tuning…

@johncarlosbaez

Kyle Gann hints at the rootedness of just tunings here: https://www.kylegann.com/tuning.html

"On a piano in just intonation, moving from one tonic to another changes the whole interval makeup of the key, and you get a really specific, visceral feel for where you are on the pitch map. That feeling disappears in bland, all-keys-the-same equal temperament."

Just Intonation Explained

@celesteh - Merry Christmas! I'll try to remember to remind you at a better time.

@johncarlosbaez
Once you have settled on 12, there is a much more mathematical way to look at scales and modes.
Just count the number of half steps, then consider where they land.
The minimum number of half-steps is 2. There are 3 distinct ways we can put 2 half-steps in the scale: (1 is a half step, 2 is a whole)
1122222 (call this A)
1212222 (B)
1221222 (C)

You can also pick your starting note. So in this notation, regular major (Ionian) is C1, starting with the first (zero-based) interval.
Locrian is C0,
Dorian C2,
Phrygian C3,
Lydian C4,
Mixolydian C5,
Aeolian C6.

It seems like A and B are much rarer. Neopolitan Major is A1, Lydia Minor is A4, Locrian Major is A5, Super Locrian is B0.

And the Melodic Minor is B when ascending, C when descending.

Then, of course, you can add more half steps.
The Blues scale is 12212112. And trivially the chromatic scale is 111111111111.

Anyway that's how I would have defined everything if I had gotten to decide. 😂

@johncarlosbaez oh that is such a cool explanation of finding the "minimum of a sliding window". Superabundant numbers are defined similarly but the ratio being extremized is related to number of factors.
@johncarlosbaez G# always sounds so tasty to me!

@johncarlosbaez

I was pickled by curiosity because in Spanish, and other Romance languages, the notes have other names (Do, Re, Mí, Fa, Sol, La , Si). I found they were introduced for singing training using the Hymn to St. John the Baptist, "Ut queant laxis". They were the first syllables of the verses (except Ut and Sa which were changed to Do and Si for being easier to uterate).

We name the singing training "solfeo".

Nothing to do with math, sorry for the diversion, thank you for the post.

@edgarchavez @johncarlosbaez in Hindustani classical, the notes are {sa, re, ga, ma, pa, dha, ni} and the alphabet is called "sargam", for the first 4 names

@adityakhanna @edgarchavez - the different note names in different regions of the world are really interesting!

In terms of sheer *area*, solfège seems to dominate. But audience will be American so I won't even mention it. 😢

https://www.reddit.com/r/lingling40hrs/comments/uwxjec/music_notes_names_around_the_world/

@johncarlosbaez @adityakhanna @edgarchavez That's not quite true, I mean, solfége exists here too - we know what it is - but! it's used for relative points in a scale rather than a specific note's name.

So the base note in a scale is always "do," regardless of key you're in, as opposed to being a specific note outside of the scale.

For example, if you're in D major, nobody sings that scale like "D, E, F-sharp, G, A" they sing "do, re, mi, fa, so." But the base note is called D, not do.

@edgarchavez @johncarlosbaez

We use those names in English as well, except with Ti instead of Si. (If you know your English-language musicals, then you may have heard them used in The Sound of Music.) But the difference between these and the letters is that the letter notes are at (or at least near) specific frequencies, while solfege (as we call it) is relative. That is, A is always about 440 Hz (modulo a power of 2), but La could be anywhere (with the others arranged at the same relative frequencies).

@TobyBartels @johncarlosbaez

Thank you! This got more interesting. I have to confess my musical knowledge is close to zero.

@edgarchavez @TobyBartels - Toby is right, so it's actually useful to have *both* a letter system (for absolute pitches) and a solfège or sa re ga ma pa system (for pitches relative to an arbitrary starting point). I don't think Western musicians ever sing "A B C D E" (or at least hardly ever); I here in America I often hear them sing "do re mi..." But still there's some sense in which "do re mi" is more important outside the Anglosphere - I'm not sure why.