MIDI, Musical Instrument Digital Interface, is an industry-standard protocol that enables electronic musical instruments, computers, and other equipment to communicate, control, and synchronize with each other. Files in this format usually have a .MID extension.
MIDI is different from other audio formats in that it does not represent sounds as they would be recorded. Instead it represents the notation of music in a data format. Basically it could be thought of as an electronic musical score. It has a sequence of notes and duration of each note and other information needed to reproduce the notes. It also identifies the instrument so a program can be used to generate the sounds from the notation information. Multiple simultaneous notations are in the file format so an entire orchestra can be reproduced. The file format is much smaller than would be required to record the sound.
The data includes such items as the pitch and intensity of musical notes to play, control signals for parameters such as volume, vibrato and panning, cues, and clock signals to set the tempo. A composer could code the data directly and then listen to the music it would produce. This is a common use for this format and it is used often to drive a keyboard or other midi compatible instrument although it can also be used directly by a computer that has a program that can interpret this data.
Note that this music format differs from other music formats discussed in the article on sound in that they represent the recording of a particular performance while the midi format is an idealized representation of the music which can then be rendered by a music machine. MIDI format provides the ability to easily edit the individual components of a piece of music.
 File formats
There are several file formats used to represent MIDI data. One format using the .KAR extension is specific for Karaoke machines and includes synchronized text for the words.
The SMF, standard MIDI format, specification was developed by, and is maintained by, the MIDI Manufacturers Association (MMA). MIDI files are typically created using computer-based sequencing software (or sometimes a hardware-based MIDI instrument or workstation) that organizes MIDI messages into one or more parallel "tracks" for independent recording and editing. In most sequencers, each track is assigned to a specific MIDI channel and/or a specific General MIDI instrument patch. Although most current MIDI sequencer software uses proprietary "session file" formats rather than SMF, almost all sequencers provide export or "Save As..." support for the SMF format.
Microsoft Windows uses a RIFF-based MIDI files with the .rmi extension. Note, Standard MIDI Files per se are not RIFF-compliant. A RIFF-RMID file, however, is simply a Standard MIDI File wrapped in a RIFF chunk. If you extract the data part of the RIFF-RMID chunk the result will be a regular Standard MIDI File.
XMF (eXtensible Music File) is a new file format approved for MIDI use. Some forms package SMF chunks with instrument data in DLS format (Downloadable Sounds, also an MMA/AMEI specification), to much the same effect as the MOD file format. The XMF container is a binary format.