When key detection misses, it usually misses by a fifth
We measured 185 uncertain key readings against real files. Of the 90 that missed the tonic, 54 landed exactly a fifth above. Here is what we changed.
The error has a direction, and almost nobody names it
Key detection reads the distribution of pitch classes in a piece of audio and picks the tonic that best explains it. When it is wrong, the usual explanation you will find is relative major and minor confusion: A minor and C major hold the same seven notes, so a detector can land on the wrong one of the pair.
That is real. It is also not the biggest class. In our corpus the most common failure by a wide margin is the tonic sliding up a perfect fifth, onto the dominant.
Key takeaways
- Across 185 readings where the tool could not resolve the mode, the tonic was exactly right in 95 of them, so about half.
- Of the 90 misses, 54 were a perfect fifth above the true tonic. That is 60 percent of all errors pointing the same way.
- Fourths accounted for 10 more misses. The remaining eight intervals together accounted for 26.
- We did not fix the estimator in that round. We fixed what the tool is allowed to claim when it cannot prove the tonic, which is a different and smaller promise.
- A confidence number is not the same thing as knowing which direction you are likely to be wrong in.
What was measured, and on what
The corpus is a working sample library, 1012 files at the time of the run on 14 August 2026, of which 294 carry a key in the filename and can therefore be scored against something. The measurement ran through the real estimator rather than a copy of it, which matters more than it sounds: a probe that reimplements the decision measures the reimplementation.
The interesting subset is the one where the tool reports that it cannot read the mode, meaning the third is never really sounded so major against minor is not decidable from the material. That subset is 185 files.
| reading | files | tonic exactly right |
|---|---|---|
| mode unreadable, pair shown | 185 | 95, about 51 percent |
| of those, tonic marked as standing | 16 | 12, 75 percent |
| of those, tonic not marked as standing | 169 | 83, 49 percent |
And the direction of the 90 misses:
| interval off the true tonic | cases | share of errors |
|---|---|---|
| perfect fifth, the dominant | 54 | 60 percent |
| fourth, the subdominant | 10 | 11 percent |
| the other eight intervals together | 26 | 29 percent |
Sample names make it concrete, because the filename is the ground truth here. A file labelled Cm read as G. Fm read as C. Gm read as D. Cmin read as G. Every one of them a perfect fifth up.
Why a fifth is the easy mistake to make
We measured the direction, not the cause, so treat what follows as the reading we act on rather than a second measurement.
A minor scale and the minor scale a fifth above it share six of their seven notes. C minor holds C, D, Eb, F, G, Ab and Bb; G minor holds G, A, Bb, C, D, Eb and F. To a method that weighs how much energy sits on each pitch class, those two hypotheses look almost identical, and the small remainder is exactly the material that trap and phonk tend not to play: no third sounding, no cadence, a bass part that hammers the fifth as often as the root.
Which is why the failure is systematic rather than random. It is not that the detector is noisy. It is that the second best answer is genuinely almost as good an explanation of the audio, and it sits a fifth up.
The fix was in the language, not in the guess
The field report that started this was a real session file. True key E minor. The answer that came back said the tonic was definitely B. B is the fifth of E minor, so it was not a random miss, it was this exact class, arriving with full confidence.
Two separate things had gone wrong, and only one of them is about pitch.
The tool had actually flagged its own doubt. The payload carried an uncertain flag and a confidence of 0.41. The sentence builder on the other side checked the mode flag first and never reached the low confidence branch, so a reading the analyzer had marked as weak came out of the model's mouth as a certainty. A gate that exists but is never reached is not a gate.
So the change was not a new threshold and not a new estimator. A separate signal now travels with the pair, saying whether the tonic itself stands up independently of the mode question, and that signal chooses the wording:
| tonic stands | what gets said |
|---|---|
| yes | the two candidates are named and the tonic is treated as read |
| no, or the signal is missing | the two candidates are still named, the tonic is not settled, and the systematic slip toward the dominant is stated |
The default when the signal is absent is the weak wording. That is deliberate and it costs us something: an older build that does not send the signal gets the cautious sentence for every case, including the ones where it would have been right. Saying the tonic reads without evidence is the sentence that produced that confident B, so the fallback goes the other way.
Is the distinction worth anything
A flag that changes the wording is only honest if the wording tracks reality. Split by the flag, the tonic hit rate is 75 percent when it says the tonic stands and 49 percent when it does not, which is 26 points of separation. Put the other way round: of the 90 readings that missed the tonic, 86 are marked as not standing.
The whole measurement was then reproduced on 15 August 2026 by a different chain, on a slightly larger corpus of 1016 files, with the audio side producing raw payloads and the language side scoring them, so that neither half graded its own homework. It came back at 186 pair cases, 95 hits, 16 standing with 12 right, 170 not standing with 83 right. The same 26 points, from a different tool.
The part that is not flattering
On the production path the strong branch fires on 2 of 444 cases, which is 0.45 percent. In practice the confident sentence is almost never built.
The reason is structural and we would rather publish it than let the 26 point number stand alone. The production path cross checks the filename hint. When the tonic genuinely stands and the name carries a key, the reading comes back certain and the pair is never shown at all. So the cases that reach the pair branch are, almost by definition, the ones where the tonic also fell over. On the decision that never sees the filename, the rate is 19 in 814.
Two readings of that are defensible. Either the behaviour is right and 0.45 percent simply says the evidence is rare, or the threshold behind the flag was calibrated on a path the production route already closes off, and it should be loosened. Changing a threshold is its own measurement, so it has not been touched.
What this corpus cannot tell us
The library is 292 minor labelled files against one major. Accuracy on major material is therefore not measurable here, and no claim is made about it.
Relative confusion, the one everybody already talks about, is still open at 17 cases. The fifth was the larger class and it got the round.
Questions
Is a plugin that shows a confidence number already doing this?
Not quite. Confidence says how sure the estimate is. It does not say which way the estimate tends to fall when it is unsure, and those are different pieces of information. Ours are wrong in one direction six times out of ten, so the direction is worth telling you about.
What should I do when a detector and my ears disagree?
Play the root the detector gives you and then the note a fifth below it, against the track. If the lower one feels like home, you are in the common failure case. That test costs ten seconds and resolves most of this class.
Why not just pick the more likely of the two and say it confidently?
Because being confidently wrong is more expensive than being uncertain out loud. A named tonic gets pasted into a sample search, a chord progression and a collaborator message before anyone questions it. The same argument runs through the band balance measurement, where a frequency is only named when a real resonance is there.
Does this mean key detection is unreliable?
It means it is reliable in a shape. Roughly half of the hardest cases come back with the exact tonic, and most of the rest land on a note that is musically related to it rather than somewhere arbitrary. That is workable information as long as nobody rounds it up to certainty.
The short version
When a key reading feels wrong, check the fifth below it first. When a tool tells you a key, the useful question is not how confident it is but whether it can show you what it could not hear.
Miles names both candidates and says which part of the reading is weak, because the alternative is the sentence that started this measurement. Key and chord are two of the four things it reads off the audio while your set plays; the full list is here, including what it does not read.