A music score notation diff package


Keywords
music, score, notation, diff, compare, OMR, Optical, Recognition, assess, assessment, comparison, music21
License
MIT
Install
pip install musicdiff==3.1.1

Documentation

musicdiff

A Python3 package (and command-line tool) for computing and visualizing the notation differences between two music scores.

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 assessing the results of Optical Music Recognition software.

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

Setup

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

Usage

On the command line:

python3 -m musicdiff file1.musicxml file2.krn

positional arguments:
  file1       first music score file to compare (any format music21 can parse)
  file2       second music score file to compare (any format music21 can parse)

The source for that command-line tool, which calls musicdiff's high-level diff() API, can be seen here. You can use it as example code for adding musicdiff capabilities to your own code. See the documentation here to find out how to customize diff()'s behavior beyond what the command line tool does.

A google colab notebook is available here.

If you are interested in calling lower-level musicdiff APIs to do more complicated things than just visualization in PDFs, the source for musicdiff's high-level diff() API (found here) is good example code to read. Note particularly how diff() calls converter21.register() to register converter21's Humdrum and MEI parsers for use by music21. If you call lower-level APIs than diff(), you will need to do this yourself.

Documentation

You can find the musicdiff API documentation here.

Citing

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

@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 paper is freely available here.

License

Licensed under the MIT License.

Acknowledgment

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