Research

Segment-Based Harmonic Profiling: A More Honest Approach to Key Detection

Technical validation of per-section analysis across genre-diverse audio corpora

Published February 2026 by Parrser · parrser.com

Abstract

Standard key detection tools return a single label for an entire track. This approach — which we call full-track detection — performs reasonably well on music with stable harmonic centers but degrades significantly on complex music: modal jazz, progressive rock, metal with dynamic clean/heavy sections, neo-soul with extended harmony, and ambient or atonal electronic music. This paper presents a segment-based approach to harmonic profiling that analyzes audio in configurable time windows, detects keys per segment, and aggregates results using confidence-weighted voting. We present validation results across two corpora: a 200-track benchmark spanning rock, metal, pop, prog, and electronic; and a 22-track adversarial corpus spanning five genres specifically chosen because they challenge conventional key detection. We also introduce a harmonic stability metric that allows the engine to honestly represent ambiguous or atonal material rather than forcing a single-key label onto music that doesn't have one.

1. The Problem with Full-Track Key Detection

A song is not harmonically static. Most music — even relatively simple pop — moves between sections with different harmonic characters: a verse in one key center, a chorus that shifts, a bridge that modulates. Jazz standards are built on chord progressions that cycle through multiple key areas in a single chorus. Progressive rock songs can visit four or five distinct key centers over twelve minutes.

Full-track key detection handles none of this. The standard approach — used by Spotify's Audio Features, Mixed In Key, Tunebat, Rekordbox, and Traktor — is to analyze the entire audio signal as a single unit, extract a chroma feature vector, and map it to the closest key in a predefined template. The output is one key label.

The failure modes are predictable:

Relative key confusion. A minor key and its relative major share identical pitch class content. D Minor and F Major use exactly the same notes. A full-track chroma vector cannot distinguish between them. Published accuracy rates for Tunebat have been documented by professional DJ communities at approximately 38%, with relative key confusion as the primary failure mode.

Modulation blindness. When a song moves through multiple key centers, full-track analysis averages the chroma content across all of them. The returned key is a statistical artifact rather than a description of any actual section of the music.

Clean/heavy dynamic confusion. Distorted guitar saturates the high-frequency spectrum in ways that corrupt chroma extraction. Full-track analysis mixes the clean signal with the distorted signal, degrading accuracy in both directions.

Genre boundary failure. Academic benchmarks — most notably MIREX — are evaluated predominantly on classical and EDM corpora. Tools optimized for MIREX performance are implicitly optimized for a narrow slice of the genre spectrum.

2. The Segment-Based Approach

The core idea is straightforward: instead of analyzing an entire track as a single unit, divide it into overlapping time windows, analyze each window independently, and aggregate the results.

2.1 Segmentation

Audio is divided into segments of configurable length (default: 30 seconds) with optional overlap. Segment length involves a tradeoff: shorter segments capture more granular harmonic movement but are more susceptible to noise; longer segments are more stable but may average over genuine key changes. The 30-second default was selected through empirical testing.

2.2 Per-Segment Analysis

Each segment is analyzed independently using Essentia's KeyExtractor algorithm with the EDMA (Extended Distribution of Musical Attributes) profile. EDMA was selected over Krumhansl-Kessler and Temperley profiles through comparative testing — it demonstrates the best generalization across diverse genre content, particularly on minor-key music.

Each segment analysis returns: detected key (pitch class), detected mode (Major or Minor), and confidence score (0.0 to 1.0).

2.3 Confidence-Weighted Voting

Segment results are not simply averaged. Each segment's key/mode pair is weighted by its confidence score before contributing to the aggregate distribution. Segments with ambiguous harmonic content contribute less than segments with clear tonal centers. The output is a key distribution: a ranked list of key/mode pairs with percentage weights — the full harmonic picture, not just a single winner.

2.4 Harmonic Journey Mapping

An additional layer of analysis tracks transitions between detected keys across adjacent segments. Aggregated across a track or catalog, these transitions form a harmonic journey map — a directed graph of how the music actually moves through key space. This representation has no equivalent in any commercial key detection tool.

2.5 Harmonic Stability

A harmonic stability score is computed as the entropy-normalized concentration of the key distribution: a track that stays in one key receives a score near 1.0; a track that distributes evenly across many key centers receives a score near 0.0. Critically, this allows honest representation of music with no dominant key center. Atonal music returns low stability rather than a spurious key label.

3. Validation — Corpus 1: 200-Track General Benchmark

3.1 Methodology

The first corpus comprised 200 tracks drawn from rock, metal, pop, progressive rock, and electronic genres. Ground truth was established via Hooktheory, sheet music, and academic literature. Analysis was run in two configurations: segment mode (30-second windows, confidence-weighted voting, EDMA profile) and full-track mode (entire audio as single segment, same algorithm).

3.2 Results

Segment-based analysis outperformed full-track analysis by 45 percentage points in key match accuracy. Zero regressions were observed: for every track where segment analysis differed from full-track, segment analysis was correct. The +45% improvement figure is relative, not absolute. The zero-regression finding is arguably more significant: segment analysis is strictly superior on this corpus.

+45% MIREX improvement
200 Tracks tested
0 Regressions
5 Genres

4. Validation — Corpus 2: 22-Track Adversarial Benchmark

The second corpus was designed specifically to challenge the engine on music that standard tools handle poorly.

4.1 Genre Selection Rationale

Progressive rock (Tool, Porcupine Tree, King Crimson) — Long-form compositions with metric complexity, multiple key areas, unconventional structures. Tool's "Lateralus" uses Fibonacci-sequence time signatures.

Jazz fusion (Miles Davis, Mahavishnu Orchestra) — Modal harmony, rapid chord changes, ambiguous tonal centers. "Bitches Brew" is 27 minutes of free improvisation.

Progressive and extreme metal (Meshuggah, Gojira) — Polyrhythmic, heavily distorted, drop-tuned to the point of tonal ambiguity.

Neo-soul (D'Angelo, Hiatus Kaiyote, Thundercat) — Extended harmony, chromatic voice leading, rhythmic displacement. Nearly absent from published MIR benchmarks.

Ambient and experimental (Burial, Arca, Aphex Twin) — Full spectrum from harmonically clear (Aphex Twin's "Avril 14th") to deliberately atonal (Arca's "Piel").

4.2 Tier Structure

Tier 1 (12 tracks): High-confidence ground truth from sheet music and Hooktheory. Hard accuracy benchmarking. Tier 2 (10 tracks): Contested or multi-source ground truth. Directional validation. Tier 3 (6 tracks): Intentionally ambiguous — scored on harmonic stability, not key accuracy.

4.3 Tier 1 Results

MetricScore
Exact key match (segments)44.4% (4/9)
Top-3 distribution match66.7% (6/9)
Full-track baseline33.3% (3/9)
Relative improvement+33%
Regressions0

The 44.4% exact match rate requires context: these tracks were specifically selected because they are difficult. Tool, King Crimson, and Miles Davis are not representative of the music that existing tools are tested on.

The top-3 accuracy of 66.7% is arguably more meaningful for most use cases. If the correct key appears in the harmonic distribution, the engine has captured the harmonic character of the track.

The Proof Point: Miles Davis — "So What"

Case Study

"So What," the opening track from Kind of Blue (1959), is a modal composition with a clear A-section in D Dorian and a B-section in E♭ Dorian — one of the most documented harmonic structures in jazz education.

Full-track result: C Major (incorrect — a plausible confusion given shared pitch content of D Dorian and C Major)

Segment analysis result: D Minor (correct — the D Dorian mode center, accurately identified)

The segment analysis succeeded because the A-section is long enough and harmonically clear enough that its segments receive high confidence scores and dominate the weighted distribution. Full-track averaging dilutes this with the B-section's E♭ content, pulling the chroma center toward C.

4.4 Tier 3 Results — Harmonic Stability

TrackStabilityNotes
Arca — "Piel"0.000No tonal center detected
Burial — "Archangel"0.267Low stability; C Minor matches contested GT
Burial — "Raver"0.316Below ambiguity threshold
Meshuggah — "Rational Gaze"0.421Genuine harmonic structure in polyrhythmic metal
Miles Davis — "Bitches Brew"0.505Modal structure in apparent chaos
Meshuggah — "Bleed"0.655Drop-tuned metal has measurable stability

The Arca result is the most significant: a stability score of exactly 0.000, representing a completely flat key distribution across all twelve pitch classes. The engine detected no tonal center — which is correct. No consumer music tool returns this result; they return a spurious label instead.

The Meshuggah and "Bitches Brew" results exceeded our stability threshold — but these are findings, not failures. The engine correctly detected real harmonic structure in music that sounds chaotic. The stability scores reflect actual harmonic content, not prior assumptions about genre.

5. The Honesty Advantage

The most underappreciated aspect of the segment-based approach is not its accuracy improvement on well-defined tracks — it is its behavior on poorly-defined ones.

A conventional key detection tool presented with Arca's "Piel" will return a key. It will be wrong, but it will return one confidently. A tool that cannot represent uncertainty has no choice but to fabricate certainty.

The harmonic stability metric changes this. A tool that returns "stability: 0.000, no dominant key detected" is providing accurate information about an atonal track. It is more useful than a wrong key label. It is more honest. And for any application that needs to distinguish between tonally coherent and tonally ambiguous music — music education, sync licensing, recommendation systems — the stability score is directly actionable.

This represents a philosophical position as much as a technical one: a music analysis engine should express what it finds, including the limits of what it can find.

6. Limitations and Future Work

Segment length sensitivity. The 30-second default is appropriate for most music but not all. Adaptive segmentation — where window length is determined by detected onset density or harmonic change rate — is a natural extension.

BPM accuracy on complex material. The adversarial corpus revealed BPM accuracy of 44.4% — our weakest metric. Metric complexity degrades beat tracking significantly. Essentia's v2.2 multi-path BPM improved on v2.0 but this remains an area for development.

Catalog-scale operation. The current pipeline processes audio files individually. Catalog-scale operation requires pipeline engineering beyond the scope of this validation.

Cross-genre ground truth scarcity. Reliable ground truth for key detection is harder to obtain for complex music than the research literature acknowledges. The MIREX datasets' genre limitations are a genuine constraint on reproducible comparison.

7. Conclusion

Segment-based harmonic profiling is a strictly superior approach to full-track key detection on genre-diverse music. The evidence from two validation corpora supports the following conclusions:

Accuracy improves. On both corpora, segment analysis matched or exceeded full-track accuracy. No regressions were observed on either corpus.

Harmonic journey data is novel and useful. No existing consumer tool maps how a song moves through keys over time. This data has direct applications in music education, DJ workflow, sync licensing, and recommendation.

Honest uncertainty is valuable. The harmonic stability metric allows the engine to correctly represent ambiguous and atonal music without fabricating confidence.

The adversarial corpus matters. Tools benchmarked only on classical and EDM are not benchmarked on music that challenges them. Publishing accuracy on Tool, Meshuggah, and Miles Davis is more informative than suppressing it.

Technical Stack

Key detection: Essentia 2.1-beta5, KeyExtractor, EDMA profile · Segment analysis: Custom Python pipeline, configurable window size · BPM: Essentia v2.2 multi-path · Spectral features: Librosa · Infrastructure: Oracle Cloud ARM64, Docker, FastAPI · Ground truth: Hooktheory, sheet music archives, MIREX documentation

Also read

The Spotify API Collapse: What Actually Broke and Why →

Get in touch

Questions about this research, partnership inquiries, or interested in early access? We'd like to hear from you.

Message sent. We'll be in touch.