LibKMid is a library that implements features to play MIDI events on MIDI devices. LibKMid also includes easy-to-use functions if all you want is play MIDI files in your application (for example, background music in a game), and a console MIDI player. The API is well documented, and the design is very simple for the most common uses.
LibKMid uses the OSS drivers to support External MIDI synthesizers, AWE, GUS and FM synths, along with soundcards from the SB Live family.
You can add easily support for any other MIDI device you may find (but I'm afraid there isn't any left), MIDI Mappers (in the same format as MIDI mappers from KMid), and a MIDI file player engine that is able to play MIDI files even if they're really corrupted or broken.
Perhaps the main thing about LibKMid is that it's optimized to take up as little resources as possible, so playing a complex MIDI on my computer (a K6/200) takes approximately 0.1% of the CPU.