midicnAudio & Music Production 中文

MIDI File Format

SMF stores events in MThd and MTrk chunks, and formats 0 and 1 serve different jobs.

The format decides how events queue and how easily tempo can be edited.

The problem

Storing the same performance as one track or many changes editing completely. A file that will not open, plays at the wrong tempo or crams parts together points to the header.

Protocol or message

A file begins with MThd, a 6-byte field holding format, ntrks and division, so the header is 14 bytes. Format 0 has one MTrk. Format 1 has several synchronised MTrk chunks, usually with tempo and time signature first. Format 2 holds independent patterns and is rare. Each MTrk holds delta times and events, with delta as a variable-length number. Division gives ticks per quarter note, or an SMPTE value. Meta events start with 0xFF, where 0x51 is tempo, 0x58 is time signature and 0x2F ends the track.

Settings and practice

Use format 1 for arranging and exchange, since tracks stay separate and compatibility is best. Small players may prefer format 0. When changing tempo, edit the tempo track.

What to listen for

Both formats should sound identical. A difference usually means a tempo track or channel problem. After splitting tracks, listen one by one and check that velocity and pedal stayed put.

Common misunderstandings

Track count is not channel count. Every track in format 1 shares one timeline. The same extension does not guarantee GM.

Listen in the library

sailors battle midi theme 9C10:58format 0,单条 MTrk 装着 5 个通道、1081 个音符DetailsPiano Quintet in A major · 2. AndanteC16:30format 1,18 条 MTrk,速度表里有多次变速Detailsintro verse1 copyC15:46format 1,32 条 MTrk,却只用 16 个通道Details

All tracks from midicn-lib — inline badge is the license tier (C1 commercial / C2 non-commercial / C3 study only).

Sources

  • SMF 1.0 规范对 MThd 与 MTrk 的结构定义,依 MMA 公开规范核查,未抄文本
  • format 0、1、2 与 division 的用法,依通行音序器文档核查,未抄文本

Used for fact-checking only; all prose is original.