Key
What is a key, where does a listener's sense of home come from, and how can a machine find it?
Play four chords and then a single tone, and every listener can say how well the tone fits. Krumhansl and Kessler did that in 1982 for all twelve notes: the ratings form a hierarchy, the tonic on top, then its triad, then the scale, then the five notes outside it. The same ranking is found by counting how much of the time each note sounds in fifty-four tunes (r = 0.92), newcomers to Indian music pick up a raga's ranking from short passages, and children acquire a key over years: a key is learned statistics. In a key the seven chords have three jobs (tonic, predominant, dominant), because the chords on four and five hold every leaning note of Part 14, and four cadences punctuate phrases. A key finder correlates the notes of a piece with the profile of each of the 24 keys. With the listeners' ratings it is right 81 times in a hundred on the tunes in all twelve keys, usually missing by a fifth; with profiles counted from music, 98; "the last note" alone is right 91 times; five notes are usually enough. The best clue is the rarest interval: two notes a tritone apart lie in only two major scales, and one more note decides. The Tune uses six notes that belong to C major and F major alike, which is why the key finder wavers and why a key is a matter of weights, not of membership. Keys a fifth apart share six notes; the 24 profiles' similarities lay the keys on a torus, with relative and parallel minors beside each major key; signatures are addresses on the circle of fifths. Music leaves home by a new leading note and a pivot chord: keys a fifth apart share four triads, two fifths apart two, further none; a tonicization visits and a modulation stays. A minor key borrows a major dominant. A Dorian sea shanty is in neither mode, and the key finder says so by being wrong. In equal temperament every key is the same key, moved; the characters of keys came from unequal tunings. The frontier is whether keys are everywhere, when major and minor condensed out of the modes, and what exactly a listener stores. The Tune travels through all twelve keys and ends on a deceptive cadence.
What you need. Part 6 for temperaments; Part 12 for the scale, the line of fifths and the interval vector; Part 13 for triads, the dominant seventh and Roman numerals; Part 14 for tendency tones, phrase endings and the corpus. Correlation; Bayes's rule; a little linear algebra for the map.
- Ideas, mathematics and history
- scale-degree qualia, the probe-tone experiment, cadences, key finding, the torus of keys, modulation
- What we build, compute and hear
- a key finder scored on the Well-Tempered Clavier; a modulation's path on the torus
What you will be able to do
Foundations
- Name a key from its signature, and give its relative and parallel keys.
- Say what job each chord of a major key does, and name the four cadences by ear.
- Tell a tonicization from a modulation, and find a pivot chord between neighbouring keys.
Full course
- Find the key of a passage by correlating its notes with 24 profiles, and by Bayes's rule.
- Count the major scales that contain a set of notes, from the interval vector.
- Compute the similarity of two keys' profiles, and place the keys by multidimensional scaling.
Research
- Set out the evidence that key profiles are learned from the statistics of music.
- Say what a profile leaves out (order), and what would decide between profiles and grammars.
Practice
- Transpose a song to suit a voice, and plan the keys of a programme.
- Harmonize a tune with tonic, predominant and dominant chords.
- Move between keys smoothly, by pivot chords and by neighbours on the circle of fifths.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Foundations 25 min · Full course 35 min · Research 40 min · Practice 27 min.
- 0One tone, after four chordsFoundations3 min
- 1The note that fitsFoundations3 min
- 2Where the ranking comes fromResearch3 min
- 3Three jobsFoundations3 min
- 4Four endingsFoundations2 min
- 5Finding the keyFull course2 min
- 6How well, and how fastFull course3 min
- 7Which notes tellFull course3 min
- 8A map of keysFoundations4 min
- 9Leaving homeFoundations3 min
- 10Minor, and neitherFoundations3 min
- 11Does it matter which key?Practice2 min
- 12Frontier: is a key learned?Research3 min
- Variation 15, recap and problemsAll tracks4 min
Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.
One tone, after four chordsFoundations3 min
Here is an experiment that you can run on yourself. You will hear four chords, and then a single tone. Your only job is to say how well the tone fits with what came before: from one, not at all, to seven, perfectly. Then the same four chords, and a different tone.
Your own ratings may vary with experience and attention. The first tone sat down as if a chair had been pulled out for it. The second was wrong: not ugly in itself, the same kind of sound, but in the wrong place. When Carol Krumhansl and Edward Kessler ran this experiment in 1982, their listeners gave the first tone out of seven and the second , Related tonal-hierarchy effects also occur in untrained listeners, though ratings vary by task and musical exposure.
Think about what that means. Four chords, lasting three seconds, and your mind had already ranked all twelve notes: this one is home, these belong, those do not. That ranking is what musicians call a key. Part 14 kept running into it: about ninety-six percent of the selected Part 14 tunes ended on degree one, and other notes leaned toward it. So where is a key? It is not in any one chord, and it is not in the scale, because the same diatonic collection can support different modal tonics. This part will argue that it is in the listener, and that statistical learning contributes alongside harmonic order and context.
This is the last part of Act Two, and it gathers the others up. Scales, chords and melody all turn out to be about one thing: home. We begin with the experiment you just did, for all twelve notes. We ask where the ranking comes from. We give the chords of a key their three jobs, and learn four ways to end a phrase. We build a machine that finds the key of a tune, and ask how well it does, how fast, and from which notes. We draw a map of the twenty-four keys, and travel on it. And we end with minor keys, and with tunes that are in no key at all.
1The note that fitsFoundations3 min
How well does each of the twelve notes belong?
The method is called the probe-tone experiment. Krumhansl first tried it in 1979 with Roger Shepard, and in 1982, with Edward Kessler, she extended the method: a passage that sets up a key, then one of the twelve notes, and a rating; over and over, for every note. The tones were built with no definite octave, to reduce register cues, without eliminating every acoustic or contextual influence. Here are the average ratings after music in C major. This picture is called the key profile, and it is one of the most replicated results in the psychology of music.
Read it from the top down, and it has four levels. Highest, alone, the tonic: C. Then the other two notes of the tonic triad, G and then E. Then the remaining notes of the scale: F, A, D and B. And at the bottom, all about equal, the five notes that are not in the scale. So a key is not just a set of seven notes. It is a hierarchy: one note at the top, two under it, four under those, five outside. Every chapter of Act Two has been a view of this picture. Part 12 found the seven; Part 13 the triad; Part 14 the leaning of the rest toward it.
They ran the same experiment in minor keys. The minor profile has a related hierarchy but more than one numerical difference. The tonic is on top; then, almost as high, the minor third, E flat, and then the fifth; then the rest of the minor scale; then the notes outside it. One profile for major, one for minor, and each can be slid to start on any of the twelve notes. Twenty-four keys, from two lists of twelve numbers.
Try it on your own ear. The same four chords, three times, each followed by a different tone. Which tone fits least: A, B or C?
B. The three tones were G, C sharp and E. G and E are in the tonic triad; C sharp is outside the scale altogether, and listeners rate it lowest of all twelve. If B made you wince a little, you have a key profile in your head, whether or not you can read a note of music.
2Where the ranking comes fromResearch3 min
Why those ratings, and not some others? Here is a clue. Take the major-mode tunes in Part 14’s fifty-four-tune corpus, align their tonics with C, and measure how much of the time each of the twelve notes is sounding. Now set that beside the listeners' ratings. The tall bars are the same bars. Plot one against the other, and the correlation is . The notes that listeners say fit best are the notes that tunes use most. Krumhansl found the same thing in counts of Schubert songs and Mozart arias. The profile is a statistical summary of the music itself.
That could be a coincidence, or it could be cause and effect. An experiment in 1984 provided evidence for contributions from short-term pitch statistics. Mary Castellano, Jamshed Bharucha and Krumhansl took listeners who had never heard Indian classical music, played them short passages from ragas, and ran the probe-tone experiment in that music. The ratings these newcomers gave followed how long each note had sounded in the passage they had just heard; and they agreed closely with the ratings of listeners who had grown up with the tradition. This supports learning and adaptation, but does not exclude acoustic influences or establish that simple counting is the only mechanism. Listeners count, without knowing that they count, and a short passage is enough to begin.
You can watch the learning happen in children. Laurel Trainor and Sandra Trehub played a short melody over and over, and now and then changed one note. Infants of eight months noticed the change equally well whether the new note stayed inside the key or went outside it. Adults noticed the outside note easily, and often missed the inside one: the key hid it from them. In this one test the babies did better than their parents, consistent with different sensitivity to learned Western tonal structure in that task. In those developmental studies, sensitivity to key membership and implied harmony differed around ages five and seven. These are task-dependent group findings, not universal milestones, and formal instruction can also contribute. It is the same kind of learning as a first language, and it comes from the same thing: years of listening.
3Three jobsFoundations3 min
What do the chords of a key do?
Part 13 built a triad on every degree of the scale. In a key, those seven chords are not seven equal colours. Part 14 showed that degrees one, three and five are where melodies rest, and that two, four, six and seven lean toward them. So sort the chords by what they contain. The chord on one is all resting notes. The chord on five holds seven and two, which both lean on one: seven rises to it times in a hundred. The chord on four holds four and six, which lean on three and five. Between them, four and five carry every leaning note of the scale.
In 1893 Hugo Riemann systematized tonic, subdominant and dominant functions; the predominant label here follows later functional teaching, and they are still used. The tonic is rest. The dominant, five, is the pull back to rest; the chord on seven does the same job. The predominant, four or two, is the step away that prepares the dominant. Six and three may act as tonic substitutes, but their function is context-dependent. Seven chords, three jobs; and the usual order is rest, leave, pull, rest.
Listen to the jobs. First: one, four, five, one. Then with the chord on two doing the work of four, and a seventh on the dominant. Then with the middle two exchanged: one, five, four, one.
The first two say the same sentence in slightly different words. The third is not wrong; it is another grammar. Five falling to four is rare in Mozart, and everywhere in blues and rock. Which order sounds like home depends on which music you have counted. That will be the theme of the frontier chapter.
Now the practical use. A melody note does not tell you its chord: each note of the scale belongs to three of the seven triads. The first degree is in the chords on one, on four and on six. So to put chords under a tune, you choose by job. Start at rest; leave before the end of the phrase; pull back with the dominant; land on the tonic. Here is the Tune's first phrase alone, and then two phrases with a chord to every two beats.
Three chords, and the tune stands on a floor. Notice the end of each phrase. The first stops on the tonic chord with the fifth degree in the melody: at rest, but open. The second goes dominant, tonic, with the melody stepping down to one: closed. That is the difference between a comma and a full stop, and the next chapter gives it names.
4Four endingsFoundations2 min
How does a phrase stop?
The three jobs come to a point at the end of a phrase. A cadence is a phrase-ending harmonic and melodic event, often summarized by its last two chords. Here are four common types. Dominant to tonic: the authentic cadence, a full stop. A phrase that stops on the dominant: a half cadence, a comma, or a question. Four to one: the plagal cadence, the Amen at the end of a hymn. And the dominant going not to one but to six: the deceptive cadence. Everything promises the tonic, and the bass steps up instead of falling home. Listen to the four.
These are the punctuation of tonal music. In Part 14, phrases ended as questions until the last one answered: now those have names. A half cadence can sound like a question, and an authentic cadence like an answer; melody and phrase context also matter. And the deceptive cadence is how a composer says: not yet.
Even the full stop comes in two strengths. The chords of an authentic cadence can be the same while the melody ends on different notes of the tonic chord. Listen to the same three chords twice: first with the tune ending on the first degree, then on the third.
The first closes the door. The second leaves it ajar. This is the profile of chapter one at work in the melody: the tonic is at the top of the ranking, the third a level below, and you hear exactly that difference in how finished the ending feels. Composers save the first kind for the end of a section.
Try your ear. Three endings, in a new key. One of them is the deceptive cadence. Which: A, B or C?
B. A stopped on the dominant, in mid air: a half cadence. C came home: authentic. B did everything C did until the last chord, and then turned aside. Notice that you could hear all that in a key you were not told, on first hearing. You found the home note within a chord or two. How? That is the next chapter.
5Finding the keyFull course2 min
How could a machine find home?
If a key is a profile, then finding the key is matching. In 1990 Krumhansl published an algorithm she had worked out with Mark Schmuckler. Take a piece of music, and count how long each of the twelve notes sounds. Compare that with the profile of C major; then slide the profile up a semitone and compare with D flat major; and so on round all twelve, and the same for the twelve minor keys. Whichever of the twenty-four matches best is the answer. No rules about chords or cadences. Just: which key's habits does this music have?
Let the key finder listen to the Tune, one note at a time, and watch how sure it is of four keys. This version works with probabilities, after David Temperley, so the bars are normalized probabilities under this simplified model, not calibrated human confidence.
It got there. But look at what happened in the middle. When the second phrase began, on two long Fs, the machine believed F major, chances in a hundred, and it was not sure of C until the th note. A familiar listener may have inferred C earlier, though that is not measured by this demonstration. The reason is in the notes of the Tune. It uses C, D, E, F, G and A: six notes, and never the seventh. Those six belong to C major and to F major alike. Chapter seven comes back to that.
6How well, and how fastFull course3 min
How good is a key finder?
How good is it? Give it each of our fifty-four tunes in each of the twelve keys: tests. With Krumhansl's profile, the listeners' ratings, it finds the key times in a hundred. Most of its mistakes are one mistake: it names the key a fifth above, because the ratings give the fifth degree too much weight. Replace the ratings with profiles counted from music, as David Temperley did in 2007 from a harmony textbook's examples, and it is right times in a hundred. The corpus-derived profile performs better on this selected corpus; that does not make listener ratings wrong.
Now two methods that need no profile at all. Guess that the key is the tune's first note and that its mode is major: right times in a hundred; more of these tunes begin on the fifth degree than on the tonic. Guess that it is the last note, again guessing major: . This last-note heuristic beats the rating-profile algorithm on this corpus; it is not a comparison with human listeners. That is Part 14's finding, turned into a key finder: tunes go home to end. The catch is that you have to wait for the end.
Look at how it goes wrong, because the mistakes are informative. Of wrong answers, name the key a fifth above the true one, and name the minor key on its third degree. Those are the next-door neighbours: keys that share six of the seven notes. These recorded errors are mostly nearby alternatives in this selected test set. Its confusions are a map of which keys are alike, and chapter eight will draw that map. One more check: throw away the published profiles, and count new ones from fifty-three of our tunes to test on the fifty-fourth. Right times in a hundred. A few dozen predominantly major, mostly Western tunes support high leave-one-tune-out accuracy here. Twelve transpositions are not twelve independent tunes.
So how soon can the key be known? Give the key finder only the first few notes of each tune. With two notes it is guessing. With four it is right three times in four. With five notes, times in a hundred. After that it improves slowly: a tune tells you its key in its first breath and then spends the rest of its time confirming it. Human listeners can sometimes infer tonal centers quickly, depending on the material and task. In experiments, a few notes or a single chord are enough for most people to hear which note would be home.
7Which notes tellFull course3 min
Which notes give the key away?
Which notes carry the news? Forget profiles for a moment, and ask a simpler question: which major scales contain the notes heard so far? C and G, a perfect fifth: of the twelve major scales contain both. A fifth tells you almost nothing. C, D, E: three keys. Add F, and it is two: C major or F major. Each new note strikes some keys off the list, but common intervals strike off very few.
Now a prediction. Two notes only: B and F. How many of the twelve major scales contain both?
Two: C major and F sharp major. And one more note, any note of either scale that is not in the other, settles it. These three pitch classes uniquely select a major collection under the all-diatonic major-only assumption. They do not exclude minor modes, chromatic notes or a later change of key. The reason is in Part 12. A major scale contains six perfect fifths and only one tritone; so a fifth could be anywhere, and a tritone can be in only two places. The rarest interval is the best clue. Richmond Browne pointed this out in 1981, and it is why the dominant seventh chord of Part 13, which contains the tritone, announces its key so plainly.
Try that on the Tune. Its first note, C, is in seven major scales. G leaves six; A, four; F, three; E, two. Its last new note is D, and two keys remain: C major and F major. The Tune never plays a B, and never a B flat. Judged by its notes alone, it is in two keys at once, which is why the key finder wavered. And yet many familiar listeners hear C rather than F. So a key cannot be a matter of which notes are used. It is a matter of which notes matter: which one begins and ends, which are long, which are leapt to. A duration profile captures some of those weights, though it does not retain beginnings, endings, leaps or event order, and a list of notes does not.
8A map of keysFoundations4 min
Which keys are neighbours?
There are twelve major keys. Are some closer to each other than others? A familiar answer is the circle of fifths, illustrated by Heinichen in 1728, with earlier precedents. Put the keys round a circle, each a fifth above the last. Part 12 showed why this is the right order: move a major scale up a fifth, and exactly one note changes. So neighbours on the circle share six of their seven notes; two steps away, five; and the key on the far side shares only two. The number of sharps or flats in a key signature is simply how many steps round the circle that key is from C.
This is all a key signature is. Go one step clockwise from C, to G, and one note must be raised: F becomes F sharp. Another step, to D: C sharp as well. The sharps arrive in a fixed order: F, C, G, D, A, E, B. Under each is the key that it completes. Going the other way, the flats arrive in exactly the reverse order: B, E, A, D, G, C, F. Both rows are the line of fifths from Part 13. A signature is not a list to be memorised. It is an address: so many steps, in one direction or the other, from C. And at the bottom of the circle, six sharps and six flats name the same equal-tempered pitch-class collection on the piano: the circle closes, thanks to the equal temperament of Part 6.
Krumhansl and Kessler measured closeness another way: by how alike two keys' profiles are. If the notes that fit one key also fit the other, the keys are close. For C major, the closest key of all is A minor, with a correlation of ; then G major and F major, ; and the furthest is F sharp major, at minus : what fits one is what does not fit the other. Hear the distances. A cadence in C, and then the same cadence in each of three keys.
The first two are steps into the next room. The third is a different building: for a moment after the change, the old profile fits less well and a new tonal context can be established. A film composer who wants the floor to drop away moves by that interval.
Now put all twenty-four keys on one map, so that keys with similar profiles are close together. No low-dimensional map preserves every profile relationship exactly. Krumhansl and Kessler found that a useful toroidal organization captures much of the structure; it is not a unique exact embedding: here it is cut open and laid flat, so the left edge joins the right and the top joins the bottom. Find C major. Beside it are its relative minor, A minor, and its parallel minor, C minor; and along one line run the fifths: F, C, G. Nobody told the computation about circles of fifths, or relative keys. It was given ratings from listeners, and it drew the chart that Gottfried Weber drew by hand in 1817 from his experience of music.
9Leaving homeFoundations3 min
How does music change key?
A piece of music does not have to stay in one key. A neighboring major collection differs by one pitch class, but a new chromatic note alone does not establish modulation. G major differs from C major by a single note, F sharp. Play the dominant seventh of G, which contains that F sharp and the tritone that goes with it, and the ear is pulled toward G as it was pulled toward C: this is a dominant of the dominant. To make the move smooth, composers approach it through a chord that belongs to both keys. A, C, E is the chord on six in C major, and the chord on two in G major: a predominant there. It is called a pivot. The listener hears it in the old key; the next chord reinterprets it in the new one.
How many pivots are there? Count the triads two keys have in common. C major and G major, one fifth apart, share of their seven chords. C and D, two fifths apart, share . Three fifths apart, and beyond: none at all. So moving to a neighbouring key is easy, and there are several doors. These major collections lack a shared diatonic triad beyond two fifth-steps; direct modulation is still possible without a common chord. Composers who wanted distant keys had to go by way of the keys between, or invent new chords to serve as doors, and Part 19, on chromatic harmony, is the story of those inventions.
An ear question. Two phrases that begin in C major. Both use the dominant of G. In one, the music comes back; in the other it moves house, and stays. Which is the one that moves: A or B?
B. In A, the dominant of G led to a G chord, and then G turned back into the dominant of C and went home: the new key was visited, for one chord. Musicians call that a tonicization. In B, after the same visit came a full cadence in G: four, five, one, with the new key's own chords. That is a modulation. The difference is not in the chord that leaves. It is in whether the new key is confirmed.
Give the key finder a short memory, three chords, and let it follow both phrases. In A it says C, then G for a moment, then C again. In B it says C, then G, and stays there. A local key estimate can change, while a piece may also retain a larger-scale home key. It is a running estimate, held over the last few seconds, and music is written to move it.
10Minor, and neitherFoundations3 min
What about the other twelve keys?
Every major key has two minor keys close to it, and they are close in different ways. Here is the Tune's first phrase in C major; then in C minor, the parallel key, with the same home note; then in A minor, the relative key, with the same natural-minor pitch collection.
The parallel minor changes three notes of the seven and keeps the home: the same place, in different weather. The relative minor keeps every note and changes the home: the same notes, seen from somewhere else. On Krumhansl's map both sit beside C major, on different sides. And it is the relative minor that key finders confuse with the major, because a list of notes cannot tell them apart; only the weights can.
A minor key has a problem that Part 12 met in melody, and here it is in harmony. The natural minor scale has no leading note: its seventh degree is a whole tone below the tonic. So its chord on five is a minor triad, without the raised leading note; it can still support a modal cadence. Listen to a cadence in A minor with that chord; and then with its third raised a semitone, so that the dominant is major.
The first drifts home. The second is pulled. That one borrowed note, G sharp in A minor, is why the minor scale has its harmonic form, and it is the surest sign by which you, and a key finder, can tell A minor from C major: a note that C major does not have, pointing at A.
And some tunes are in neither. The sea shanty Drunken Sailor has D for its home and the notes of the C major scale: the Dorian mode of Part 12. Ask the key finder, which knows only major and minor, and it gives a wrong answer with little confidence. The tune has a perfectly clear home; it is just not a home that the machine was taught. Pentatonic tunes are the opposite case. Amazing Grace uses five notes, with no fourth degree, no seventh, and so no tritone: the best clue is missing. Yet the key finder gets it right, from the weights alone. Major and minor are not the only ways to organize a tonal center. They are the two that many European tonal practices increasingly emphasized over a gradual and uneven historical transition, out of the older modes.
11Does it matter which key?Practice2 min
Is D major different from C major?
People have long said that keys have characters: D major is bright and martial, F major pastoral, D minor grave. Is that true? Here is one cadence in C major, and then in D flat major, five fifth-steps away on the circle; F sharp is six steps away.
The second is a semitone higher. The equal-tempered interval pattern is unchanged, though register and instrument response can differ: every interval, every chord, every leaning note is the same. Played a day apart, very few listeners could say which was which. Part 14 said it of melody, and it holds for harmony: a key is a pattern of relations, and in equal temperament the pattern is identical in all twelve places. Yet memory is better than that suggests. When Daniel Levitin asked people in 1994 to sing a favourite recorded song from memory, most of them started within a tone or two of the record.
So where did the characters come from? Partly from instruments: a violin's open strings ring in D and A, and trumpets were built in D. And partly from tuning. Before equal temperament, keyboards were tuned so that the common keys were sweeter than the rare ones. In Werckmeister's temperament, from Part 6, the major third on C is cents, nearly pure; the third on F sharp is , a wide Pythagorean third, with perceived acceptability depending on timbre and context. Every key had its own mixture of calm and edge, and a composer of 1720 could choose a key for its colour. Modern equal temperament removes those systematic interval-size differences. Register, instrument resonances, playing technique, absolute-pitch memory and associations can still affect key character.
12Frontier: is a key learned?Research3 min
Where do keys come from, and are they everywhere?
Is the key a fact about music, or about European music? The probe-tone experiment has been taken round the world. In north Indian music, as we saw, listeners' ratings follow the notes of the raga. In Bali, in 1984, Edward Kessler, Christa Hansen and Roger Shepard tested villagers and American students on Western and Balinese scales, and each group heard the other's music partly through its own. In 2000 Krumhansl and Finnish colleagues tested expectations for Sami yoiks, a style with large leaps: Western listeners expected by Western habits, and Sami listeners did not. So the general finding is this. Some notes being more central than others is found in many studied traditions, without establishing a universal rule. Which notes, and in what order, is learned from what a listener hears.
If keys are learned from music, then they have a history, and it can be read from scores. In 2014 Joshua Albrecht and David Huron counted the notes in hundreds of pieces written between 1400 and 1750, fifty years at a time. The early music is spread over several modes, each with its own profile. Through the seventeenth century the profiles gather into two, and by 1700 they are the major and minor profiles of this part. The selected score corpus shows a gradual consolidation of major/minor pitch distributions, not one invention date or a complete history of tonality, and the listeners' ratings of 1982 are a fossil of that process.
And it has not stopped changing. In rock and pop, as Trevor de Clercq and David Temperley showed from a corpus of a hundred songs, the chord on four is as common as the chord on five, the flattened seventh is everywhere, and the progression five to four, rare in Mozart, is ordinary. Key finders tuned on classical music lose their way in it, and for a song that loops four chords, which of them is home can be a matter of opinion. So the open question is what exactly a listener learns. A profile of twelve numbers explains a great deal: this whole part. But it has no order in it, and chapter three showed that order matters. Whether a key is stored as counts of notes, as a grammar of chords, or as both, is not settled.
Variation 15, recap and problemsAll tracks4 min
Every part ends by doing something to the Tune with what it has built. This part built keys, and a way to move between them. So the Tune will travel. Two phrases at home in C; then each phrase a fifth lower than the last, all the way round the circle: F, B flat, E flat, and on through the flats and back through the sharps, until it reaches C again. Each phrase ends by turning its own home chord into the dominant seventh of the next key. And at the very end, where everything promises the tonic, listen for what it does. The key finder will follow along, and say where it thinks we are.
Row fifteen of the ledger. seconds. The measurement: the key finder named the key of of the phrases, though each lasted only a few seconds. And the ending was the deceptive cadence of chapter four: the dominant of C, and then, where C should have been, A minor. After twelve keys, the Tune came all the way home and did not go in.
What did we find? A key is a ranking of all twelve notes: the tonic, then its triad, then the scale, then the rest. That ranking matches how often notes occur in music, and listeners learn it by listening. In a key, chords have three jobs, rest, leave and pull back, and four cadences punctuate the phrases. A key finder that simply counts is right times in a hundred on our tunes, and needs about five notes. A tritone sharply narrows candidate major collections; context determines tonic and mode; the Tune has none, and gets by on weights. And the twenty-four profile relationships admit a useful approximate torus map, where music travels by pivot chords and new leading notes.
Five problems. One to compute, one to prove, one for your ears, one to build, and a research problem, marked with a star. Solutions are in this part's notes. Pause here.
Where does this come back? Act Three begins at once, with two melodies in one key, and then four. Chromatic harmony is the art of reaching far keys quickly. Musical form, a whole sonata, is a journey away from the home key and back. The torus returns as geometry. And finding the key of a recording, not a score, is a standard task for the machines of the last act.
And in practice. A singer moves a song to the key that suits the voice, and every note keeps its job. A songwriter lifts the last chorus up a step, or goes to the relative minor for the bridge. A DJ mixes tracks whose keys are neighbours on the circle of fifths, so that the join does not jar. And an arranger plans the keys of a whole programme, so that each song arrives as a fresh room.
The books and papers this part follows. The full list, with notes, is in the README.
That is the end of Act Two. We have notes, written down; rhythm; scales; chords; melody; and a home for all of them. One thing we have not yet done is a central practice in the contrapuntal repertoire studied next: two melodies at the same time, each a good tune, and both making sense together. When do two lines stay two, and when do they melt into one? Act Three begins there. Part 16: Two Voices.
Where it goes next. Act III begins: two voices in Part 16, four in Part 17, progressions in Part 18, distant keys quickly in Part 19. Form as a journey between keys is Part 21. The torus returns as geometry in Part 32, and finding the key of a recording in Part 62.
Key results
The part's results in one place, for revision.
Try it
Lab 15 · Keys, found and mapped
Work out key signatures and the notes two keys share, count how many major scales contain a pair of notes, find the key of every tune in the corpus with profiles learnt from the others, and name cadences by ear.
python -m videos.music.labs 15
needs numpy, scipy, matplotlib · download lab15.py ·
source on GitHubfour sharps E major; relative minor C♯ minor (7 notes shared)
three flats E♭ major; parallel minor E♭ minor (4 notes shared)
E major and E flat major 5 steps apart on the circle of fifths; 2 notes shared
a major scale's interval vector 2 5 4 3 6 1
major scales containing a pair of notes, by interval class 1: 2; 2: 5; 3: 4; 4: 3; 5: 6; 6: 2
the pair B, F C major, F♯ major
keys found (learnt profiles, all notes) 612 of 648 (94 in a hundred)
tunes misread (written with C as home) We Wish You a Merry Christmas: A minor; Aura Lee: A minor; Alle meine Entchen: D minor
profile counted from the corpus against the listeners' ratings r = 0.92
C major's nearest keys, by profile A minor 0.65; G major 0.59; F major 0.59; E minor 0.54; C minor 0.51
ear problem, the eight cadences (listen first) deceptive; plagal; half; authentic; authentic; plagal; plagal; deceptive
A key is a ranking of the twelve notes that matches how often they occur; a key finder that counts needs about five notes; the rarest interval of the scale is its best clue; and keys that share notes and chords lie side by side on a torus.
The code (111 lines; it asserts its own result)
"""Lab 15: key signatures and relations, a counting proof about rare intervals, a key finder with learnt profiles, and cadences by ear."""
from itertools import combinations
import numpy as np
from videos.coursekit import labs
from explainer.music.monochord import Clip, concat
from explainer.music.monochord import chords as CH
from explainer.music.monochord import key as K
from explainer.music.monochord import melody as M
from explainer.music.monochord import scales as S
from explainer.music.monochord.partkit import organ_tone
TITLE = "Keys, found and mapped"
GOAL = ("Work out key signatures and the notes two keys share, count how many major scales contain a pair of notes, find "
"the key of every tune in the corpus with profiles learnt from the others, and name cadences by ear.")
TASKS = [
"Set NOTES to 3, 5 and 8. How many notes does the key finder need before it is right four times in five? Which tunes does it still misread with all of their notes?",
"Set PROFILES to 'ratings'. Which wrong key does it name most often, and where is that key on the circle of fifths?",
"Set PAIR to (0, 7), (0, 4) and (11, 5). Check the count against the interval vector, and explain the factor of two for the tritone.",
]
NOTES = None # how many notes of each tune the key finder hears (None: all of them)
PROFILES = "learnt" # "learnt" (from the other tunes), "counts" (Temperley 2007) or "ratings" (Krumhansl and Kessler 1982)
PAIR = (11, 5) # two pitch classes: B and F
SR = 48_000
CADENCES = {"authentic": [(5, "major"), (7, "7"), (0, "major")], "half": [(0, "major"), (5, "major"), (7, "major")], "plagal": [(0, "major"), (5, "major"), (0, "major")],
"deceptive": [(5, "major"), (7, "7"), (9, "minor")]}
def run(seed=0):
rng = np.random.default_rng(seed)
lab = labs.Lab()
corpus = M.corpus()
# 1. Problem 1: signatures and relations
e, eb = (4, "major"), (3, "major")
lab.row("four sharps", f"{K.key_name(e)}; relative minor {K.key_name(K.relative(e))} ({K.shared_notes(e, K.relative(e))} notes shared)")
lab.row("three flats", f"{K.key_name(eb)}; parallel minor {K.key_name(K.parallel(eb))} ({K.shared_notes(eb, K.parallel(eb))} notes shared)")
lab.row("E major and E flat major", f"{K.fifths_apart(e, eb)} steps apart on the circle of fifths; {K.shared_notes(e, eb)} notes shared")
assert K.signature(e) == 4 and K.signature(eb) == -3
# 2. Problem 2: a pair of notes lies in as many major scales as its interval class occurs in one
vec = S.interval_vector(K.MAJOR_SCALE)
counts = {}
for a, b in combinations(range(12), 2):
ic = min((b - a) % 12, (a - b) % 12)
counts.setdefault(ic, set()).add(len(K.keys_containing([a, b])))
lab.row("a major scale's interval vector", " ".join(str(v) for v in vec))
lab.row("major scales containing a pair of notes, by interval class", "; ".join(f"{ic}: {sorted(c)[0]}" for ic, c in sorted(counts.items())))
lab.row(f"the pair {K.NAMES_FLAT[PAIR[0]]}, {K.NAMES_FLAT[PAIR[1]]}", ", ".join(K.key_name(k) for k in K.keys_containing(PAIR)))
assert all(len(c) == 1 for c in counts.values()) and [sorted(counts[ic])[0] for ic in range(1, 7)] == [2, 5, 4, 3, 6, 2]
# 3. Problem 4: the key of every tune, in every transposition
wrong, right, total = {}, 0, 0
for i, m in enumerate(corpus):
prof = {"learnt": K.learn_profiles(corpus[:i] + corpus[i + 1:]), "counts": (K.TEMPERLEY_MAJOR, K.TEMPERLEY_MINOR), "ratings": (K.KK_MAJOR, K.KK_MINOR)}[PROFILES]
p, b = (m.pitches, m.beats) if NOTES is None else (m.pitches[:NOTES], m.beats[:NOTES])
for tr in range(12):
got = K.find_key(K.distribution([x + tr for x in p], b), prof) if PROFILES == "ratings" else K.bayes_key([x + tr for x in p], b, prof)
total += 1
if got == (tr, m.mode):
right += 1
elif tr == 0:
wrong[m.name] = K.key_name(got)
lab.row(f"keys found ({PROFILES} profiles, {'all' if NOTES is None else NOTES} notes)", f"{right} of {total} ({100 * right / total:.0f} in a hundred)")
lab.row("tunes misread (written with C as home)", "; ".join(f"{n}: {k}" for n, k in wrong.items()) or "none")
maj, _ = K.learn_profiles(corpus)
lab.row("profile counted from the corpus against the listeners' ratings", f"r = {np.corrcoef(maj, K.KK_MAJOR)[0, 1]:.2f}")
lab.row("C major's nearest keys, by profile", "; ".join(f"{K.key_name(k)} {r:.2f}" for k, r in K.nearest_keys((0, 'major'), top=5)))
# 4. Problem 3, for the ear: eight cadences
answers, clips = [], []
for _ in range(8):
name = list(CADENCES)[int(rng.integers(0, 4))]
tonic = int(rng.integers(55, 66))
y, t, cur = np.zeros(int(4.2 * SR)), 0.0, None
for off, kind in CADENCES[name]:
pcs = [(tonic + off + h) % 12 for h in CH.offsets(kind)]
cur = tuple(sorted(60 + ((p - 60) % 12) for p in pcs[:3])) if cur is None else CH.nearest_voicing(cur, pcs[:3] if len(pcs) == 3 else pcs[1:], low=55, high=74)
notes = [36 + (tonic + off) % 12 + (12 if (tonic + off) % 12 < 5 else 0)] + list(cur)
tone = sum(organ_tone(CH.hz(n), 1.5 if t > 1.5 else 0.95, partials=6, rolloff=0.7, decay=1.5) for n in notes)
i = int(t * SR)
y[i:i + len(tone)] += tone[: len(y) - i]
t += 0.95
clips.append(Clip(y, SR).fade(0.01, 0.2).at_level(-20.0))
answers.append(name)
lab.audio = concat(clips, gap=0.9)
lab.row("ear problem, the eight cadences (listen first)", "; ".join(answers))
fig, (a, b) = labs.figure(2)
x = np.arange(12)
a.bar(x - 0.2, K.KK_MAJOR / K.KK_MAJOR.sum(), width=0.4, color=labs.GOLD, label="listeners' ratings (1982)")
a.bar(x + 0.2, maj / maj.sum(), width=0.4, color="#888", label="time on each note, 54 tunes")
a.set_xticks(x)
a.set_xticklabels(K.NAMES_FLAT)
a.set_title("A key's profile, asked and counted")
a.legend(frameon=False)
t = K.torus()["angles"]
for k, (th, ph) in t.items():
b.text(th, ph, K.key_name(k, short=True), ha="center", va="center", color=labs.GOLD if k[1] == "major" else "#7DD3FC", fontsize=11)
b.set_xlim(-0.05, 1.05)
b.set_ylim(-0.05, 1.05)
b.set_title("The 24 keys on Krumhansl and Kessler's torus, laid flat")
b.set_xlabel("first angle (the circle of fifths)")
b.set_ylabel("second angle")
lab.fig = fig
lab.note = ("A key is a ranking of the twelve notes that matches how often they occur; a key finder that counts needs about "
"five notes; the rarest interval of the scale is its best clue; and keys that share notes and chords lie "
"side by side on a torus.")
return lab
Now change it
- Set NOTES to 3, 5 and 8. How many notes does the key finder need before it is right four times in five? Which tunes does it still misread with all of their notes?
- Set PROFILES to 'ratings'. Which wrong key does it name most often, and where is that key on the circle of fifths?
- Set PAIR to (0, 7), (0, 4) and (11, 5). Check the count against the interval vector, and explain the factor of two for the tritone.
Problems, with solutions
Try each problem before opening its solution.
-
Signatures and relations. Name the key with four sharps and its relative minor; the key with three flats and its parallel minor. How many notes does each pair share, and how many steps apart are E major and E♭ major on the circle of fifths?
Solution
Four sharps (F♯, C♯, G♯, D♯) is E major, four steps clockwise from C; its relative minor is C♯ minor, a minor third below, with the same seven notes. Three flats (B♭, E♭, A♭) is E♭ major; its parallel minor, E♭ minor, has six flats and shares four notes with it (E♭, F, A♭, B♭). E major and E♭ major are a semitone apart as notes and five steps apart on the circle (four sharps to three flats is seven steps one way, five the other): they share only two notes, G♯/A♭ and D♯/E♭.
-
Rare intervals. A major scale's interval vector is ⟨2, 5, 4, 3, 6, 1⟩. Prove that a pair of notes forming interval class k lies in exactly v_k major scales (twice that for the tritone), and so explain why the tritone is the best clue to a key.
Solution
Fix an interval class k between 1 and 5, and a pair of notes x, x + k. A major scale on tonic t contains the pair exactly when the pair (x − t, x − t + k) is one of the v_k places where that interval occurs in the scale on 0. Each of those v_k places gives one value of t, and different places give different t, so there are v_k scales. For the tritone, the pair {x, x + 6} is the same set as {x + 6, x + 12}: each of the scale's v_6 = 1 tritones can be matched to the pair in two ways, giving two scales (C and F♯ for B–F). So a fifth lies in six scales and tells you little; a semitone or a tritone lies in two. And of those, the tritone's two scales are as far apart as keys can be, so a single further note decides.
-
Ear. The lab plays eight short progressions. Name each cadence: authentic, half, plagal or deceptive.
Solution
The lab prints the answers. Listen to the bass. Falling a fifth (or rising a fourth) to a chord that sounds like home: authentic. Stopping on a chord that wants to go on: half. The bass falling a fourth to home, without a leading note: plagal. The bass stepping up one note where it should have fallen a fifth, onto a minor chord: deceptive.
-
Build. With
key.learn_profiles, count profiles from the corpus and use them inkey.bayes_key. Test each tune with profiles learnt from the others. Which tunes are still misread, and what do they have in common?Solution
The lab does this: 612 of 648, or 94 in a hundred. With C as home, three major tunes are read as minor: We Wish You a Merry Christmas and Aura Lee as A minor, Alle meine Entchen as D minor. All three spend an unusual share of their time on the sixth or second degree (long or repeated As and Ds) and little on the fifth, so their note counts look like the relative or supertonic minor. (The three minor tunes are all read correctly.) Nothing in a count of notes says which note the tune ends on, which would have settled all three.
-
★ Counts or grammar? Design an experiment to tell whether listeners store a key as counts of notes or as a grammar of chords. What would each account predict for a passage with the right notes in the wrong order?
Where the frontier is. A count model predicts that scrambling the order of a passage leaves its key, and the probe-tone ratings after it, unchanged; a grammar predicts weaker or different ratings. The evidence is mixed. West and Fryer (1990) and later Smith and Schmuckler (2004) found that random orderings of the right notes in the right proportions still produce the standard profile, which favours counts. But Butler (1989) and Brown, Butler and Jones (1994) showed that the order of the same few notes changes which tonic listeners choose (the tritone resolving one way or the other), and priming studies of chords (Bharucha and Stoeckig 1986; Tillmann and others 2000) show expectations for what comes next that no table of counts contains. Current models (Temperley 2007; Harrison and Pearce 2020 for harmony) combine both; which carries how much, and whether the answer differs by musical culture, is open.
Notes and sources
Sources
Books: C. L. Krumhansl, Cognitive Foundations of Musical Pitch (1990); D. Temperley, The Cognition of Basic Musical Structures (2001) and Music and Probability (2007); F. Lerdahl, Tonal Pitch Space (2001); H. Riemann, Vereinfachte Harmonielehre (1893); J. D. Heinichen, Der General-Bass in der Composition (1728); G. Weber, Versuch einer geordneten Theorie der Tonsetzkunst (1817–21); S. Laitz, The Complete Musician (4th ed., 2015), chs. 7–12.
Papers: C. L. Krumhansl and R. N. Shepard, "Quantification of the hierarchy of tonal functions within a diatonic context", Journal of Experimental Psychology: Human Perception and Performance 5 (1979); C. L. Krumhansl and E. J. Kessler, "Tracing the dynamic changes in perceived tonal organization in a spatial representation of musical keys", Psychological Review 89 (1982); R. Browne, "Tonal implications of the diatonic set", In Theory Only 5 (1981); M. A. Castellano, J. J. Bharucha and C. L. Krumhansl, "Tonal hierarchies in the music of North India", Journal of Experimental Psychology: General 113 (1984); E. J. Kessler, C. Hansen and R. N. Shepard, "Tonal schemata in the perception of music in Bali and in the West", Music Perception 2 (1984); L. J. Trainor and S. E. Trehub, "A comparison of infants' and adults' sensitivity to Western musical structure", JEP: HPP 18 (1992), and "Key membership and implied harmony in Western tonal music: developmental perspectives", Perception & Psychophysics 56 (1994); D. J. Levitin, "Absolute memory for musical pitch: evidence from the production of learned melodies", Perception & Psychophysics 56 (1994); C. L. Krumhansl, P. Toivanen, T. Eerola, P. Toiviainen, T. Järvinen and J. Louhivuori, "Cross-cultural music cognition: cognitive methodology applied to North Sami yoiks", Cognition 76 (2000); T. de Clercq and D. Temperley, "A corpus analysis of rock harmony", Popular Music 30 (2011); J. Albrecht and D. Huron, "A statistical approach to tracing the historical development of major and minor pitch distributions, 1400–1750", Music Perception 31 (2014).
About this partfrom its README
Part 15 of a sixty-eight-part course in music (see the series plan and
the syllabus), and the last part of Act II. Scales, chords and melody all turned out to lean on
one thing, a home note; this part is about that. It runs Krumhansl and Kessler's probe-tone experiment, shows that
a listener's ranking of the twelve notes matches how often they occur in music, gives the chords of a key their
three jobs and names the cadences, builds a key finder and scores it on the series' fifty-four tunes in all twelve
keys, asks which notes give a key away, maps the twenty-four keys, and follows music from one key to another. The
key module is Monochord's (explainer/music/monochord/key.py), the pictures are in explainer/music/keyviz.py,
and every sound is computed in compute.py. Published findings are the ones listed under Sources.
- One tone, after four chords. Four chords and then a tone with no octave, twice: one that fits (rated 6.35 out of 7 by Krumhansl and Kessler's listeners) and one that does not (2.52); a key as an expectation for all twelve notes; the plan.
- 1. The note that fits. The probe-tone method (1979, 1982) and the major profile; its four levels: the tonic, the rest of its triad, the rest of the scale, the five notes outside; the minor profile; an ear question (three probes).
- 2. Where the ranking comes from. The time on each note in the 54 tunes against the ratings: r = 0.92; Castellano, Bharucha and Krumhansl (1984): newcomers to Indian music rate by what they have just heard; Trainor and Trehub (1992, 1994): infants hear in-key and out-of-key changes alike, adults miss the in-key ones, children acquire key membership by five and harmony by seven.
- 3. Three jobs. The seven triads sorted by the resting and leaning notes they hold: the chords on four and five carry every leaning note; Riemann's tonic, predominant and dominant (1893); three progressions, heard (I–IV–V–I, I–ii–V7–I, I–V–IV–I); each degree belongs to three triads; the Tune alone and then harmonized by function, heard.
- 4. Four endings. Authentic, half, plagal and deceptive cadences, heard; one authentic cadence with the melody ending on the first degree and on the third (perfect and imperfect), heard; an ear question (which is deceptive, in another key).
- 5. Finding the key. The Krumhansl–Schmuckler algorithm: correlate the notes with 24 profiles; a probabilistic key finder listening to the Tune note by note, heard: after nine notes it believes F major (58 in a hundred), and it is sure of C major only after eleven.
- 6. How well, and how fast. 648 tests (54 tunes, 12 keys): the listeners' ratings 81 in a hundred, a probabilistic finder 96, profiles counted from music 98, "the first note" 33, "the last note" 91; the mistakes: 72 of 120 name the key a fifth above, 36 the minor key on the third degree; profiles learnt from 53 tunes and tested on the other: 94; by number of notes: five are enough for 91.
- 7. Which notes tell. Major scales containing C and G: six; C, D, E: three; a predict-pause (B and F: two; with C: one); the rarest interval is the best clue (Browne 1981); the Tune's six notes belong to C major and F major alike: a key is weights, not membership.
- 8. A map of keys. The circle of fifths (Heinichen 1728): 6, 5, 4, 3, 2, 2 notes shared; key signatures as addresses, the order of sharps and of flats; closeness as the correlation of profiles: A minor 0.65, G and F 0.59, F♯ −0.68; one cadence moved to G major, A minor and F♯ major, heard; the 24 keys on Krumhansl and Kessler's torus, computed by multidimensional scaling.
- 9. Leaving home. The dominant of the dominant; pivot chords; triads shared by keys one, two and three fifths apart: 4, 2 and 0; an ear question: a tonicization and a modulation; the key finder's reading of both.
- 10. Minor, and neither. One phrase in C major, C minor (four notes shared, the same home) and A minor (seven shared, another home), heard; the minor key's borrowed dominant, heard; a Dorian tune that the key finder misreads, and pentatonic tunes that it reads correctly.
- 11. Does it matter which key? One cadence in C and in D♭, heard: in equal temperament every key is the same key, moved; Levitin (1994): people sing remembered songs near their recorded key; Werckmeister's temperament: the third on C is 390 cents, on F♯ 408: where the characters of keys came from.
- 12. Frontier: is a key learned? Tonal hierarchies in north India, Bali and Sami yoiks; major and minor condensing out of the modes between 1400 and 1750 (Albrecht and Huron 2014); rock harmony (de Clercq and Temperley 2011). ★ research problem: what a listener stores.
- Variation 15, recap and problems. The Tune through all twelve keys, a fifth lower each phrase, each home chord turned into the next key's dominant seventh, ending on a deceptive cadence, with the key finder naming every key; the ledger; what we found; five problems; where it comes back; in practice; references; Act III.
What is computed and built
python -m videos.music.music15.compute (under a minute) fills .cache/music15/.
| Item | What it computes | Checked against |
|---|---|---|
hook, profile |
contexts and probes; the published profiles; the corpus's own | the ratings are Krumhansl and Kessler's (1982), as printed in Krumhansl (1990) |
functions |
resting and leaning notes in each triad; three progressions | Part 14's degree transitions |
cadences |
four cadences, voiced by least motion | — |
meter |
the posterior over 24 keys after each note of the Tune | — |
finder |
five key finders on 648 cases; accuracy by number of notes; leave-one-out profiles | — |
rare |
major scales containing sets of notes | the interval vector ⟨2, 5, 4, 3, 6, 1⟩ |
keymap |
correlations between key profiles; the torus by classical scaling | Krumhansl and Kessler's table: 0.651, 0.591, 0.536, 0.511, −0.683 |
modulate |
a tonicization and a modulation; a three-chord key tracker | — |
minor |
one phrase in three keys; five tunes the finder may misread | — |
more |
harmonization; two authentic cadences; near misses; shared triads; the minor dominant; Werckmeister's thirds | Part 6's tuning tables |
tune |
Variation 15 | the key finder names 14 of 14 phrases |
Monochord's keys are held against these in tests/music/test_key.py; this part's claims and clips in
tests/music/test_music15.py.
Sounds. Fourteen clips, on Part 7's piano (physical model) in twelve-tone equal temperament; the probe
tones are Shepard tones (partials in every octave under a fixed envelope), as in the experiments. There are no
recordings.
What the models are, and are not. The profiles are averages over the listeners of one laboratory in 1982 (and of Temperley's counts from the examples of one harmony textbook); they are not constants of nature, and the film says so. The corpus is Part 14's fifty-four tunes, nearly all in major keys and nearly all European or American: "r = 0.92" is a statement about those tunes. The key finders see pitch classes and durations only: no chords, no order, no metre; the probabilistic one is the simplest form of Temperley's, a multinomial over notes with a flat prior over keys. Scores on 648 "tests" count each tune twelve times, once in each key, so they measure 54 tunes, not 648. The Well-Tempered Clavier, on which the syllabus meant to score the key finder, was not available to this build (no score files or libraries offline). Function is presented as Riemann's three categories read off the leaning notes of Part 14; other accounts (scale-degree theory, Schenker's) carve harmony differently. The torus is a four-dimensional classical scaling of profile correlations; it holds 82% of the variance, not all of it. The key tracker of chapter 9 uses a window of three chords. Werckmeister III is one of many unequal temperaments. The curve in the frontier chapter is a sketch of a published finding, not data of ours.
Notes
The major/minor profile model is a useful account of tonal hierarchy, not a universal definition of key. Statistical correlations and cross-cultural adaptation support learning but do not isolate it from acoustics or context. Developmental ages are task-dependent group findings. Riemann’s tonic/subdominant/dominant theory is distinguished from the later predominant terminology used here. A cadence includes phrase context and melodic behavior. Model posteriors are not calibrated listener confidence, and algorithm scores are not human accuracy. The 648 transpositions represent 54 independent tunes at most. The first- and last-note heuristics always guess major, explaining part of their difference from tonic-ending frequency. The profile correlation uses the corpus’s major-mode subset. A unique major collection under a diatonic assumption does not prove tonic or mode. The torus is an approximate organization of profile correlations. Direct modulation does not require shared diatonic triads. Equal temperament preserves interval patterns while register and instrument response still vary; C–D-flat is five fifth-steps apart, not the opposite point of the circle.
Companion material in this repository
- Monochord's keys: profiles, key finders, the map of keys
- Pictures of keys: the circle of fifths, the torus laid flat, a meter of keys
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- Hook: four chords and a tone that fits; four chords and one that does not; the plan.
- The note that fits: the probe-tone profile and its four levels; the minor profile (an ear question).
- Where the ranking comes from: ratings against counts; a raga learned in minutes; how children acquire a key.
- Three jobs: resting and leaning notes; tonic, predominant, dominant; three progressions; the Tune harmonized.
- Four endings: authentic, half, plagal, deceptive; perfect and imperfect (an ear question).
- Finding the key: correlating with 24 profiles; the key finder hears the Tune.
- How well, and how fast: five methods on 648 tests; near misses; five notes.
- Which notes tell: scales containing a set of notes (a predict-pause); the rarest interval; the Tune's blind spot.
- A map of keys: the circle of fifths; signatures; near and far keys heard; the torus.
- Leaving home: the dominant of the dominant; pivot chords; visiting and moving (an ear question).
- Minor, and neither: parallel and relative; the borrowed dominant; a Dorian tune.
- Does it matter which key: one cadence in two keys; the characters of keys and unequal temperament.
- Frontier: hierarchies elsewhere; when major and minor began; what a listener stores.
- Variation 15: the Tune through twelve keys. Outro: problems, payoffs.
Covers: scale degrees and their qualities; tonic, dominant and predominant; cadences; the probe-tone experiment;
key finding (Krumhansl–Schmuckler, Temperley's Bayesian model); the torus of keys; relative and parallel keys;
tonicization and modulation.
Built and computed: a key finder (monochord/key.py) scored on the series' fifty-four tunes in all twelve keys
(the forty-eight preludes and fugues were not available to the build: no score files offline); the map of keys by
multidimensional scaling; a piece's path from key to key; the pictures of keys (explainer/music/keyviz.py).
Variation 15: the Tune modulating round the circle of fifths, ending on a deceptive cadence.
Frontier: tonal hierarchies in other traditions; when tonality emerged, read from corpora.
Reading: Krumhansl, Cognitive Foundations of Musical Pitch; Temperley, The Cognition of Basic Musical
Structures.
Build the film
python -m videos.music.music15.compute # the part's numbers, into .cache/music15
python tools/build.py music15 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py music15 Hook # one chapter, silent, with a contact sheet
Scenes: videos/music/music15. Setup: see the course page. Source of these notes: the README and the scenes' narration.
Build it
python -m videos.music.music15.compute # numbers and sounds (under a minute)
EXPLAINER_TTS=silent python tools/build.py music15 -q l --fps 15 # a silent-narration preview, with the sounds
python tools/qa_sound.py music15 --sync # the sound gates
python tools/dead_air.py renders/music15_480p.mp4 --sound music15 # no empty screen; no sound over a still one
python tools/lecture_length.py music15 # 30 to 60 minutes, listening included
python tools/build.py music15 # 1080p30, narrated
python -m pytest -q tests/music # Monochord against its references; this part's claims and clips
python -m videos.music.labs 15 # the lab (writes a figure and a short WAV)