MIDI (Musical Instrument Digital Interface) is the name for a protocol for allowing musical data to be send between musical devices. Example devices are (music)keyboards, drum machines and soundcards.
It is also the name for files that store MIDI data, which can be replayed on MIDI compatible sound cards. Instead of storing the music data as a waveform (like .wav ), the music sequence is stored (e.g. which instument,note,timing,etc). The music that is stored in MIDI files and replayed on computers is not an accurate representation of the music (it is not intended to be), but is intended for processing by digital MIDI-compatible instruments. The actual instruments used for outputting can be different and thus the music can sound different. The collection of samples of the instruments that is used for output is often called a sound font.
An example of this is that musicians can play several instruments simultaneously, have the computer record the performance, save the performance to a MIDI file, email the MIDI file to a remote studio, and then, a user at that remote studio can plug in MIDI instruments in to the computer, and reproduce the performance almost exactly, without the musicians ever having to be there.
The port used for connecting external MIDI device is usually the same as the gameport for joysticks on most consumer grade soundcards.
Some sound cards are capable of MIDI, some use built-in FM synthesis others use a hardware wavetable (containing the digital samples of intruments). Examples of these soundcards are the SoundBlaster AWE,Live,Audigy, etc. Both the ALSA and the OSS drivers support most of these cards.
To play midi files, you can use Timidity:
If the card or the drivers don't support it (or the card just produces bad quality MIDI output), MIDI to wave conversion software can be used: