Key detection is a question about which notes appear and how often, not about hearing a tonic. The file is reduced to twelve numbers, one per pitch class, and the key whose profile best matches those twelve wins.
The chromagram
Every FFT bin in the analysis band maps to the nearest semitone, and the semitone maps to one of twelve pitch classes. C2, C4, and C6 all count as C.
Two details do most of the work. Only bins that are a local maximum are counted, so the broadband energy of a snare does not add a little to all twelve classes at once. And every window is normalised before it is added, so a loud chorus and a quiet verse carry the same weight and the result does not move if you change the gain.
Relative keys share every note
C major and A minor use the same seven pitch classes. So do G major and E minor, and every other relative pair. A chromagram cannot tell them apart by content, only by weighting, which is why the two scores usually land within a few hundredths of each other.
When they do, the readout says so and names the alternative. A confident-looking percentage over a coin flip is worse than no answer.
Confidence
The figure combines two doubts: how far the winner stands above the runner-up, and how well the winner fits at all. A file that matches every key weakly is as unreliable as one where two keys tie.
Above roughly 70% the answer is worth acting on. Below 30%, read the ranked list instead of the headline.
Camelot codes
The wheel exists so a DJ can find compatible tracks without thinking in key signatures. Same number, different letter is the relative major or minor. One number up or down is a fifth away. Both blend.
The code appears next to the key name and in the copied JSON.
Where it fails
Music that changes key mid-track produces an average of the sections, which may be a key that never appears. Modal material sits between the major and minor profiles and reads as whichever is closer. Heavy distortion adds harmonics that were never played, and those harmonics land on real pitch classes.