Signal Features - Chroma Features

Chroma Features

Chroma features, also known as chromagrams, are a special type of feature designed specifically for music analysis. They represent the spectral energy in terms of the 12 musical semitones (pitch classes): C, C#, D, D#, E, F, F#, G, G#, A, A#, B. The key idea is that chroma features are independent of octave — they sum the energy across all octaves for each semitone.

This octave-invariance is what makes chroma features so useful. A C note played on a piano, a C note on a guitar, and a C note sung by a voice will all contribute to the same chroma bin, regardless of which octave they are in. This allows chroma features to capture the harmonic content and tonal structure of music without being distracted by octave changes, instrumentation, or timbre.

How Chroma Features Are Computed

The computation of chroma features involves the following steps:

  1. Compute the magnitude spectrum of the signal using a windowed FFT.
  2. Map each frequency bin to its corresponding musical pitch. The reference frequency for middle A (A4) is 440 Hz. The frequency of a note with pitch class m (0 to 11, where 0 = C) and octave o is given by:
\[ f(m, o) = 440 \cdot 2^{(m - 9)/12} \cdot 2^{o - 4} \]

where m is the pitch class (0 to 11), o is the octave number, and the exponent (m - 9)/12 accounts for the fact that A corresponds to m = 9.

  1. For each pitch class c (0 to 11), sum the energy of all frequency bins that fall within the frequency range of that pitch class across all octaves. Typically, the range is limited to a certain frequency band (e.g., 50 Hz to 4000 Hz) to cover the most musically relevant range.
  2. The result is a 12-element vector, one for each semitone. This vector can be normalized to unit length or to sum to 1, depending on the application.

In practice, the mapping is not a hard assignment but uses a weighted sum. Each frequency bin contributes to the nearest pitch class with a weight that depends on the distance in cents (a logarithmic unit for musical intervals, where 100 cents equal one semitone). This reduces aliasing and produces smoother chroma vectors.

Interpretation and Use

The chroma vector is essentially a harmonic fingerprint of the music at a given moment. A chord, for example, will activate several semitone bins simultaneously — a C major chord (C, E, G) will have strong energy at bins 0, 4, and 7. This makes chroma features directly suitable for chord recognition and harmonic analysis.

Because chroma features are robust to changes in instrumentation, dynamics, and octave, they are widely used in:

  • Chord recognition — identifying the harmonic progression of a piece.
  • Music retrieval — searching for songs by humming or by a short audio fragment (audio fingerprinting).
  • Key detection — determining the musical key of a piece.
  • Structural analysis — finding repeated sections in a song (e.g., chorus, verse).

Chroma features are typically extracted from each frame of the audio signal, producing a sequence of vectors over time. When plotted as a heatmap with time on the horizontal axis and pitch class on the vertical axis, the result is called a chromagram. Chromagrams are a powerful visualization tool for understanding the tonal content and harmonic structure of music.

Computational Considerations

The main computational cost of chroma features lies in the initial FFT and the mapping step. The mapping can be precomputed as a fixed transformation matrix that converts the FFT magnitude spectrum to the 12 chroma bins. This makes chroma extraction very fast in practice, especially when applied to short frames.

A common variant is the enhanced chroma or chroma DCT, which applies a DCT to the chroma vector to decorrelate the bins and reduce the dimensionality, similar to the MFCC approach. However, the plain 12-bin chroma vector is often sufficient for many music analysis tasks.