𝄞 TSM Diff

A similarity measure for music scores based on Tree Score Model (TSM) DAG representations

Overview

We propose a new algorithm for comparing digital music scores in various encodings (e.g. MusicXML or MEI). It is based on an intermediate abstract representation structured as labeled directed acyclic graphs (DAGs). Inspired by rhythm trees [1], these DAGs encode the metric and rhythmic structure of a score. Given two scores, after conversion into DAGs, our procedure calculates jointly:

The two later measures are normalised and combined into a similarity distance between scores.

The DAG's nodes are labelled with basic events (notes, rests, ...) for leaves, and, for inner nodes, by operators acting on time intervals, like splitting into sub-intervals of equal duration (in a tuplet), or one bar and the remaining, or concurrent voice creation. Node sharing represents composed events such as dotted notes. This way, every node corresponds to a time interval. For more details, see Description page.

The comparison proceeds first bar-wise, aligning equal bars, then by a recursive parallel descent into sub-DAGs representing differing bars, stopping as soon as labels diverge. This yields linear time complexity and provides more explicit feedback than the ins/del/replace operations of classical edit distances, with ad-hoc difference codes associated to each pair of node labels. The exact list of codes can be adapted to use-cases.

This approach can be applied e.g. to comparative corpus studies in musicology [2], or versioning in the context of score edition or preparation of corpora.

As a proof of concept, we propose two demos based on a corpus of piano sonatas [4], and transcriptions of monophonic soli on the same jazz standard by different performers [5].

Example of a TSM Diff comparison
TSM DAG representation of a music score excerpt. The index below the graph lists the pitches of the score without rhythmic information.

Applications

Score versioning

A primary application of TSM Diff is comparing different versions of the same score, much like Git does for source code.

Comparative corpus studies

TSM Diff also supports comparative corpus studies in musicology [2], who is been applied to melodic similarity tasks.

Quantitative evaluation of MIR procedures

A key advantage is the clear independence of its sub-metrics [3], one related to timing (time distance) and one to other symbolic aspects (surface distance).

Example Output

Below is a sample diff-list output for two versions of the same piece. Each row identifies one difference: its category, the time positions in the left and right scores (expressed as a number of bars, e.g. 2+1/4 means beat 1/4 after bar 2), the duration of the change, the number of TSM nodes involved, and the two distance values.

    code   left     left    left right   right  right l|r    time symb  cost
           type     start   dur  type     start   dur  nodes  dist dist  cost
------------------------------------------------------------------------------------
0   CHORDS Chord3   2+1/4   1/4  Chord4   2+1/4   1/4  1|1     1/2    1  0.00067
1   CHORDS Chord2   2+1/4   1/4  Chord3   2+1/4   1/4  1|1     1/2    1  0.00067
2   FRAG   Note_F3  6+1/2   1/2  Div2     6+1/2   1/2  1|1       1    1  0.00123
3   CONS   Div2     8+1/4   1/8  Note_C5  8+1/4   1/8  1|1     1/4    1  0.00039
4   CONS   Div2     11+1/2  1/2  Note_Bb3 11+1/2  1/2  1|1       1    1  0.00123
5   INS                          Artic    11+1/2  1/2  0|1       0    1  0.00011
6   REP    Rest     18+3/8  1/8  Note_C5  18+3/8  1/8  1|1     1/4    1  0.00039
7   REP    Div2     93+1/2  1/4  Rest     93+1/2  1/4  1|1     1/2    1  0.00067
8   INS    Note_D6  93+3/4  3/16 Ornament193+3/4  0    1|1       0    2  0.00021
9   MULTI  Multi    106     3/8  Chord2   106     3/8  2|1     3/4    1  0.00095
10  CHORDS Chord2   107+5/8 1/8  Chord2   107+5/8 1/8  1|1     1/4    1  0.00039
similarity= 0.9931179841354437

Comparison of two versions of Mozart's Piano Sonata in B♭ major, KV 281 (K281-1 vs K281-1_01).

See the description of difference categories.

The following examples show two selected differences as they appear in the scores, with the relevant elements highlighted in yellow.

Diffs 0 & 1 — CHORDS at position 2+1/4, duration 1/4. Both the treble and bass voices have a chord at this beat that differs.

K281-1 chords at bar 2+1/4
Left — K281-1
K281-1_01 chords at bar 2+1/4
Right — K281-1_01

Diff 2 — FRAG at position 6+1/2, duration 1/2. In K281-1, a single F in the bass occupies this position. In K281-1_01, that note is fragmented into two shorter notes, F then E, covering the same total duration.

K281-1 single note at bar 6+1/2
Left — K281-1
K281-1_01 fragmented note at bar 6+1/2
Right — K281-1_01

References

  1. Agon, C., Haddad, K., & Assayag, G. (2002). Representation and rendering of rhythm structures. Proceedings of the Second International Conference on Web Delivering of Music (WEDELMUSIC), pp. 109–113. IEEE.
  2. Nachtwey, A., Moss, F. C., & Plaksin, A. V. K. (2025). Beyond Bars: Distribution of Edit Operations in Historical Prints. Music Encoding Conference 2025 (poster) arXiv:2509.12786
  3. McLeod, A., & Steedman, M. (2018). Evaluating automatic polyphonic music transcription. Proceedings of the 19th International Society for Music Information Retrieval Conference (ISMIR), pp. 42–49.
  4. Hentschel, J., Neuwirth, M., & Rohrmeier, M. (2021). The Annotated Mozart Sonatas: Score, harmony, and cadence. Transactions of the International Society for Music Information Retrieval, 4(1). https://doi.org/10.5334/tismir.63
  5. Foster, D., & Dixon, S. (2021). Filosax: A dataset of annotated jazz saxophone recordings. Proceedings of the 22nd International Society for Music Information Retrieval Conference (ISMIR).
  6. Miller, W., & Myers, E. W. (1985). A file comparison program. Software: Practice and Experience, 15(11), pp. 1025–1040. Wiley.
  7. Foscarin, F., Jacquemard, F., & Fournier-S'niehotta, R. (2019). A diff procedure for music score files. Proceedings of the 6th International Conference on Digital Libraries for Musicology (DLfM).
  8. Foscarin, F., Jacquemard, F., & Fournier-S'niehotta, R. (2019). Computation and Visualization of Differences between two XML Music Score Files. 20th International Society for Music Information Retrieval Conference (ISMIR), Late Breaking Demo.
  9. Myers, E. W. (1986). An O(ND) difference algorithm and its variations. Algorithmica, 1(1–4), pp. 251–266. Springer.
  10. Martinez-Sevilla, J. C., Cerveto-Serrano, J., Luna-Barahona, N., Chapman, G., Sapp, C., Rizo, D., & Calvo-Zaragoza, J. (2025). Sheet Music Benchmark: Standardized Optical Music Recognition Evaluation. Proceedings of the 26th International Society for Music Information Retrieval Conference (ISMIR).
  11. Cogliati, A., & Duan, Z. (2017). A Metric for Music Notation Transcription Accuracy. Proceedings of the 18th International Society for Music Information Retrieval Conference (ISMIR), pp. 407–413.
  12. Suzuki, M. (2021). Score Transformer: Generating Musical Score from Note-level Representation. ACM Multimedia Asia, pp. 1–7.
  13. Nakamura, E., Benetos, E., Yoshii, K., & Dixon, S. (2018). Towards Complete Polyphonic Music Transcription: Integrating Multi-Pitch Detection and Rhythm Quantization. IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP).
  14. Hiramatsu, Y., Nakamura, E., & Yoshii, K. (2021). Joint Estimation of Note Values and Voices for Audio-to-Score Piano Transcription. Proceedings of the 22nd International Society for Music Information Retrieval Conference (ISMIR), pp. 278–284.
  15. Mongeau, M., & Sankoff, D. (1990). Comparison of musical sequences. Computers and the Humanities, 24(3), pp. 161–175. Springer.