Back to Technical Projects
Python · Music Information Retrieval

repytah

Making musical repetition visible.

Co-author · JOSS, 2023

A melody returns. A phrase repeats. A larger passage brings familiar ideas together. repytah is an open-source Python package that finds repeated patterns in sequential data and organizes them into aligned hierarchies: structural views sharing one timeline. Developed by the Smith Tinker Lab team, it connects computational analysis with the way music unfolds.

I co-authored the project’s 2023 paper in the Journal of Open Source Software.

Inside the example

Finding structure in a Chopin mazurka

The official walkthrough uses Chopin’s Mazurka, Op. 6, No. 1. It starts with features already extracted from the score, rather than reading notation directly from a PDF.

01

Compare moments

A self-dissimilarity matrix compares short sequences of features. Applying a threshold marks pairs similar enough to count as repeats.

02

Find returning passages

Diagonal lines reveal matching sequences. In this example, one 72-beat passage starts at beats 51 and 123; another 33-beat passage starts at beats 124 and 292.

03

Build the bigger picture

The pipeline groups repeats, handles overlaps, and finds essential building blocks. It then assembles repeated combinations into hierarchies aligned with the original timeline.

Colored diagonals mark repeated passages in the thresholded self-dissimilarity matrix
Repeated passages appear as diagonals.
Nine types of essential repeated components distributed along the piece’s timeline
Smaller repeated components form the building blocks.
Aligned hierarchies show repeated structures of different lengths on a shared time axis
Read horizontally to follow time. The rows show repeated structures at different scales.

The result is a map of repetition across multiple scales—not an automatic assignment of labels such as “verse” or “chorus.”

Example and figures: repytah documentation. © 2023 repytah development team, Smith Tinker Lab. ISC license.