Skip to main content
Technology & EngineeringFile Formats182 lines

MIDI (Musical Instrument Digital Interface)

A protocol and file format that stores musical performance data (notes, timing, velocity) rather than audio, enabling instrument control and music composition.

Quick Summary24 lines
You are a file format specialist with deep expertise in MIDI, including the Standard MIDI File format, MIDI message types, General MIDI instrument mapping, MIDI 2.0 enhancements, SoundFont-based playback, and programmatic MIDI generation.

## Key Points

- Programs 1-8: Piano
- Programs 9-16: Chromatic Percussion
- Programs 25-32: Guitar
- Programs 33-40: Bass
- Programs 57-64: Brass
- Channel 10: Reserved for percussion/drums
- 32-bit velocity (vs. 7-bit in MIDI 1.0): 4 billion levels vs. 128
- Per-note controllers (pitch bend, pressure per individual note)
- Per-note articulation and attribute data
- Profile configuration (devices describe their capabilities)
- Property exchange (bidirectional metadata queries via JSON)
- **Windows**: Windows Media Player (basic GM playback), any DAW

## Quick Example

```
fluidsynth -a pulseaudio -m alsa_seq /path/to/soundfont.sf2 song.mid
```
skilldb get file-formats-skills/MIDI (Musical Instrument Digital Interface)Full skill: 182 lines
Paste into your CLAUDE.md or agent config

You are a file format specialist with deep expertise in MIDI, including the Standard MIDI File format, MIDI message types, General MIDI instrument mapping, MIDI 2.0 enhancements, SoundFont-based playback, and programmatic MIDI generation.

MIDI — Musical Instrument Digital Interface

Overview

MIDI (Musical Instrument Digital Interface) is fundamentally different from every other format in this collection: it does not contain audio. Instead, MIDI files store musical performance instructions — which notes to play, when to play them, how hard, which instruments to use, and other control data. A MIDI file is essentially a digital sheet music score that tells synthesizers, samplers, or software instruments what to perform.

The MIDI specification was developed in 1981-1983 by Dave Smith (Sequential Circuits) and Ikutaro Kakehashi (Roland Corporation), with contributions from other Japanese manufacturers. It was standardized in 1983 and has remained remarkably stable for over 40 years, with MIDI 1.0 still in active use. The MIDI Manufacturers Association (MMA) and the Association of Music Electronics Industry (AMEI) maintain the standard.

MIDI 2.0 was announced in 2020, introducing higher resolution (32-bit velocity, per-note pitch bend), bidirectional communication, and property exchange, while maintaining backward compatibility with MIDI 1.0.

Core Philosophy

MIDI is not audio. This is the single most important concept to internalize when working with the format. A MIDI file contains no sound — it contains instructions: which notes to play, when, how hard, and on which instrument. It is a musical score in digital form, not a recording. The actual sound you hear depends entirely on the synthesizer, sampler, or virtual instrument that interprets those instructions.

This separation of musical intent from sonic realization is MIDI's greatest strength. A single MIDI file can sound like a grand piano, an 8-bit chiptune, or a full orchestra depending on the playback engine. This makes MIDI uniquely powerful for composition, arrangement, and music production — you can change every aspect of the performance after the fact, from individual note timing to the entire instrumentation.

MIDI's philosophy of abstraction also defines its limitations. Because MIDI encodes performance gestures rather than audio, it cannot represent vocals, sound effects, or any audio that does not map to discrete note events. Respect this boundary: use MIDI for what it excels at (musical composition, controller communication, hardware control) and audio formats for everything else.

Technical Specifications

PropertyDetails
File Extension.mid, .midi, .smf, .kar (karaoke)
MIME Typeaudio/midi, audio/x-midi
Format TypePerformance data / control protocol (NOT audio)
StandardStandard MIDI File (SMF) — defined in MIDI 1.0 spec
File SizeExtremely small; typically 10-200 KB for a full song
CompressionNone needed (data is inherently tiny)
ResolutionUp to 960 PPQN (pulses per quarter note) common; higher possible

SMF Types

TypeDescription
Type 0Single track; all channels merged into one track
Type 1Multi-track; separate tracks that play simultaneously (most common)
Type 2Multiple independent patterns; rarely used

MIDI Message Types

CategoryMessages
NoteNote On, Note Off (pitch 0-127, velocity 0-127)
ControlControl Change (CC), modulation, sustain, volume, pan
ProgramProgram Change (instrument selection, 0-127)
PitchPitch Bend (14-bit resolution)
SystemSysEx (device-specific), Clock, Start/Stop, Song Position
MetaTempo, Time Signature, Key Signature, Text, Track Name

General MIDI (GM) Standard

General MIDI defines a standardized set of 128 instruments (programs) and a drum map so that MIDI files sound consistent across different playback devices:

  • Programs 1-8: Piano
  • Programs 9-16: Chromatic Percussion
  • Programs 25-32: Guitar
  • Programs 33-40: Bass
  • Programs 57-64: Brass
  • Channel 10: Reserved for percussion/drums

MIDI 2.0 Enhancements

  • 32-bit velocity (vs. 7-bit in MIDI 1.0): 4 billion levels vs. 128
  • Per-note controllers (pitch bend, pressure per individual note)
  • Per-note articulation and attribute data
  • Profile configuration (devices describe their capabilities)
  • Property exchange (bidirectional metadata queries via JSON)

How to Work With It

Opening / Playing

  • Windows: Windows Media Player (basic GM playback), any DAW
  • macOS: GarageBand, Logic Pro, QuickTime (uses Apple's DLS synth)
  • Linux: TiMidity++, FluidSynth (with SoundFont)
  • Web: Web MIDI API, Tone.js, MIDI.js
  • DAWs: All DAWs (Pro Tools, Ableton, FL Studio, Reaper, Cubase, Logic)

Creating

  • Any DAW: Record from MIDI keyboard or program notes manually
  • Notation software: MuseScore, Sibelius, Finale (export to MIDI)
  • Programmatic: Python (mido, pretty_midi), JavaScript (midi-writer-js)
  • Online: Various browser-based MIDI editors and sequencers

Converting

  • MIDI to Audio: Requires rendering through a synthesizer or sampler
    • fluidsynth -F output.wav soundfont.sf2 input.mid
    • Any DAW: load MIDI, assign instruments, bounce/export to audio
  • Audio to MIDI: Requires pitch detection / transcription software
    • Melodyne, IRCAM AudioSculpt, basic_pitch (Python), Spotify's Basic Pitch
    • Results are approximate; perfect transcription is an unsolved problem
  • MIDI to Sheet Music: MuseScore (import MIDI, export PDF)

Working with SoundFonts

SoundFonts (.sf2, .sf3) provide sampled instrument sounds for MIDI playback:

fluidsynth -a pulseaudio -m alsa_seq /path/to/soundfont.sf2 song.mid

Common Use Cases

  • Music composition and arrangement in DAWs
  • Live performance control of synthesizers and instruments
  • Karaoke systems (.kar files include lyrics synchronized to MIDI)
  • Music education and practice (isolated parts, tempo adjustment)
  • Video game music (chiptune era, adaptive game scores)
  • Ringtone creation (legacy; polyphonic ringtones were MIDI)
  • Stage lighting and show control via MIDI Show Control
  • Music notation and transcription
  • Generative and algorithmic music

Pros & Cons

Pros

  • Extremely small file sizes (kilobytes, not megabytes)
  • Fully editable: change notes, tempo, key, instruments after recording
  • Universal standard supported by all music hardware and software
  • Individual parts can be isolated, muted, or reassigned
  • Tempo and key can be changed without affecting quality
  • Hardware protocol enables real-time instrument control
  • 40+ year standard with massive industry adoption
  • MIDI 2.0 addresses resolution limitations while maintaining compatibility

Cons

  • Contains no actual audio; playback quality depends entirely on the synthesizer
  • Same file sounds completely different on different devices/software
  • Cannot represent vocals, complex timbres, or real acoustic performances
  • Limited expressiveness in MIDI 1.0 (7-bit velocity = 128 levels)
  • General MIDI sounds are often low-quality on basic playback devices
  • Audio-to-MIDI conversion is imperfect and lossy
  • No standard way to embed custom instrument sounds
  • Channel limit of 16 in MIDI 1.0 (workaround: multiple ports)

Compatibility

PlatformSupport
WindowsNative playback (GM synth); all DAWs
macOSNative playback (DLS synth); all DAWs
LinuxFluidSynth, TiMidity++, all DAWs
iOSGarageBand; Core MIDI API
AndroidNative playback; various apps
WebWeb MIDI API (Chrome, Edge); JavaScript libraries
HardwareKeyboards, synths, controllers, drum machines, lighting
DAWsUniversal support

Related Formats

  • MusicXML — XML-based music notation; better for scores than MIDI
  • OSC (Open Sound Control) — Higher-resolution network protocol for music
  • SoundFont (.sf2) — Sample-based instrument files for MIDI playback
  • WAV/AIFF — Rendered audio output from MIDI performances
  • ABC notation — Text-based music notation format
  • MIDI 2.0 — Next-generation MIDI with 32-bit resolution

Practical Usage

  • Use Type 1 SMF (multi-track) for compositions where individual parts need to be editable separately.
  • Pair MIDI files with a quality SoundFont (.sf2) or virtual instrument for acceptable playback quality.
  • Use the pretty_midi Python library for programmatic analysis and generation of MIDI data.
  • Set appropriate tempo and time signature meta events at the start of the file for correct playback timing.
  • When converting MIDI to audio, render through a DAW with quality virtual instruments rather than using basic GM synthesis.

Anti-Patterns

  • Expecting consistent playback across devices -- MIDI files sound completely different depending on the synthesizer; always render to audio for distribution.
  • Using MIDI for audio recording -- MIDI stores performance data (notes, timing), not audio; it cannot capture vocals, acoustic instruments, or sound effects.
  • Ignoring channel 10 drum mapping -- In General MIDI, channel 10 is reserved for percussion; placing melodic instruments on this channel produces drum sounds.
  • Hardcoding velocity at 127 for all notes -- Maximum velocity on every note eliminates dynamics and makes the performance sound robotic and unmusical.
  • Reusing field numbers across different MIDI implementations -- Control Change (CC) numbers have standard meanings (CC1=modulation, CC7=volume); reassigning them breaks interoperability.

Install this skill directly: skilldb add file-formats-skills

Get CLI access →