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.
From MATLAB code to a published Python package
I worked with my teammates through weekly meetings, contributing to the project from code analysis and implementation to testing, examples, and publication.
- Analyze and organize: We studied the original MATLAB source and organized its functionality into four Python modules, then broke the modules down into individual functions.
- Implement and debug: I helped translate the algorithms into idiomatic Python, adapting the implementation to Python’s strengths and debugging the code.
- Test and explain: I contributed tests and worked on examples to demonstrate how the package works.
- Publish: I co-authored the project’s 2023 paper in the Journal of Open Source Software, helping communicate the package and its methods to a wider audience.
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.