🎉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 (200x to 500x 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.
And a document is also available. Not complete though.
- The legacy mdBook (link above) stays online for historical reference but is no longer updated.
- The next-generation documentation for the 1.0 release is being rebuilt with Sphinx + MyST under
docs/. - Build the new docs locally via
pip install -r docs/requirements.txtfollowed bysphinx-build -b html docs docs/_build/html. - Once the Read the Docs deployment is live, this README will point to the canonical URL.
- You can just read a midi file like
score = symusic.Score("path to midi", ttype="tick") - Writing back to midi is now supported!
score.dump_midi("path") - Multiple
time unit (ttype)is now supported (currentlytickandquarter) - The tempo attribute in the tempo event represents quarter per minute (qpm)
- We offer some batch operation functions for both
ScoreandTrackclass:- shift_pitch(offset: int)
- shift_velocity(offset: int)
- shift_time(offset: float)
- sort(key, reverse)
- You can operate each note just like you did before in python (like PrettyMidi)
- Extremely fast
pickleis now supported .numpy()method for getting SoA data.filter(func, inplace)method for filtering objets in all the "List" in symusic- A new synthesizer is now available! It comes from our another project prestosynth. Find usages in our document. Note that we will support more features of soundfont for synthesizing in the future.
pip install symusicMake 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 ./symusicOr you could install the source distribution from pypi
pip install symusic --no-binary symusicFor 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 ./symusicThe wheel publication workflow already builds CPython wheels for cp314, but free-threaded variants (+freethreaded) are not tested, and no separate precompiled packages are published apart from the standard PyPI wheels generated by that workflow.
midifileis writen in cpp, and could parse midi files to bothevent levelandnote level. It is slow mostly because ofiostream.midois writen in pure python, and only parses midi files toevent levelpretty_midiandmiditoolkitis based onmido, and parse midi files tonote level- For libraries written in python or with python bindings, we use
timeitto measure the time cost of parsing the midi file.nanobenchfor cpp libraries andBenchmarkToolsfor julia libraries. - The following benchmarks could be found in symusic-benchmark.
- Tested using github action M1 runner
@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},
}- minimidi : A fast and lightweight midi parsing library written in cpp, which is the foundation of this project.
- prestosynth : A new fast soundfont synthesizer written in cpp, which is the foundation of the synthesizer in this project.
- nanobind : A efficient and lightweight library for binding C++ to Python, which is significantly faster than pybind11.
- zpp_bits : An extraordinary fast and lightweight single header library for serialization and deserialization. I use it to support pickle.
- geek_time_cpp The example code of the book "Modern C++ Programming Practice". We use the metamacro.h in it for shortening the code.
- utfcpp An easy to use and portable library for handling utf8 string in C++.