ACIDCAT . FILE FORMAT REFERENCE

MIDI Anatomy

Standard MIDI FileSMF 1.0
rev 2026.06
magic "MThd"
endian big
container MThd + MTrk
format 0 / 1 / 2

A Standard MIDI File is one MThd header chunk followed by one or more MTrk track chunks. MThd is 14 bytes; each MTrk is a stream of events, every event prefixed by a variable-length delta time. The clever field is division: its top bit flips the meaning of the other fifteen. Hover to light bytes or bits, click a + for its table. Color marks kind (see the key).

file regions

One header, then the tracks. Events use compact encodings (VLQ deltas, running status) that a parser must track byte by byte.

MThd0x00 . 14 bytes . drawn below

Format, track count, and timing division. The length is always 6 (extra header bytes are legal and skipped). See the byte map below.

MTrkone per track
header"MTrk" + u32 big-endian byte length
eventsdelta-time (VLQ) + event, repeated to end-of-track
VLQ delta timethe variable encoding

Seven payload bits per byte; the high bit set means another byte follows. A parser that loses sync here misreads everything after it. acidcat's running-status bookkeeping is exactly where a one-byte desync once corrupted note counts.

running statusthe omitted byte

Consecutive channel events with the same status may drop the repeated status byte; the parser must remember the last one. Every mainstream DAW exports this way.

channel voice messagesstatus 0x80-0xEF . SSSS CCCC

High nibble is the message type, low nibble the channel (0-15). Types 8n-Bn and En carry two data bytes, Cn and Dn one. Note On with velocity 0 means Note Off.

8nnote off: key, velocity
9nnote on: key, velocity (velocity 0 = note off)
Anpolyphonic aftertouch: key, pressure
Bncontrol change: controller, value
Cnprogram change: program (one data byte)
Dnchannel aftertouch: pressure (one data byte)
Enpitch bend: 14-bit LSB+MSB, (msb<<7)|lsb - 8192 = signed offset, 0 = center
meta eventsFF type len data
FF 51tempo: microseconds per quarter (bpm = 60e6 / us)
FF 54SMPTE offset: hr mn se fr ff; hr packs 0rrhhhhh, bits 6-5 = frame rate (00=24, 01=25, 10=29.97, 11=30 fps), low 5 bits = hour
FF 58time signature
FF 59key signature: sharps/flats count + minor flag
FF 01-07text family: text, copyright, track name, instrument, lyric, marker, cue point
FF 2Fend of track (required)
sysexF0 / F7 + VLQ length

In a file, F0 and F7 are followed by a VLQ byte length, then the payload; F7 carries escapes and continuations. Both cancel running status, same as meta events.

F0<length VLQ> <data> -- standard sysex
F7<length VLQ> <data> -- escape / continuation
MThd header

14 bytes. Example: format 1, 3 tracks, 480 ticks per quarter note.

division field

The 16-bit timing field, expanded. Top bit chooses the scheme; here it is 0, so the rest is ticks per quarter note.