A few weeks ago I wrote about how the dissonance of a musical interval is related to the complexity of the frequency ratio as a fraction, where complexity is measured by the sum of the numerator and denominator. Consonant intervals have simple frequency ratios and dissonant intervals have complex frequency ratios.

By this measure, the most consonant interval, other than an octave, is a perfect fifth. And the most dissonant interval is a tritone, otherwise known as the diminished fifth or augmented fourth. So in some sense perfect fifths and tritones are opposites, but they are both ways of splitting an octave in half, just on different scales.

Linear scale versus log scale

When we say simple frequency ratios are consonant and complex frequency ratios are dissonant, we are speaking about ratios on a linear scale. But we often think of musical notes on a logarithmic scale. For example, we think of the notes in a chromatic scale as being evenly spaced, and they are evenly spaced, but on a log scale.

If we divide an octave in half on a linear scale, we get a perfect fifth. For example, if we take an A 440 and an A 880 an octave higher, the arithmetic mean, the midpoint on a linear scale, we get E 660.

But if we divide an octave in half on a log scale, we get a tritone, three whole steps or six half steps out of 12 half steps in a chromatic scale. The midpoint on a log scale is the geometric mean. The geometric mean of 440 and 880 is 440 √2 = 622, which is D#.

So we take the midpoint of an octave on a linear scale we get the most consonant interval, a perfect fifth, but if we take the midpoint of an octave on a log scale we get the most dissonant interval, a tritone.

Tritone substitution

Intervals of a fifth are so consonant that they don’t contribute much to the character of a chord. It is common to leave out the fifth.

Tritones, however, are essential to the sound of a chord. In fact, it is common to replace a chord with a different chord that maintains the same tritone. For example, in the key of C, the G7 chord contains B and F, a tritone. The chord C#7 contains the same two notes (though the F would be written as E#), and you’ll often see a C#7 chord substituted for a G7 chord. So a song that had a Dm–G7–C progression might be rewritten as Dm–C#7–C, creating a downward chromatic motion in the base line.

This is called a tritone substitution. You could think of the name two ways. In the discussion above we talked about preserving the tritone in a chord. But notice we also changed the root of the chord by a tritone, replacing G with C#. More generally, replacing any chord with a chord whose root is a tritone away is called a tritone substitution or simply tritone sub. For example, a D minor chord does not contain a tritone, but we could still do a tritone sub, replacing Dm with G#m because D and G# are a tritone apart.

Related posts

Jaccard index and jazz albums

Miles Davis Kind of Blue album cover

Jaccard index is a way of measuring the similarity of sets. The Jaccard index, or Jaccard similarity coefficient, of two sets A and B is the number of elements in their intersection, AB, divided by the number of elements in their union, AB.

J(A, B) = \frac{|A \cap B|}{|A \cup B|}

Jaccard similarity is a robust way to compare things in machine learning, say in clustering algorithms, less sensitive to outliers than other similarity measures such as cosine similarity.

Miles Davis Albums

Here we’ll illustrate Jaccard similarity by looking at the personnel on albums by Miles Davis. Specifically, which pair of albums had more similar personnel: Kind of Blue and Round About Midnight, or Bitches Brew and In a Silent Way?

There were four musicians who played on both Kind of Blue and Round About Midnight: Miles Davis, Cannonball Adderly, John Coltrane, and Paul Chambers.

There were six musicians who played on both Bitches Brew and In a Silent Way: Miles Davis, Wayne Shorter, Chick Corea, Dave Holland, and John McLaughlin, Joe Zawinul.

The latter pair of albums had more personnel in common, but they also had more personnel in total.

There were 9 musicians who performed on either Kind of Blue or Round About Midnight. Since 4 played on both albums, the Jaccard index comparing the personnel on the two albums is 4/9.

In a Silent Way and especially Bitches Brew used more musicians. A total of 17 musicians performed on one of these albums, including 6 who were on both. So the Jaccard index is 6/17.

Jaccard distance

Jaccard distance is the complement of Jaccard similarity, i.e.

d_J(A, B) = 1 - J(A,B)

In our example, the Jaccard distance between Kind of Blue and Round About Midnight is 1 − 4/9 = 0.555. The Jaccard distance between Bitches Brew and In a Silent Way is 1 − 6/17 = 0.647.

Jaccard distance really is a distance. It is clearly a symmetric function of its arguments, unlike Kulback-Liebler divergence, which is not.

The difficulty in establishing that Jaccard distance is a distance function, i.e. a metric, is the triangle inequality. The triangle inequality does hold, though this is not simple to prove.

F# and G

I was looking at frequencies of pitches and saw something I hadn’t noticed before: F# and G have very nearly integer frequencies.

To back up a bit, we’re assuming the A above middle C has frequency 440 Hz. This is the most common convention now, but conventions have varied over time and place.

We’re assuming 12-tone equal temperament (12-TET), and so each semitone is a ratio of 21/12. So the nth note in the chromatic scale from A below middle C to A above middle C has frequency

220 × 2n/12.

I expected the pitch with frequency closest to integer would be an E because a perfect fifth above 220 Hz would be exactly 330 Hz. In equal temperament the frequency of the E above middle C is 329.6 Hz.

The frequency of F# is

220 × 29/12 Hz = 369.9944 Hz.

The difference between this frequency and 370 Hz is much less than the difference between equal temperament and other tuning systems.

The frequency of G is

220 × 25/6 Hz = 391.9954 Hz

which is even closer to being an integer.

In more mathematical terms, stripped of musical significance, we’ve discovered that

23/4 ≈ 37/22


25/6 ≈ 98/55.


Humming St. Christopher

The other day I woke up with a song in my head I hadn’t heard in a long time, the hymn Beneath the Cross of Jesus. The name of the tune is St. Christopher.

When I thought about the tune, I realized it has some fairly sophisticated harmony. My memory of the hymns I grew up with was that they were harmonically simple, mostly built around three chords: I, IV, V. But this hymn has a lot going on.

I imagine a lot of things that I remember as being simple weren’t. I was simple, and my world was richer than I realized.


You can find the sheet music for the hymn here. I’ll write out the chord progressions for the first two lines.

    I     idim | I            | V7   ii7 V7  | I   III | 
    vi   iidim | vi VI7 ii vi | II   VIII7♭5 | III     |

If you’re not familiar with music theory, just appreciate that there are a lot more symbols up there than I, IV, and V.

The second line effectively modulates into a new key, the relative minor of the original key, and I’m not sure how to describe what’s going on at the end of the second line.

Related posts

Updated pitch calculator

I’ve made a couple minor changes to my page that converts between frequency and pitch. (The page also includes Barks, a psychoacoustic unit of measure.)

If you convert a frequency in Hertz to musical notation, the page used to simply round to the nearest note in the chromatic scale. Now the page will also tell you how sharp or flat the pitch is if it’s not exact.

For example, if you enter 1100 Hz, the page used to report simply “C#6” and now it reports “C#6 – 14 cents” meaning the closest note is C#6, but it’s a little flat, 14/100 of a semitone flat. If you enter 1120 Hz it will report “C#6 + 18 cents” meaning that the note is 18/100 of a semitone sharp.

Octave numbers, such as the 6 in C#6 are explained here.

The other change I made to the page was to add a little eighth note favicon that might show up in a browser tab.

pitch converter favicon

I’ve written several online converters like this: LaTeX to Unicode, wavelength to RGB, etc. See a full list here.



Saxophone with short bell

Paul A. sent me a photo of his alto sax in response to my previous post on a saxophone with two octave keys. His saxophone also has two octave keys, and it has a short bell. Contemporary saxophones have a longer bell, go down to B flat, and have two large pads on the bell. Paul’s saxophone has a shorter bell, only goes down to B, and only has one pad on the bell.

Alto sax with short bell

Here’s a closeup of the octave keys.

Two octave keys

Paul says he found his instrument in an antique shop. It has no serial number or manufacturer information. If you know anything about this model, please leave a comment below.

Saxophone blog posts

All possible scales

Pete White contacted me in response to a blog post I wrote enumerating musical scales. He has written a book on the subject, with audio, that he is giving away. He asked if I would host the content, and I am hosting it here.

Here are a couple screen shots from the book to give you an idea what it contains.

Here’s an example scale, number 277 out of 344.

scale 277

And here’s an example of the notes for the accompanying audio files.

sheet music example, track 22


The acoustics of Hagia Sophia

Hagia Sophia

The Hagia Sophia (Greek for “Holy Wisdom”) was a Greek Orthodox cathedral from 537 to 1453. When the Ottoman Empire conquered Constantinople the church was converted into a mosque. Then in 1935 it was converted into a museum.

No musical performances are allowed in the Hagia Sophia. However, researchers from Stanford have modeled the acoustics of the space in order to simulate what worship would have sounded like when it was a medieval cathedral. The researchers recorded a virtual performance by synthesizing the acoustics of the building. Not only did they post-process the sound to give the singers the sound of being in the Hagia Sophia, they first gave the singers real-time feedback so they would sing as if they were there.

Related posts

Mathematics of Deep Note

THX deepnote logo score

I just finished listening to the latest episode of Twenty Thousand Hertz, the story behind “Deep Note,” the THX logo sound.

There are a couple mathematical details of the sound that I’d like to explore here: random number generation, and especially Pythagorean tuning.

Random number generation

First is that part of the construction of the sound depended on a random number generator. The voices start in a random configuration and slowly reach the target D major chord at the end.

Apparently the random number generator was not seeded in a reproducible way. This was only mentioned toward the end of the show, and a teaser implies that they’ll go more into this in the next episode.

Pythagorean tuning

The other thing to mention is that the final chord is based on Pythagorean tuning, not the more familiar equal temperament.

The lowest note in the final chord is D1. (Here’s an explanation of musical pitch notation.) The other notes are D2, A2, D3, A3, D4, A4, D5, A5, D6, and F#6.


Octave frequencies are a ratio of 2:1, so if D1 is tuned to 36 Hz, then D2 is 72 Hz, D3 is 144 Hz, D4 is 288 Hz, D5 is 576 Hz, and D6 is 1152 Hz.


In Pythagorean tuning, fifths are in a ratio of 3:2. In equal temperament, a fifth is a ratio of 27/12 or 1.4983 [1], a little less than 3/2. So Pythagorean fifths are slightly bigger than equal temperament fifths. (I explain all this here.)

If D2 is 72 Hz, then A2 is 108 Hz. It follows that A3 would be 216 Hz, A4 would be 432 Hz (flatter than the famous A 440), and A5 would be 864 Hz.

Major thirds

The F#6 on top is the most interesting note. Pythagorean tuning is based on fifths being a ratio of 3:2, so how do you get the major third interval for the highest note? By going up by fifths 4 times from D4, i.e. D4 -> A4 -> E5 -> B5 -> F#6.

The frequency of F#6 would be 81/16 of the frequency of D4, or 1458 Hz.

The F#6 on top has a frequency 81/64 that of the D# below it. A Pythagorean major third is a ratio of 81/64 = 1.2656, whereas an equal temperament major third is f 24/12 or 1.2599 [2]. Pythagorean tuning makes more of a difference to thirds than it does to fifths.

A Pythagorean major third is sharper than a major third in equal temperament. Some describe Pythagorean major chords as brighter or sweeter than equal temperament chords. That the effect the composer was going for and why he chose Pythagorean tuning.


Then after specifying the exact pitches for each note, the composer actually changed the pitches of the highest voices a little to make the chord sound fuller. This makes the three voices on each of the highest notes sound like three voices, not just one voice. Also, the chord shimmers a little bit because the random effects from the beginning of Deep Note never completely stop, they are just diminished over time.

Related posts


[1] The exponent is 7/12 because a half step is 1/12 of an octave, and a fifth is 7 half steps.

[2] The exponent is 4/12 because a major third is 4 half steps.

Musical score above via THX Ltd on Twitter.

How many musical scales are there?

How many musical scales are there? That’s not a simple question. It depends on how you define “scale.”

For this post, I’ll only consider scales starting on C. That is, I’ll only consider changing the intervals between notes, not changing the starting note. Also, I’ll only consider subsets of the common chromatic scale; this post won’t get into dividing the octave into more or less than 12 intervals.

First of all we have the major scale — C D E F G A B C — and the “natural” minor scale: A B C D E F G A. The word “natural” suggests there are other minor scales. More on that later.

Then we have the classical modes: Dorian, Phrygian, Lydian, Mixolydian, Aeolian, and Locrian. These have the same intervals as taking the notes of the C major scale and starting on D, E, F, G, A, and B respectively. For example, Dorian has the same intervals as D E F G A B C D. Since we said we’d start everything on C, the Dorian mode would be C D E♭ F G A B♭ C. The Aeloian mode is the same as the natural minor scale.

The harmonic minor scale adds a new wrinkle: C D E♭ F G A♭ B C. Notice that A♭ and B are three half steps apart. In all the scales above, notes were either a half step or a whole step apart. Do we want to consider scales that have such large intervals? It seems desirable to include the harmonic minor scale. But what about this: C E♭ G♭ A C. Is that a scale? Most musicians would think of that as a chord or arpeggio rather than a scale. (It’s a diminished seventh chord. And it would be more common to write the A as a B♭♭.)

We might try to put some restriction on the definition of a scale so that the harmonic minor scale is included and the diminished seventh arpeggio is excluded. Here’s what I settled on. For the purposes of this post, I’ll say that a scale is an ascending sequence of eight notes with two restrictions: the first and last are an octave apart, and no two consecutive notes are more than three half steps apart. This will include modes mentioned above, and the harmonic minor scale, but will exclude the diminished seventh arpeggio. (It also excludes pentatonic scales, which we may or may not want to include.)

One way to enumerate all possible scales would be to start with the chromatic scale and decide which notes to keep. Write out the notes C, C♯, D, … , B, C and write a ‘1’ underneath a note if you want to keep it and a ‘0’ otherwise. We have to start and end on C, so we only need to specify which of the 11 notes in the middle we are keeping. That means we can describe any potential scale as an 11-bit binary number. That’s what I did to carry out an exhaustive search for scales with a little program.

There are 266 scales that meet the criteria listed here. I’ve listed all of them on another page. Some of these scales have names and some don’t. I’ve noted some names as shown below. I imagine there are others that have names that I have not labeled. I’d appreciate your help filling these in.

| Scale number | Notes                 | Name              |
|          693 | C D  E  F# G  A  B  C | Lydian mode       |
|          725 | C D  E  F  G  A  B  C | Major             |
|          726 | C D  E  F  G  A  Bb C | Mixolydian mode   |
|          825 | C D  Eb F# G  Ab B  C | Hungarian minor   |
|          826 | C D  Eb F# G  Ab Bb C | Ukrainian Dorian  |
|          854 | C D  Eb F  G  A  Bb C | Dorian mode       |
|          858 | C D  Eb F  G  Ab Bb C | Natural minor     |
|         1235 | C Db E  F  G  Ab B  C | Double harmonic   |
|         1242 | C Db E  F  G  Ab Bb C | Phrygian dominant |
|         1257 | C Db E  F  Gb Ab B  C | Persian           |
|         1370 | C Db Eb F  G  Ab Bb C | Phrygian mode     |
|         1386 | C Db Eb F  Gb Ab Bb C | Locrian mode      |

Update: See this page for Pete White’s free ebook listing all possible scales with 3 to 11 notes.

More music and acoustics posts