Skip to content

Section and Structure

Section analysis divides a track into longer musical spans such as intro, verse, chorus, bridge, instrumental, and outro. It is a structural estimate: useful for navigation and visualization, but not a replacement for a producer's arrangement notes.

Use it to navigate a track, set loop points around a chorus, or build a structural visualization — anywhere you need an approximate map of the song's large-scale form.

For newcomers, think of section analysis as building a map of the song. It looks at large spans such as an intro, verse-like area, chorus-like area, or bridge-like area, rather than short events like individual beats or chords.

Reading a self-similarity matrix

The central tool is the self-similarity matrix (SSM). It compares every moment of a feature sequence against every other moment.

You can read it as a "which parts sound alike?" table:

Pattern in the SSMMeaning
Bright cellThese two times sound similar
Block along the diagonalA span is internally consistent, so it may be one section
Stripe away from the diagonalTwo different times sound similar, often a repeated chorus or repeated verse
From repetition to a section list
self-similarity matrixtime →a repeat, off the diagonalnoveltydetected sectionsintroABACAtime →
  • frames that sound alike
  • novelty
  • boundary
Each A section is similar to itself along the diagonal and to the other A sections off it — those off-diagonal blocks are the repetition cue. The novelty curve measures how sharply the matrix changes from one moment to the next, and its peaks are where boundaries get placed.

Two signals are especially useful:

  • Novelty means the SSM changes suddenly. It helps find boundaries.
  • Repetition means similar material appears in separate places. It helps group recurring sections.

Novelty alone tends to split too much. Repetition alone can miss one-off parts. libsonare combines both.

Boundaries first

libsonare detects section boundaries by building frame-level features, computing a self-similarity matrix, and looking for novelty peaks. The default feature mix uses MFCC and chroma, so boundaries can come from timbre changes, harmonic changes, or both.

minSectionSec (default 4 s) is not a hard floor on section length. It sets the minimum spacing between novelty peaks, and a merge pass afterwards drops only spans shorter than half of it — so the effective minimum length of a returned section is 0.5 × minSectionSec, and the leading and trailing spans are bounded by the file edges rather than by two peaks. Very short edits, drops, or pickup bars may be merged into neighboring spans.

For long-form input, the boundary detector mean-pools its feature sequence when the self-similarity matrix would exceed the native integer index cap. Boundary time values remain in the original audio timeline; on very long files, the diagnostic frame field refers to the pooled analysis grid, so UI code should place markers from time, not from frame.

Then labels

After boundaries are found, the implementation classifies each span using several clues:

ClueWhat it helps identify
Normalized energyWhether a span feels like a high-energy or low-energy section
Chroma similarity to other spansWhether the same harmonic material returns elsewhere
Vocal-likelihood descriptorWhether the span is likely to contain a lead vocal or vocal-like material

Typical outcomes are heuristic:

PatternLikely label
Repeated, high-energy, vocal-like spanChorus
Repeated, lower-energy spanVerse
Low-energy first or last spanIntro / outro
Distinctive interior span with low vocal likelihoodInstrumental
Distinctive interior span that still reads as vocalBridge

These labels are intentionally heuristic. They are good for orientation, not for declaring a canonical song form.

Why the result is an estimate

Song structure is partly subjective. Two listeners may disagree about the exact start of a chorus, and different genres use different cues. A techno track and a ballad do not announce sections in the same way.

Treat section output as a strong hint for navigation, looping, and visualization. It works best on music with clear repeated sections, and it is weaker on through-composed material (music that keeps developing instead of repeating sections), ambient, or very gradual material. A boundary being a few seconds off is normal, so automatic results are best used as a starting point for review.

How libsonare computes it

BoundaryDetector combines MFCC and chroma features, L2-normalizes them, mean-pools long inputs when needed, builds a cosine self-similarity matrix, computes a checkerboard novelty curve, and picks boundary peaks. SectionAnalyzer turns boundaries into spans, computes RMS energy, chroma descriptors, spectral flatness, and vocal-band energy, then assigns Intro, Verse, Chorus, Bridge, Instrumental, or Outro labels with confidence. The SectionType enum also carries PreChorus and Unknown, but no classifier branch produces them — treat a switch arm for either as dead code, and do not expect a pre-chorus to be detected.

Related: Mel, MFCC, and Timbre, Chroma Features, MIR Overview