Steev's MIDI Library is a pure C library to handle the MIDI protocol, as well  as providing code to read and write standards-compliant MIDI files. This  provides code functionality for apps wishing to support MIDI file serialism,  as well as write music apps that auto-compose music.