## What is MIDI?
MIDI (Musical Instrument Digital Interface) is a communication protocol for digital musical instruments, created in 1983. MIDI files (`.mid`) don't contain recorded audio — they contain **musical instructions**: which note to play, when, at what velocity, and on which instrument.
Think of it this way: MIDI is a score; an audio file (MP3, WAV) is a recording.
## What's Inside a MIDI File?
- **Note On/Off**: which pitch starts or stops
- **Velocity**: how hard the key is pressed (0-127)
- **Channel**: which instrument plays (channels 1-16)
- **Program Change**: instrument selection (piano, guitar, drums...)
- **Tempo**: speed in BPM
- **Control Change**: volume, panning, sustain pedal, etc.
General MIDI (GM) standard defines 128 instruments and assigns percussion to channel 10.
## MIDI vs Audio: Key Differences
| Aspect | MIDI | Audio (MP3/WAV) |
|--------|------|----------------|
| Contains | Instructions | Recorded sound |
| File size | Very small (KB) | Large (MB) |
| Editable | Completely | Limited |
| Quality | Depends on synthesizer | Fixed |
| Transpose | Trivial | Requires processing |
| Change instrument | One click | Impossible |
## What is MIDI Used For?
- **Music production**: recording keyboard performances in a DAW
- **Karaoke**: KAR files include synchronized lyrics
- **Retro gaming**: many 90s games used MIDI for music (Game Boy, SNES)
- **Digital instruments**: electric pianos, drum machines, synthesizers communicate via MIDI
## How to Play MIDI Files
The sound depends entirely on the **synthesizer** rendering it:
- **MuseScore** (free): renders MIDI with high-quality virtual orchestra
- **VLC**: plays MIDI via FluidSynth
- **DAW + VST instrument**: assign a virtual instrument plugin
## Converting MIDI to Audio
### FluidSynth (Command Line)
```bash
sudo apt install fluidsynth
# You need a SoundFont (.sf2): GeneralUser GS, FluidR3_GM
# MIDI to WAV
fluidsynth -ni /path/to/soundfont.sf2 song.mid -F output.wav -r 44100
# WAV to MP3
ffmpeg -i output.wav -b:a 192k output.mp3
```
### Timidity++
```bash
sudo apt install timidity
timidity song.mid -Ow -o output.wav
```
## MIDI in Modern Music Production
1. Record a keyboard performance into the DAW as MIDI
2. Assign a VST plugin to generate actual audio
3. Edit notes, tempo, and dynamics with full precision
4. Render the final project to WAV/MP3 for distribution
Guide