Blog

24/24 / known-key smoke

New: stronger key detection for major and minor mixes

Mix Analyzer tightened harmonic key detection after user feedback found wrong keys in two songs. The analyzer now compares major and minor key profiles and keeps inspectable top candidates.

New: stronger key detection for major and minor mixes - Mix Analyzer blog
Key detection is more useful when it can separate C major from A minor. The result is still a musical estimate, but the estimate now comes from stronger harmonic evidence.

What changed

Shipped in this update

  • Harmonic analysis now compares major and minor key profiles.
  • Minor keys can be returned directly in the analysis result.
  • Top candidates now carry mode, score, and confidence for debugging close calls.
  • A benchmark script can test known-key files before future key-detection changes ship.

The feedback was specific enough to fix

A user liked the analyzer but pointed out a real problem: two songs came back with the wrong key. That is the kind of complaint worth acting on. If the Harmonic section gets the key wrong, the rest of the musical advice starts from shaky ground.

The old path was too blunt. It looked at the strongest chroma pitch class and treated that as the key root. That can work on simple material, but it misses an obvious musical difference: C major and A minor use the same pitch classes but do not feel like the same key.

What changed in the analyzer

The active harmonic analyzer now compares the chroma result against major and minor key profiles. It still uses the audio evidence from the track, but it asks a better question: which key and mode best explain the full pitch-class pattern?

  • Major and minor profiles are scored separately.
  • Root and fifth support help break close ties.
  • The result can now return minor keys such as Am.
  • Top candidates include key, mode, score, and confidence instead of a plain string list.

This does not turn key detection into a perfect musicologist. Songs can modulate, borrow chords, sit in a mode, or avoid a clear tonic. The change makes the default estimate less naive and easier to debug.

How we tested it before shipping

We added focused unit coverage around the key detector and the Harmonic analysis output. We also added a small benchmark script for known-key audio files, so future tuning can be checked against a folder or CSV instead of one manual upload at a time.

For the first smoke test, we generated clean major and minor progressions across all 12 roots. The internal detector returned the expected key in 24 out of 24 controlled cases. That proves the new logic handles the basic major/minor split. It does not prove every real song is solved.

Why not switch everything to a heavy external engine today?

We looked at open-source key-detection tools. Essentia has a strong key extractor and is wired as an optional backend path for controlled testing. It is not part of the default web dependency set yet because production licensing, packaging, and runtime cost need to stay deliberate.

The default path stays small and inspectable. That is the right tradeoff for this release: fix the clear bug class, keep the output debuggable, and leave room to benchmark stronger engines with real songs before making them operational.

What to expect in the result

The Harmonic section should now be better at separating relative major and minor keys. If your song is clearly in A minor, the analyzer no longer has to collapse that into C only because the pitch classes overlap.

When a result still looks wrong, the best bug report is the exact song or report plus the expected key. That lets us compare the detected key, top candidates, chroma evidence, and any musical edge case instead of guessing from memory.

FAQ

Does this guarantee the correct key for every song?

No. It improves the default estimate, especially for major versus minor ambiguity, but real songs can change key or avoid one stable tonic.

Did you verify the two reported songs?

No. The exact files were not available during this fix, so we verified the detector on controlled known-key audio and added a benchmark path for real labeled songs.

Will Mix Analyzer use Essentia for key detection?

Maybe. The optional backend path is ready for testing, but the default release keeps the internal detector until licensing, packaging, and real-song benchmark results justify a switch.