Yikai-Liao / symusic

A swift and unified toolkit for symbolic music processing
https://yikai-liao.github.io/symusic/
MIT License
135 stars 9 forks source link

symusic

Build and upload to PyPI PyPI version Downloads Page Views Count

Open In Colab

🎉ISMIR 2024 LBD Demo Vedio: Youtube Bilibili

Symusic("Sybolic Music") is a cross-platform note level midi decoding library with lightening speed, which is hundreds of times faster (100x to 1000x depending on your file size) than mido, the main midi parsing library in python.

The library is written in cpp and based on minimidi. It offers a python binding using pybind11.

Here, we have added a tutorial.ipynb for you to learn about how to use the library.

Open In Colab

And a document is also available. Not complete though.

Features

Known Bugs

Strange Noise at the End of Synthesized Audio

Currently, synthesizing audio with symusic on linux gives a probability of hearing strange noise at the end of the audio. This phenomenon cannot be reproduced consistently and does not occur on windows.

You can temporarily fix this by adding a few seconds of notes at the end and removing those seconds of audio at the end.

It is important to note that the audio synthesis functionality was implemented by us rather than using an off-the-shelf project, and it is still experimental at this time. Feel free to give us feedback on any bugs you find.

Installation

Use pre-compiled version

pip install symusic

Build from source

Make sure that your system has cmake and c++ compilers

You could clone from github and install it by pip

git clone --recursive https://github.com/Yikai-Liao/symusic
pip install ./symusic

Or you could install the source distribution from pypi

pip install symusic --no-binary symusic

For debugging purpose, you could pass -Ccmake.define.MEM_LEAK_WARNING=True to pip install to enable the memory leak warning from nanobind.

pip install -Ccmake.define.MEM_LEAK_WARNING=True ./symusic

Benchmark

Common MIDI File Parsing

read-bench

Common MIDI File Dumping

write-bench

Large MIDI File Parsing

library level absolute time relative time
minimidi event 2.86 ms 1.0x
symusic note 3.47 ms ± 113 µs 1.2x
midifile event 44.0 ms 15.4x
midifile note 45.6 ms 15.9x
MIDI.jl note 109.707 ms 38.4x
mido event 2.92 s ± 42.7 ms 1021.0x
miditoolkit note 3.15 s ± 38.2 ms 1101.4x
pretty_midi note 3.16 s ± 9.56 ms 1104.9x
music21 note 4.23 s ± 34.5 ms 1479.0x

Citation

@inproceedings{symusic2024,
    title={symusic: A swift and unified toolkit for symbolic music processing},
    author={Yikai Liao, Zhongqi Luo, et al.},
    booktitle={Extended Abstracts for the Late-Breaking Demo Session of the 25th International Society for Music Information Retrieval Conference},
    year={2024},
    url={https://ismir2024program.ismir.net/lbd_426.html#lbd},
}

Acknowledgement