Skip to main content

Module key

Module key 

Source
Expand description

Key estimation by Krumhansl–Schmuckler profile correlation over an HPCP.

The Krumhansl–Kessler major/minor tonal-hierarchy profiles are correlated against the (12-bin) HPCP at all 12 rotations; the best-correlating (tonic, mode) is the proposed key.

§Proposal, with abstention (hard epistemic rule)

The K–S profiles are 12-TET-specific. This function therefore takes an explicit assumes_12tet flag and abstains (Ok(None)) when 12-TET is not asserted, when the HPCP is not 12-bin, or when the best correlation falls below min_correlation (flat / ambiguous / atonal material). It never forces a key label onto content that does not support one.

Zero-heap: rotation happens in a stack [f32; 12]; no allocation.

Structs§

KeyEstimate
A proposed key: tonic pitch class (0 = C … 11 = B), mode, and the correlation that supports it.

Functions§

estimate_key
Estimate the musical key of a 12-bin HPCP frame/profile.