Browse by type
libremidi is a cross-platform C++20 library for real-time and MIDI file input and output.
This is a fork / rewrite based on two libraries:
Additionnally, for MIDI 2 parsing support we use cmidi2!
Read the documentation here.
If you use this work as part of academic research, please kindly cite the paper:
@inproceedings{celerier2024libremidi,
title={libremidi: a cross-platform library for real-time MIDI 1 and 2},
author={Celerier, Jean-Micha{\"e}l},
booktitle={Proceedings of the Sound and Music Computing Conference (SMC)},
year={2024},
address={Porto, Portugal}
}
import libremidi;. So far compilers other than Clang 20+ crash. Enable with -DLIBREMIDI_LIBRARY_MODE=MODULE. Note that one cannot mix a module-based and a non-module based API. An example is provided in examples/modules.cpplibremidi::set_client_name / client_name function to simplify construction of an API object with a custom client name.port_information / input_port / output_port objects. Multiple ways of doing this comparison depending on the use case have been provided as examples in <libremidi/port_comparison.hpp>.libremidi::find_closest_port(query, existing_ports) utility function which tries to lookup the most likely candidate for a MIDI port across backends with the lookup information that can be provided.libremidi::port_information.track_any flag to track MIDI ports that are not reported as being hardware or software.Custom timestamping mechanism which allows the user to provide a
custom callback to run timestamping as close as possible to the event's reception.midi_in::absolute_timestamp() to get the origin timestamp for driver-provided ticks as accurately as possible.dlopen. This is necessary for making apps that will run on older Linux versions which do not have the ALSA UMP APIs yet.
Note that to make an app which supports MIDI 2 on recent Linuxes and still runs on older ones, you will need to use the latest ALSA library headers as part of your build on an older distribution, by building alsa-lib yourself (as the old distributions with an old glibc that you want to build against to make compatible software of course also ship an old libasound which won't have the UMP API...).-DLIBREMIDI_SLIM_MESSAGE=<NBytes> (in CMake or directly to the compiler)span when available (C++20) or (uint8_t* bytes, std::size_t size) pairs whenever possible to reduce copying.std::function and generally simplified.boost::small_vector to pass midi bytes instead of std::vector to reduce allocations.snake_case.$ claude mcp add libremidi \
-- python -m otcore.mcp_server <graph>