This page maps out the structure of a piece of music — which stretches
belong together, where the section boundaries fall, and which sections are
repeats of each other. Watch for the headline trick: a section that comes
back later in the song gets the same color, even across a gap. Technically
this is the upgraded sibling of plot-segmentation — that page
stops at recurrence + agglomerative (the contiguous, bottom-up
Ward slice), while this one runs the full spectral-clustering recipe, now
that every primitive exists in pleco:
beat_track → beat-synchronous feature.chroma_stft +
feature.mfcc stack → segment.laplacianSegmentation(k)
= recurrence affinity → time-lag median filter → normalized graph Laplacian
(linalg.laplacian) → symmetric eigensolver (linalg.eigh)
→ cluster.kmeans. Its superpower over the agglomerative sibling:
a section that RETURNS later gets the SAME label even across a gap —
contiguous clustering can never express that.
Proof design (honest — there is no ground-truth boundary fixture for real audio): the synthetic 3-block control below is the hard pass/fail gate — its boundaries MUST land exactly on the planted structure [20, 40]. The real orphans-mix.wav result is the qualitative display; every badge on it asserts only what is verifiable from the output (k distinct labels, strictly-increasing internal boundaries, adjacent segments differ, bit-identical on re-run, and a genuinely recurring section). Feature rows are z-scored so the large-magnitude MFCCs and the [0,1] chroma contribute comparably (the canonical method uses CQT for recurrence and MFCC for the path separately; pleco's single-matrix API needs one balanced stack — documented divergence).