repytah
Making musical repetition visible.
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.
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.
Compare moments
A self-dissimilarity matrix compares short sequences of features. Applying a threshold marks pairs similar enough to count as repeats.
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.
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.



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.