Skip to main content

musicdiff

A Python3 package (and command-line tool) for computing and visualizing (or describing) the notation differences between two music scores, or between two folders of music scores (for ML training runs).

musicdiff is focused on visible notation differences, not only on audible musical differences. For example, two tied eighth notes are considered different from a single quarter note. And two beamed 16th notes are considered different from two unbeamed 16th notes. This makes musicdiff particularly useful for evaluating the results of Optical Music Recognition software.

musicdiff is derived from: music-score-diff by Francesco Foscarin.

Setup

Depends on music21 (version 10.5.0+), numpy, and converter21 (version 4.0.2+). You also will need to configure music21 (instructions here) to display a musical score (e.g. with MuseScore). Requires Python 3.12+.

Usage

On the command line:

python3 -m musicdiff -i decoratednotesandrests lyrics style -x beams -- file1.musicxml file2.krn

arguments:
  -i/--include  one or more named details to include in comparison (the default is allobjects,
                a.k.a. decoratednotesandrests and otherobjects). Can be decoratednotesandrests,
                otherobjects, allobjects, or any combination of those and/or the following:
                notesandrests; the aforementioned note decorations: beams, tremolos, ornaments,
                articulations, ties, slurs; the other objects: signatures, directions,
                barlines, staffdetails, chordsymbols, ottavas, arpeggios, lyrics and
                lyricidentifiers; and a final few details that are not found in allobjects:
                style, metadata, notestaffposition, and voicing.  notestaffposition compares
                note staff position instead of note diatonic pitch (to avoid cascading errors
                from OMR clef/key errors), and voicing compares how notes are included in voices
                and chords (by default this is ignored).
  -x/--exclude  one or more named details to exclude from comparison.  Can be any of the
                named details accepted by -i/--include.
  -o/--output   one or more of three output formats: text (or t) or visual (or v) or omrned
                (or o); the default is visual). visual (or v) requests production of marked-up
                score PDFs; text (or t) requests production of diff-like text output; omrned
                (or o) requests a JSON text output containing OMR-NED (Optical Music
                Recognition - Normalized Edit Distance) information.

  file1         first music score file to compare (any format music21 or converter21 can parse)
  file2         second music score file to compare (any format music21 or converter21 can parse)

Alternate usage (for ML training runs):

python3 -m musicdiff [-h]
                        --ml_training_evaluation
                        --ground_truth_folder gtfolderpath
                        --predicted_folder predfolderpath
                        --output_folder outputfolderpath
other arguments:
  -i/--include  one or more named details to include in comparison (the default is allobjects,
                a.k.a. decoratednotesandrests and otherobjects). Can be decoratednotesandrests,
                otherobjects, allobjects, or any combination of those and/or the following:
                notesandrests; the aforementioned note decorations: beams, tremolos, ornaments,
                articulations, ties, slurs; the other objects: signatures, directions,
                barlines, staffdetails, chordsymbols, ottavas, arpeggios, lyrics and
                lyricidentifiers; and a final few details that are not found in allobjects:
                style, metadata, notestaffposition, and voicing.  notestaffposition compares
                note staff position instead of note diatonic pitch (to avoid cascading errors
                from OMR clef/key errors), and voicing compares how notes are included in voices
                and chords (by default this is ignored).
  -x/--exclude  one or more named details to exclude from comparison.  Can be any of the
                named details accepted by -i/--include.

musicdiff is also a package, with APIs you can call in your own code. There is a high-level diff() and diff_ml_training() API that the command-line tool uses (that you can tweak the behavior of), and there are also lower level APIs that you can use in projects that perhaps want to do something more complicated than just visualization in PDFs or diff-like text output.

Documentation

You can find the musicdiff API documentation here.

Citing

If you use this work in any research, please cite the relevant papers:

@inproceedings{juan_c_martinez_sevilla_2025_17811446,
  title = {Sheet Music Benchmark: Standardized Optical Music Recognition Evaluation},
  author = {Juan C. Martinez-Sevilla and Joan Cerveto-Serrano and Noelia Luna-Barahona and
            Greg Chapman and Craig Sapp and David Rizo and Jorge Calvo-Zaragoza},
  booktitle = {Proceedings of the 26th International Society for
               Music Information Retrieval Conference},
  pages = {618-625},
  year = 2025,
  publisher = {ISMIR},
  month = sep,
  venue = {Daejeon, South Korea and Online},
  doi = {10.5281/zenodo.17811446},
  url = {https://doi.org/10.5281/zenodo.17811446},
}

@inproceedings{foscarin2019diff,
  title={A diff procedure for music score files},
  author={Foscarin, Francesco and Jacquemard, Florent and Fournier-S’niehotta, Raphael},
  booktitle={6th International Conference on Digital Libraries for Musicology},
  pages={58--64},
  year={2019}
}

The Martinez-Sevilla paper is freely available on arxiv.org, and the Foscarin paper is freely available on hal.inria.fr.

Acknowledgment

Many thanks to Francesco Foscarin for allowing me to use his music-score-diff code, and for continuing to advise me on this project.

License

The MIT License (MIT) Copyright (c) 2022-2026 Francesco Foscarin, Greg Chapman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for musicdiff 6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for musicdiff 6.0
File Size Uploaded
musicdiff-6.0.tar.gz 77.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for musicdiff 6.0
File Interpreter ABI Platform
musicdiff-6.0-py3-none-any.whl Python 3 none any Details

Total release size: 150.8 kB

Release files / musicdiff-6.0.tar.gz

Download URL musicdiff-6.0.tar.gz
Size 77.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2592a5edb6f2d5dd0490c61312e77093cab10df47c204c4ca737b6b0850ddd93
BLAKE2b-256 checksum
How to use checksums
0ddd11d24f82b6ed79a45cad2fd3326f298829d1b53a49c7bcc6e7e771fcfce1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / musicdiff-6.0-py3-none-any.whl

Download URL musicdiff-6.0-py3-none-any.whl
Size 73.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a72c195a74bd707761e1b4a77413103d9a7dfd2b1bbe9842ac19f8e4b728ebcd
BLAKE2b-256 checksum
How to use checksums
6cb14d5a4c05118b3f46f65dfaab6a03eb160656797d9eb291ab30659953a303
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

6.0 This release

2 release files

5.2

2 release files

5.1

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page