libTiMidity could help:
http://sourceforge.net/projects/libtimidity/libTiMidity is a MIDI to WAVE converter library that uses Gravis Ultrasound-compatible patch files to generate digital audio data from General MIDI files. This library based on the TiMidity decoder from SDL_sound library.
Hope that helps, or at least inspires !