Perception and the listener

What a tonic costs in seconds

The standard key-finding algorithm cannot be run on a pitch-class set at all — a flat histogram has no variance and the correlation is undefined. Give it durations and it answers with the parent key for all seven modes identically, and it takes between 15.8 and 30.0 per cent of the total time spent on one note before it names that note instead.

Assumes: The same seven, started later · Counting produced the hierarchy

The first rung of this ladder said that a mode is the same seven notes with a different one treated as home. The scale ladder has just finished by proving that nothing about those seven notes can say which one that is: every structural property is invariant under rotation, so the set is compatible with all seven answers and prefers none.

Something has to decide, and the standard candidate is duration. This rung puts a number on it.

The price of a tonic. Every note of Dorian is given the same duration except its tonic, which is lengthened; the horizontal axis is the share of the total that goes to it. The key-finder answers with the parent key until 25.0 per cent of the time is spent on the modal tonic, and with D minor above it. At the left-hand edge every note has equal weight, which is the pitch-class set itself — and with every weight identical the correlation is not merely low but undefined, because a flat histogram has no variance to correlate with anything.
Fig. 1 The seven notes of D Dorian, every one given the same duration except D, which is lengthened. The horizontal axis is the share of the total time that goes to D; the curves are how well the sounding pitch classes fit the profiles for C major, D minor and D major. Below a quarter of the bar the answer is C.

The algorithm, and the two things wrong with running it here

Krumhansl and Schmuckler’s key-finder is four lines long. Build a twelve-entry histogram of how long each pitch class sounds. Correlate it against the measured probe-tone profile for a major key, rotated to each of the twelve roots, and against the minor profile likewise. Report the best of the twenty-four.

It is a good algorithm, it is forty years old, and it is the thing most often reached for when somebody wants a computer to say what key a passage is in — including on this site, where a later rung uses it to time a modulation. Two of its properties are usually passed over and both are load-bearing here.

It cannot be run on a set. A pitch-class set gives every member the same weight and every non-member zero, which is a perfectly good histogram. But a completely flat histogram — one in which even the non-members are equal, which is what “here are twelve pitch classes and no information about them” means — has zero variance, and Pearson’s correlation divides by the standard deviation of both vectors. The answer is not low. It is undefined. The object the whole previous ladder is about is outside this algorithm’s domain.

And it has two profiles. There is a major profile and a minor profile and there is not a Dorian one, because Krumhansl and Kessler ran the experiment on listeners who had been given a major or a minor context. So the algorithm’s twenty-four possible answers are twelve major keys and twelve minor ones, and no possible output of it is the name of a mode.

The algorithm has a major profile and a minor profile and no Dorian one, because Krumhansl and Kessler ran their experiment on listeners who had been given a major or a minor context. So its twenty-four possible answers are twelve major keys and twelve minor ones, and no possible output of it is the name of a mode. A passage in Mixolydian will be answered with a major key and a passage in Dorian with a minor one — correctly as far as the notes go, and wrongly as to which note is home.

The set answers with the parent key, seven times

Take the binary histogram — the seven notes of the C-major collection at weight one, the other five at zero — and run it. The answer is C major, at r = 0.756, with A minor second at 0.712.

Now take D Dorian. Same seven pitch classes. Same histogram. Same answer: C major at 0.756, A minor at 0.712, and so for E Phrygian, F Lydian, G Mixolydian, A Aeolian and B Locrian, because there is nothing to distinguish them.

That is the invariance result of the previous ladder arriving in a piece of working software. The algorithm does not fail on modes in some subtle way; it is given an input that contains no information about which mode is meant, and it returns the same number seven times.

The seven modes, brightest first. The same seven pitch classes started on each of its degrees in turn, ordered by how many of their notes are raised. Each row differs from the one below it by exactly one note, and that note moves down one semitone each time.
Fig. 2 The seven rotations, which are seven inputs to a musician and one input to the algorithm above. Nothing that distinguishes these rows survives the step of counting how long each pitch class sounds, because that count is the same for all seven.

The price

Now lengthen one note. Every member of the set keeps weight 1 and the candidate tonic gets 1 + w, which is the crudest possible model of “this passage dwells on its tonic” — no triad, no bass, no metre, one note held longer.

The answer flips at a computable point, and the point differs by mode.

What each mode's tonic costs. The share of a passage's total duration that has to be spent on the modal tonic before the key-finder names it rather than the parent key. Dorian 25.0 per cent, Phrygian 21.5 per cent, Lydian 22.1 per cent, Mixolydian 20.1 per cent, Aeolian 15.8 per cent, Locrian 30.0 per cent. Every note of the set is given equal weight and only the candidate tonic is lengthened, so the number is a lower bound: a real passage spends its extra time on the tonic triad rather than on one note.
Fig. 3 The share of the total duration that has to be spent on the modal tonic before the algorithm names a key rooted on it. Aeolian is cheapest at 15.8 per cent, Locrian dearest at 30.0, and the answer it gives is a major or minor key in every case.

The ordering is not arbitrary and it is worth reading off the picture. Aeolian is cheapest — 15.8 per cent — because the minor profile is one of the two the algorithm has, and A minor was already the runner-up at flat weights. Mixolydian is next at 20.1, because G major is a real key and shares six of its seven notes with C. Locrian is dearest at 30.0, because there is no B-anything key that fits this collection well: the algorithm answers B minor, which requires two notes the collection does not contain.

The one mode not on the list is Ionian, and for the obvious reason: it is the parent key, so its tonic costs nothing at all. Everything above is the price of disagreeing with the set’s own default reading, and the default reading is the major key whose shape the whole census forces.

So the price of a tonic, on this model, is between a sixth and a third of everything sounding. That is a large number, and the obvious response is that it must be an upper bound on the crudest strategy: a real passage does not lengthen one note, it lands on the tonic triad at phrase ends, puts the tonic in the bass, and arrives on it at metrically strong positions, and surely each of those is cheaper.

For this algorithm, at least one of them is dearer, and a later section computes it: emphasising the tonic triad rather than the tonic note costs between 46 and 73 per cent of the total, and for one mode no amount of it works at all. The cues that are cheap for a listener are not the cues that are cheap for a histogram, and the difference is that a listener knows which note of the triad is the root.

The two ends of the range

The cheapest and the dearest cases are worth drawing side by side, because the reason for the spread is entirely about the templates and not at all about the music.

The price of a tonic. Every note of Aeolian is given the same duration except its tonic, which is lengthened; the horizontal axis is the share of the total that goes to it. The key-finder answers with the parent key until 15.8 per cent of the time is spent on the modal tonic, and with A minor above it. At the left-hand edge every note has equal weight, which is the pitch-class set itself — and with every weight identical the correlation is not merely low but undefined, because a flat histogram has no variance to correlate with anything.
Fig. 4 A Aeolian: the same procedure with the sixth degree lengthened. The A-minor curve starts high — it was already the runner-up at flat weights, at 0.712 against C major’s 0.756 — and it crosses at 15.8 per cent, less than half what Locrian needs. Aeolian is cheap because the algorithm has a template for it.

That is the whole explanation of the ordering. Aeolian is the natural minor, and the minor template is one of the twenty-four; Mixolydian and Lydian are one note from a major key and are answered by one; Dorian is one note from a minor key. Locrian is two notes from anything, so the algorithm has to be pushed hardest before it will name a B-rooted key, and the key it then names — B minor — contains F♯ and C♯, neither of which is sounding at all.

The algorithm’s confidence in a wrong answer is highest exactly where it is furthest from a right one. B minor at 0.582 is the lowest winning correlation in the whole sweep, and nothing in the output says so unless the runner-up is inspected too.

The price of a tonic. Every note of Aeolian is given the same duration except its tonic, which is lengthened; the horizontal axis is the share of the total that goes to it. The key-finder answers with the parent key until 15.8 per cent of the time is spent on the modal tonic, and with A minor above it. At the left-hand edge every note has equal weight, which is the pitch-class set itself — and with every weight identical the correlation is not merely low but undefined, because a flat histogram has no variance to correlate with anything.
Fig. 5 The cheapest of the seven, drawn on its own. Aeolian’s tonic needs 15.8 per cent of the passage’s total duration before the finder stops answering with C major and starts answering with A minor — and above that threshold the answer is A minor, which is the parallel minor of the mode rather than the mode. Aeolian is cheapest because the minor profile is nearly its own shape already: what it has to overcome is not a wrong template but a rival root under the right one.

What it answers with

The last column of that figure is the part that matters most and is easiest to skip.

Asked about Dorian, with enough weight on the tonic, the algorithm says D minor. Asked about Mixolydian it says G major. Asked about Lydian, F major. Every one of those is the parallel major or minor of the mode in question — the right tonic and the wrong scale.

The price of a tonic. Every note of Dorian is given the same duration except its tonic, which is lengthened; the horizontal axis is the share of the total that goes to it. The key-finder answers with the parent key until 25.0 per cent of the time is spent on the modal tonic, and with D minor above it. At the left-hand edge every note has equal weight, which is the pitch-class set itself — and with every weight identical the correlation is not merely low but undefined, because a flat histogram has no variance to correlate with anything.
Fig. 6 The same curve with the other five degrees’ answers drawn alongside, which is where the pattern in the prices is. Every one of the six crosses over to the parallel major or minor of its own mode — the right tonic and the wrong scale — because the algorithm has twenty-four templates and a mode is not one of them, so the closest available answer is the nearest template and the nearest template is always the parallel key. A tool with the wrong number of categories does not report uncertainty; it reports the nearest category, confidently. That is worth carrying past this subject: the output of a classifier is not evidence that its categories are the right ones, and there is no way to tell from the output alone.

This is not a defect that a better weighting fixes. The algorithm has twenty-four templates and a mode is not one of them, so the closest available answer is the nearest template — which is exactly the parallel major or minor, because those two differ from the mode by the fewest notes. A tool with the wrong number of categories does not report uncertainty; it reports the nearest category, confidently.

That is worth carrying beyond this subject. The output of a classifier is not evidence that its categories are the right ones, and there is no way to tell from the output alone.

Duration is the only cue in this model

It is worth being clear about how little is in the model, because the number 15.8 per cent invites more weight than it can hold.

The histogram has no order in it. A passage and the same passage backwards give identical input. It has no register: a tonic in the bass and a tonic in an inner voice are the same entry. It has no metre, so a note on the downbeat and the same note on the last semiquaver of the bar count the same. And it has no harmony — the pitch classes of a chord are three separate entries and nothing records that they arrived together.

the seven, with no order and no time. The twelve semitones drawn as a cycle, with the notes of the scale filled in. The gaps between filled positions are the step pattern, and reading them round the circle is what makes the scale's asymmetry obvious.
Fig. 7 The input the algorithm actually gets, before durations are attached: seven filled positions on a circle. Everything that makes a passage a passage — its order, its metre, its bass line, its chords — has been removed before the correlation is computed.

There is a case for each omission, and it is the same case every time: the histogram was designed to be computable from a score or a MIDI file without an analysis, and every cue named above requires one. Knowing that a note is metrically strong means knowing the metre, which is itself inferred and can be inferred wrongly. Knowing that a note is supported by a triad means having segmented the texture into chords. The algorithm is cheap because it assumes nothing, and it is blunt for exactly the same reason.

Each of those omissions is a known cue. Listeners weight the first and last notes heavily, weight metrically strong positions heavily, and treat a note supported by a triad quite differently from the same note passing. Models that add them do better on real music, and adding them makes the price of a tonic fall — which is the direction the number here should be read in.

The margin, and what happens when the weighting changes

Two things were asserted about these numbers rather than checked, and one of them is wrong.

The first is the margin. Every figure above reports the winner of twenty-four correlations and none reports the second. At the flip point the two are, by construction, level — the flip is the crossing — and the numbers say how level: Mixolydian’s winner beats its runner-up by 0.0002, Dorian’s by 0.0008, Aeolian’s by 0.0024. At the price this essay quotes, the algorithm is at a coin toss, and it says so nowhere in its output.

What matters is how fast the margin opens past it, and it opens quickly. Five percentage points of extra share past the flip take Aeolian’s margin to 0.146 and Lydian’s to 0.119; ten points take Aeolian’s to 0.268. So the crossing is genuine rather than a numerical accident, and the honest way to read the quoted percentages is as the cheapest share at which the answer changes, not the share at which it is held with any conviction.

The second assertion is that the ordering of the seven modes survives a change of weighting. It does not.

mode one note lengthened the whole tonic triad lengthened
Mixolydian 20.1% 46.1%
Aeolian 15.8% 46.9%
Phrygian 21.5% 50.3%
Dorian 25.0% 52.9%
Lydian 22.1% 72.8%
Locrian 30.0% never

Aeolian and Mixolydian swap places, Lydian falls two, and Locrian stops flipping at all — no weight on B, D and F, however large, makes the algorithm name a B-rooted key. So neither half of the robustness claim holds: not the ordering, and not the existence of a crossing.

The mechanism is worth having because it is about the templates again. Lengthening a triad puts weight on three pitch classes, and two of them are not the tonic. Lydian’s F–A–C contains C, so emphasising the Lydian tonic triad also emphasises the parent key’s tonic, and the mode has to outrun evidence it is itself supplying. Locrian’s B–D–F is diminished: it puts weight on D and F, which fit D minor and F major far better than they fit anything rooted on B, so the emphasis pushes the answer away from the tonic being emphasised.

A cue that helps six modes actively hurts the seventh, and no summary statistic over the seven would have shown it.

What the picture cannot show

The profile is a measurement and it is dated. Krumhansl and Kessler’s ratings come from listeners in 1982, mostly with Western training, responding to a short context. The same caveat applies wherever this site uses the profile and it is not a small one: a listener raised on modal repertoire may well have a profile with a different shape, and there is no seven-mode version of the experiment to compare against.

The flip point is a property of this weighting, and so is the ordering. The section above shows how little survives a change to a weighting that is at least as plausible — lengthening the tonic triad rather than one pitch class. What does survive is narrower than it looks: that a crossing exists for the five modes whose tonic triad is major or minor, and that the answer when it comes is a major or minor key rather than a mode.

A winner without a margin is a ranking with no scale on it, which is the same failure as a cadence measured by distance alone. Every number quoted here is now given with its runner-up above, which is what a correlation-based tool should always report and almost never does.

Nothing here is a claim about hearing. The algorithm’s flip point is not a listener’s flip point, and no experiment reported here measures when a person starts hearing D as home. A listener needs far less than a quarter of the bar, and the honest reading of this rung is that it prices one particular cue in one particular model, which is a lower bound on how much information there is and not a measurement of how much a listener uses.

And a mode that is not a rotation of the diatonic set is outside all of it. Bhupali and Deshkar have identical pitch sets, different tonics, and a distinction that lives in which degrees are emphasised and how the line moves; the histogram machinery would give the two of them the same input and could not do otherwise.

Whose music this is a claim about

Modal European repertoire — plainchant, sixteenth-century polyphony, a great deal of folk song and most modal jazz — is precisely where this algorithm is least at home, and it is worth saying why that is a fact about the tool rather than about the music.

The tool was built to answer which of the twenty-four keys is this, on a repertoire in which that question has an answer. Applied to a Dorian tune it reports the relative or parallel minor, and every published use of it on modal material has had to add a repair: extra profiles fitted from modal corpora, or a post-processing step that reads the mode off the final. Both are admissions that the twenty-four templates are the wrong set. The second repair — read the mode off the final — is interesting because it is what the theory of the period actually did: a mode was identified by its final and its ambitus, which are facts about where a piece ends and how high it goes, and neither is in a histogram.

There is also a repertoire where the algorithm’s answer is right and its reasoning is wrong. The harmonic minor exists to give a minor key a major dominant, and the raised seventh puts a pitch class into the histogram that the natural minor does not have — so the algorithm identifies minor keys partly by the accidental that was introduced to fix a chord. It gets the key right by counting a note that is there for a completely different reason.

The interesting case is repertoire that is genuinely between the two. A great deal of sixteenth-century music is analysed as modal by one tradition and as tonal by another, and this algorithm cannot adjudicate, because it has already assumed one of the two answers in the shape of its templates.

One more thing is missing and it is not an omission so much as a boundary. The histogram is a count over a stretch of music, and it says nothing about when in that stretch the evidence arrived. A passage that establishes C for eight bars and then moves to G has one histogram; so does a passage that alternates them bar by bar. Reading a key as a running quantity rather than a summary is a different measurement with its own parameter, and it is where this machinery goes next on another ladder.

The ladder from here

The next rung stops asking what supplies a tonic and asks what a rotation has to have to be a tonic at all. One of the seven has no perfect fifth above its own first degree, which is a hard structural disqualification and not a preference — and where the set’s one tritone lands, relative to the tonic, turns out to decide most of the rest.

Part 3 of 9

One essay in the series on modes. The essays either side of this one:

What links here

Essays that reach for this one mid-argument — the half of a link its own author cannot write down, the 8 sharing most with it of 11.

The objects named here

The third way in, after the field and the series: the things themselves, and every essay that touches each one.

DurationExpectationKey-findingModeProbe-toneTonal hierarchyTonic