How much evidence a modulation needs
Assumes: Keys are neighbours, and the map is computed · Counting produced the hierarchy
The previous rung measured the distance between two keys three ways and found the three disagreeing. Every one of those measurements treats both keys as given, at once, as objects on a map.
A listener is not given both at once. A listener is given one key, then some bars, then another key, and at no point is told that anything has happened. So there is a question the map cannot answer, and it is the question a key plan quietly assumes has an answer: when does the change become detectable, and how much has to go by first?
The measurement
The machinery is the same one the modes ladder used to price a tonic: a twelve-entry histogram of how long each pitch class sounds, correlated against the major and minor probe-tone profiles rotated to each of the twelve roots, best of the twenty-four wins.
The only change is that the histogram is built from the last w bars rather than from the whole passage. That single parameter turns a summary into a running measurement, and it turns out to matter more than anything in the music.
The progression is deliberately ordinary: I–vi–IV–V–I in C, then ii–V–I–vi–ii–V–I in G. It modulates at bar six by the commonest possible route — the ii of the new key, which is A minor, which is also the vi of the old one. That chord is a pivot, and a pivot is by construction a chord belonging to both keys — which is available exactly because the two collections share six of their seven notes.
The pivot cannot be the moment
Here is the first result, and it is a matter of definition rather than of measurement.
At bar six the sounding notes are A, C and E. Every one of them is in C major. Every one of them is in G major. There is no information in the pivot chord about which key is meant — that is what makes it a pivot, and it is why it is used.
So the earliest bar at which any procedure could detect the change is bar seven, the first bar containing a note outside the old key. A modulation by pivot chord has a built-in lag of at least one bar and the lag is not a limitation of any algorithm.
What each window does
Four bars of history finds it at bar seven — the first bar in which it could — and holds G for the remaining six bars. That is the best available performance and it is achieved by a window barely longer than the pivot.
Eight bars finds it at bar nine and holds. Two bars late, because a long window is still full of C when the new key arrives; the old evidence has to age out before the new evidence can win.
Three bars never finds it. It reports C, C, A minor, A minor, C, E minor, A minor, D, B minor, E minor, E minor, D. That sequence contains the right notes throughout and never names the right key, because three bars of a diatonic progression is not enough evidence to distinguish a key from its relative minor or from its own dominant.
The two-bar reading is worth one more look, because its errors are the clearest statement of what a short window is doing. It reports C, C, A minor, G, G, C, A minor, D, G, E minor, A minor, D — — C, C, A minor, G, G, C, A minor, D, G, E minor, A minor, D, which is very nearly a list of the chords themselves, each named as the key it would be the tonic of. At a window of two bars the key-finder is a chord recogniser, and the transition from chord recognition to key recognition happens somewhere between two bars and four.
So there is an optimum and it is narrow. Too short and the reading tracks the surface: every ii–V looks like a key change, every vi looks like a relative minor. Too long and the reading is a summary that lags. The window that works is about the length of one phrase, which is a suspiciously musical answer to arrive at from a correlation.
Why a short window fails in a specific way
The three-bar reading’s errors are not random and are worth reading off.
It says A minor at bars three and four, where the chords are IV and V of C — F major and G major, whose combined notes fit A minor’s profile better than C’s over a three-bar span. It says E minor at bar six and B minor at bar nine, both of which are the relative minors of keys two steps round the circle.
Every error is a key that shares six or seven of its notes with the right answer — including the relative minor, which shares all seven. That is the previous rung’s content metric, arriving as an error pattern: a short window can only distinguish keys that differ in the notes it has heard, and neighbouring keys differ by one note that may not have gone by yet.
Neighbouring collections differ by one note, so any window that has not yet heard the note distinguishing two of them cannot tell them apart — and that note may not arrive for bars. That is the floor under everything here: the evidence a modulation needs is not merely some evidence, it is a particular note, and until it sounds the question has no answer at any threshold.
The parameter and the rate trade off against each other, and not smoothly: below four bars the threshold does not move at all, because at that rate no setting of the prior will buy a second key. The number this ladder has been tuning is therefore doing nothing over most of the range it was tuned on.
The distant modulation was supposed to be faster, and it is not
The obvious prediction is that a modulation to a distant key should be caught sooner: fewer shared notes means the new material is evidence at once. Run it and the prediction fails.
The distinguishing note does arrive earlier: F minor, the ii of E♭, contains A♭, which is not in C major, so from bar six onwards there is something in the sound that C cannot account for. And no window names E♭ any sooner than the dominant case was named G.
What the short windows do instead is the finding. At a two-bar window the readings across bars six, seven and eight are F minor, B♭ major, E♭ major — the ii, the V and the I of the new key, each named as a key of its own. The window is short enough to see that something changed and too short to see what it changed to, so it reports the chord.
Detecting that a key has ended is not the same as naming the one that replaced it, and this algorithm only ever reports the second. The evidence for “no longer C” is available in bar six; the evidence for “E♭” requires the tonic to have been heard, with weight, which is what a tonic costs and takes until bar eight.
So the lag has two components and they behave oppositely. The lag before the old key is contradicted shortens with distance — a distant key contradicts it at once. The lag before the new key is established does not, because establishing a key is a matter of dwelling on its tonic and the ii–V–I takes three bars to do that whichever key it is in.
A modulation has no instant
Put the two findings together and the conclusion is not a number but a shape.
The pivot chord is ambiguous by construction, so the change cannot be detected while it sounds. The distinguishing note may arrive one bar later or five, depending on the progression. And the reading depends on a window whose length is a free parameter with an optimum near the phrase length.
None of that leaves room for a moment at which the key changes. A boundary that has to be found rather than read off is the same situation the form ladder is in, where a section boundary is a place the local neighbourhood changes fastest rather than a line anybody drew. There is a bar after which the evidence is available, a bar at which a given procedure with a given window notices, and a stretch in between where both readings are live. A score marks the change with a key signature at a bar line; the music does not have one.
That is not a failure of analysis, and it is worth noticing that the ambiguity is a resource. Composers write pivots precisely so that the listener does not experience a jump — the smoothest modulations are between the keys that share most, which is the same fact as their being the slowest to identify — the retrospective reinterpretation, where a chord heard as vi turns out to have been ii, is one of the standard pleasures of the style. A return has to be remembered makes the same point about form: the effect lives in the difference between what was heard at the time and what is heard later.
Two quantities that were being run together
The refusal above is worth stating as a distinction, because the literature on key-finding and the ordinary language of analysis both use one word for two things.
Contradiction is the arrival of a note the old key does not contain. It is instantaneous, it is a fact about pitch content, and it is cheaper the further the new key is.
Establishment is the accumulation of enough weight on a new tonic for it to win a correlation. It takes several bars, it is a fact about duration, and it is roughly independent of how far away the new key is.
A modulation is the interval between the two, and both endpoints are computable. The dominant modulation contradicts at bar seven and establishes at bar seven, because its distinguishing note arrives in the chord that is also the new key’s dominant. The E♭ modulation contradicts at bar six and establishes at bar eight, so it has a two-bar stretch in which the passage is demonstrably not in C and not yet in E♭.
That stretch is the thing composers call a transition, and this measurement gives it a length.
What the picture cannot show
The progression is a construction. Twelve bars of roman numerals with one chord each is not a piece; it has no melody, no bass line, no rhythm and no repetition. Every one of those carries key information, and a real passage would be identified faster. The lag measured here is a property of the pitch-class content alone.
The histogram counts pitch classes, not events. A note held for a bar and a note touched in passing count the same, and the bass and the melody count the same. Weighting by metrical position and by register is known to improve key-finding substantially, and it would move all the numbers here.
And the algorithm has twenty-four templates. It cannot report no key, or both keys, or in transition — the three answers that are actually right during a modulation. Its winner is always a key, and the runner-up, which is the number that would say how ambiguous the reading is, is thrown away. The same limitation appeared when it was asked about modes: a classifier with the wrong categories does not report uncertainty, it reports the nearest category.
Nothing here measures a listener. There is a literature on how quickly listeners detect key changes and it is not consulted here; every number above is what a stated procedure does on a stated input. What the procedure establishes is a bound, and only on the contradiction half: in the dominant case no note outside C sounds before bar seven, so nothing can detect the change earlier — not this algorithm and not a listener. The establishment half is a property of the algorithm and carries no such bound.
What a better measurement would look like
The gaps above are specific enough to say what would close them, which is worth doing when a rung ends on a limitation.
Report the margin. The winner’s correlation minus the runner-up’s is a number the algorithm already computes and throws away, and the obvious expectation is that it collapses toward zero during a modulation, giving the “in transition” answer the twenty-four templates cannot. That expectation is wrong, and it is worth reporting because it was written down here before it was checked.
At the four-bar window the margins across the dominant modulation run 0.105, 0.105, 0.105, 0.093, 0.093, then 0.054 for the last four bars. There is no dip. The reading passes through the pivot and the change without the confidence moving at all, and then settles lower after the modulation than before it, because C and G go on being each other’s nearest rival for the rest of the passage. The deepest margin in the whole reading is 0.021 at bar three, where the answer is A minor and the modulation is three bars away.
The distant case is worse than no dip. Across the E♭ modulation the four-bar margins are 0.105, 0.105, 0.246, 0.079, 0.102, then 0.054 — so the margin peaks at bar six, which is the bar the new key arrives in, and the label it is confident about is C. At the eight-bar window the three largest margins in the entire run — 0.235, 0.244, 0.243 — are bars six, seven and eight, every one of them a confident reading of a key the music has already left.
The reason is not subtle once the number is on the page. A correlation margin measures how much the evidence agrees with itself, not how current the evidence is. A window holding five bars of clean C and one foreign chord is an internally consistent histogram, and consistency is what a Pearson correlation rewards. The margin is a confidence and confidence is not calibration.
There is one place the dip does appear, and it is the wrong place to take comfort from: at the three-bar window the margin reaches exactly 0.000 twice, at bars six and nine of the dominant progression. That is the window this essay has already shown never names the right key at all, so its ties are the reading failing rather than the transition showing.
Weight the histogram by position. A note on a downbeat, in the bass, held for a bar, is worth more evidence than a passing note in an inner voice. Every serious key-finder does some of this, and every one of them has to choose the weights by hand.
And run it forwards and backwards. A listener hearing bar seven does not know what bar nine will contain; an analyst does. The difference between the causal reading and the retrospective one is where the pleasure of a pivot lives, and this site has the machinery for exactly that comparison on a different subject.
None of the three is done here. What is done is the parameter sweep, which is the part that shows the answer depends on a choice nobody usually reports.
Whose music this is a claim about
The pivot modulation is a device of European tonal practice, and this whole essay presumes that a passage is in a key and then in another one. Both are strong assumptions about a specific repertoire.
The bound, though, is general in a useful way. Any music in which two collections share most of their notes will have the property that a change between them is undetectable until a distinguishing note sounds, and that the number of bars this takes depends on the progression rather than on the listener. That applies to modal writing, to a raga’s characteristic phrases, and to any music that moves between overlapping pitch sets — including the case where the collection does not move at all and only the tonic does, which is a modal shift rather than a modulation and is undetectable by this machinery in principle, since the histogram is identical.
Where it does not apply is music whose collections do not overlap. A move between two keys sharing two notes is detectable almost at once, because almost anything that sounds is evidence. The keys that are easiest to modulate to smoothly are exactly the keys whose arrival takes longest to notice, and both facts are the same fact about shared content.
The ladder from here
The map of keys has now been measured as a set of distances and as a process in time. What has not been asked is what shape the map has: whether the circle of fifths is the whole of it or a projection of something larger. The last rung of this ladder shows that among the twelve major keys the circle really is the whole thing — provably, because shared content is a function of one variable — and that a second dimension appears only when the minor keys are added.
Part 4 of 21
One essay in the series on Key-relations. 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 25.
What this makes readable
Essays that declare this one a prerequisite.
The objects named here
The third way in, after the field and the series: the things themselves, and every essay that touches each one.
ExpectationKey-findingModulationPivot chordSegmentationTonal hierarchy
- A fourth decision, and two that were never made key-finding, segmentation
- A short note is heard more in tune than it is expectation, tonal hierarchy
- An ending that can be heard coming expectation, segmentation
- Given the bar in octaves, the degree comes back key-finding, modulation
- Surprise is a number expectation, tonal hierarchy
- The bars a key is made of key-finding, modulation