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.
It provides sample code to:
It is a wonderfully compact, and complete, library that contains all the constants necessary to understand the protocol, such as instrument names, drum maps, and controller names & IDs. There's also utility methods to compute the real-world frequency of any given note and guess the currently playing chord.
The full source to MIDI Library is still available!