Fmidi is a library to read and play back MIDI files. It supports both standard MIDI files and RIFF MIDI files.
The functionality is exposed as a C programming interface, and it is implemented with C++.
It is a simple library which is good for implementing a MIDI file player, or any program taking MIDI files as inputs. In fact, a player with a terminal interface is provided as an example. Build it with ncurses, libev and RtMidi.
This library is designed for excellent compatibility. Downloaded MIDI files often come as corrupted, incomplete, or non-standard in many ways. Fmidi has a permissive reader, which attempts repairs when errors are detected, without compromise on the MIDI file standard.
Fmidi is tested on a collection of MIDI files and the results are displayed in the table below. The data gives an idea of the relative compatibility and robustness of the library.
Tests are performed under different libraries with AddressSanitizer and identical environments. Under each error situation, the data indicates the number of problematic files.
Library | Reading error | AddressSanitizer issue | LeakSanitizer issue |
---|---|---|---|
Fmidi 0.1 | 20 | 0 | 0 |
libsmf 1.3 | 468 | 265 | 108 |
portsmf 228 | 979 | 7 | 0 |
libtimidity 0.2.5 | 493 | 0 | 0 |
Total files | 86808 |