Getting Started
This page covers installing TSM Diff and running the bundled example.
Requirements
- Python 3.12
music21,numpy,matplotlib,verovio,pypdf, pinned inrequirements.txt- The TSM library, compiled C++ extensions included in
scripts/: - Linux x86-64:
pytsm.cpython-312-x86_64-linux-gnu.so(diff and coloured score export) - macOS:
pytsmlight.cpython-312-darwin.so(diff list only, no coloured export for now)
Installation
git clone https://gitlab.com/xiaobo-wang/tsm_diff_lbd.git cd tsm_diff_lbd pip install -r requirements.txt
Run your first comparison
From the scripts/ directory:
cd scripts python test.py
By default, test.py compares two versions of Mozart's Piano Sonata KV 281
(test/examples/K281-1.musicxml and test/examples/K281-1_01.musicxml) and prints the diff list.
On Linux, it also writes K281-1_vs_K281-1_01.html in scripts/: both scores side by side,
rendered with Verovio, with the differences coloured. Each colour is one diff category, and the
same colour on the left and right scores marks the two sides of the same difference.
To compare other scores, edit LEFT_SCORE and RIGHT_SCORE at the top of test.py.
Reading the output
Each row of the diff-list is one difference between the two scores:
| Column | Description |
|---|---|
code | The diff code |
left type / right type | Label of the TSM node on each side, e.g. Chord3, Note_F3 |
left start / right start | Position of the difference, in bars (e.g. 2+1/4 means beat 1/4 after bar 2) |
left dur / right dur | Duration of the affected interval, in bars |
l|r nodes | Number of TSM nodes involved on the left and right side |
time dist | Contribution to the time distance |
symb dist | Contribution to the surface distance |
cost | Combined weighted cost of this difference |
Diff codes, node labels, and the similarity formula (1 minus the harmonic mean of the two distances)
are all explained on the Description page.