In order to successfully compile KMidi, you need appropriate versions of the program libraries in kdelibs. All required libraries as well as KMidi itself can be found on ftp://ftp.kde.org/pub/kde/.
To compile the ``dumb'' commandline interface of TiMidity, any standard Unix-type system should do. The other interfaces have special requirements (see the various README files in the distribution). The Motif interface works reasonably well with Lesstif, but better with Motif.