Meta events carry what a file needs but a MIDI cable does not: names, words, the tempo, the time and key signatures and the end of each track. They are never sent to a synthesiser. Each one is
FF <type> <length> <data>
where the type is one byte, 00 to 7F, and the length is a
variable-length quantity. A meta
event cancels running
status.
Types
| Type | Name | Length | Data |
|---|---|---|---|
00 | Sequence number | 2 or 0 | u16 |
01 | Text | any | text |
02 | Copyright notice | any | text |
03 | Sequence or track name | any | text |
04 | Instrument name | any | text |
05 | Lyric | any | text |
06 | Marker | any | text |
07 | Cue point | any | text |
08 | Program name | any | text |
09 | Device name | any | text |
0A–0F | Text, reserved kinds | any | text |
20 | MIDI channel prefix | 1 | channel |
21 | MIDI port | 1 | port |
2F | End of track | 0 | none |
51 | Set tempo | 3 | u24 |
54 | SMPTE offset | 5 | hr mn se fr ff |
58 | Time signature | 4 | nn dd cc bb |
59 | Key signature | 2 | sf mi |
60 | XMF patch type prefix | 1 | patch type |
7F | Sequencer specific | any | manufacturer ID, then data |
Numbers in meta events are big-endian. RP-001 says readers must never ignore the length of an event they know, and “shouldn’t be surprised if it’s bigger than they expected. If so, they must ignore everything past what they know about”; writers must not add bytes of their own. The explorer does the same: it decodes the known part of a longer event and shows the rest as ignored bytes. An event shorter than its fixed length cannot be read and is shown as bytes, with an issue.
Meta events at the same time may come in any order, with these exceptions in RP-001: Sequence number and Sequence/Track name, when present, are at time 0; a copyright notice should be the first event of the first track; End of track is the last event of every track.
Sequence number (00)
A 16-bit number that identifies the sequence: in a type 2 file, the pattern; in a type 0 or 1 file, the song, and it belongs in the first track. It must come at the beginning of its track, before any non-zero delta time and before any transmittable event. With a length of 0 and no data, the number is the track’s place in the file. RP-001 adds that several multitrack sequences are sent as several format 1 files, each with its own sequence number.
Text (01)
Any text: comments, notes about the song, or anything else. Types 0A to
0F are reserved for further kinds of text and are read as text too.
The original specification does not fix an encoding. Most files are ASCII;
Windows-1252 and, in Japanese files, Shift JIS are also common. Many writers end text
with a zero byte, as C strings do; readers drop it. The explorer works out one encoding
for the file’s text events: it uses UTF-8 when every run of high bytes is valid UTF-8,
Shift JIS when the high bytes fit its lead and trail bytes with kana among them, and
Windows-1252 otherwise, and says which it chose and that it guessed. An
RMID file’s MENC entry takes
the place of the guess.
RP-001 asks for printable ASCII for the widest interchange; characters with the top bit set may be used between programs on a computer that supports them, and programs that cannot show them should ignore them. RP-026’s code set tags (see Lyric) apply to Lyric events only, not to Text or the other text events.
Karaoke files (.kar) put the words of the song in Text events, usually
in a track named “Words”. Texts that start with @ carry information:
@KMIDI KARAOKE FILE, @V a version, @I
information, @L the language and @T title lines. Within the
words, \ starts a paragraph and / a new line. This is a
convention, not part of the specification; see the
MIDI karaoke file. From a real file, in a track
named “Words” after one named “Soft karaoke”:
00 FF 01 13 40 4B 4D 49 44 49 20 4B 41 52 41 4F 4B 45 20 46 49 4C 45
Delta 0, Text, 19 bytes: @KMIDI KARAOKE FILE.
Copyright notice (02)
A copyright notice as printable ASCII, with the characters (C), the year and the owner, such as “(C) 2000 Name”. If a file holds several pieces, all their notices go together in this one event. RP-001: it should be the first event in the first track, at time 0.
Sequence or track name (03)
The name of the track. In a type 0 file, or the first track of a type 1 file, it names the whole song. When present it is at time 0. From the start of a real file’s first track:
00 FF 03 1B 5A 6F 6D 62 69 65 …
Delta 0, Track name, 27 bytes: Zombie Nation-Kernkraft 400.
Instrument name (04)
The instrument meant to play the track, as text, such as “Piano”. It does not choose the sound; a program change does.
Lyric (05)
One syllable or word of the lyrics, at the time it is sung. Karaoke files more often use Text events for the words.
RP-017: lyric events (1997)
RP-017 keeps Lyric events to ASCII and fixes how they are written, for notation and for karaoke alike:
- Each syllable is its own Lyric event, at the time it is sung.
- A space (
20) ends every word. An event that does not end with a space is continued by the next one. - Punctuation goes at the end of a syllable, before the space.
- A carriage return (
0D) on its own in an event ends a line, usually at the end of a phrase; for karaoke, a displayed line. - A line feed (
0A) on its own in an event ends a paragraph, such as a verse or chorus; for karaoke, when to clear the screen. - Hyphens appear only where the language has them (“sixty-four”), not between syllables; a notation program adds those itself.
- An event with no characters is a melisma: the syllable before goes on being sung.
It also recommends a Lyric event at bar 1, beat 1, tick 0, to turn lyric display on in
some players, and a carriage return within every 40 characters, on a word boundary.
The characters allowed are A–Z, a–z, 0–9, space, CR, LF and
. , ! " ' ? # $ & * + - / : ; = % @ ^ ` ~ _ | ( ) < >;
\ [ ] { } were kept back for the escape codes RP-026 then defined.
| Event | Text |
|---|---|
| 3:01:000 | "Each " |
| 3:02:000 | "syl" |
| 3:03:000 | "la" |
| 3:04:000 | "ble " |
| 4:02:000 | "six", then "ty-", "four " |
| 8:01:000 | CR, then at 8:02:000 LF |
Part of RP-017’s own example, “Each syllable in sixty-four…”, by bar, beat and tick.
RP-026: language and display extensions (1999)
RP-026 renames Lyric events Lyric/Display events and reserves five characters in them. It applies to Lyric events only.
| Character | Meaning |
|---|---|
\ (5C) | Starts a command code |
[ (5B) | Starts a ruby part |
] (5D) | Ends a ruby part |
{ (7B) | With @, starts a code set tag; with #, a song information tag |
} (7D) | Ends a tag |
Command codes. \r is a carriage return,
\n a new line (line feed), \t a horizontal tab; other codes
are reserved. \\, \{, \}, \[ and
\] stand for the characters themselves.
Ruby. Text between [ and ] is ruby: small
characters shown above or below the text it belongs to, which is the text before
[ in the same event, or, if there is none, the text of the event
before.
Code set. {@LATIN} (or Latin,
latin) is the ANSI set for the common European languages, and
{@JP} (Jp, jp) is MS-Kanji, Shift JIS. The tag goes
before any other Lyric/Display event and holds until another; a file may switch.
Without a tag the set is ANSI. After a code set that is not defined, lyrics are
ignored until a defined one appears. A byte order mark, FF FE or
FE FF, means Unicode.
Song information. {#TITLE=…}, {#COMPOSER=…},
{#LYRICS=…} (the lyricist) and {#ARTIST=…}, in upper,
initial-capital or lower case, placed at the start of the lyrics after the code set
tag. {#} is the null tag that marks the end of a group; a new
{# also ends the item before, in case a multi-byte character hid its
}.
In the explorer
Each Lyric event is shown with its code set, song information and commands
decoded, and an empty one as a melisma. The lyrics view joins the events in order:
a CR (or \r) starts a new line and an LF (or \n) a new
paragraph; ruby stays in brackets after its text. Song information appears with the
song’s other details, and lyrics in an undefined code set are left out.
Marker (06)
The name of a point in the song, such as a rehearsal letter or “Verse”. It belongs in the first track of a type 1 file.
Cue point (07)
A description of something that happens on stage, on screen or in the film at this point.
Program name (08)
Added by RP-019 in 1998. The name of the program called up by the bank select and program change messages that immediately follow it, which also give the channel. It helps re-orchestration, as one device’s piano can be another’s drum kit. It may appear anywhere in a track, more than once, but only together with a program change and any bank selects.
Device name (09)
Added by RP-019 in 1998. The name of the device the track is meant for, often a synthesiser’s model name, but any string that identifies a device in a setup. It lets one file address several devices and more than 16 channels, and lets devices move without renumbering cables. RP-019’s rules:
- One Device name per track, at the beginning, before any sendable event: with the text events, before Program name and before bank select and program change. A track addresses one device.
- In a type 1 file, the data for each device is in its own track with its own Device name; several tracks may name the same device. A type 0 file has only one.
- For files sent to unknown setups, generic names for the kind of instrument are useful, or none at all when the file uses fewer than 16 channels; a maker may use “0”, “1” and so on, or names such as “FM” and “Wave”.
MIDI channel prefix (20)
One byte, a channel 0 to 15. The meta and system exclusive events that follow belong to that channel, until the next channel message or the next channel prefix.
MIDI port (21)
One byte, the output port the track plays on. It is not in the specification, but many sequencers write it, and it is common in the files examined for this site. Some sources call it obsolete, in favour of the Device name event; that was not checked.
End of track (2F)
FF 2F 00, with no data. It is required as the last event of every track;
see End of track on the
tracks page.
Set tempo (51)
Three bytes, a 24-bit big-endian number: microseconds per quarter note, from this point on. Beats a minute = 60,000,000 ÷ tempo. Until the first one the tempo is 500,000, 120 beats a minute. In a type 1 file tempo events belong in the first track.
00 FF 51 03 0D 14 37
From a real file: 0D 14 37 is 857,143 µs a quarter note, 70 beats a
minute. How ticks become seconds is shown under
Timing.
SMPTE offset (54)
Five bytes, the SMPTE time at which the track starts. It belongs at the start of the track, before any event with a delta time above 0. In a type 1 file, RP-001 says it must be stored with the tempo map, in the first track, and has no meaning in any other. The hour must be encoded as in MIDI Time Code, with the frame rate in it.
| Byte | Name | Meaning |
|---|---|---|
| 0 | hr | Bits 0 to 4: hours, 0 to 23. Bits 5 and 6: the frame rate, 0 = 24, 1 = 25, 2 = 29.97 drop-frame, 3 = 30 frames a second. |
| 1 | mn | Minutes |
| 2 | se | Seconds |
| 3 | fr | Frames |
| 4 | ff | Hundredths of a frame |
00 FF 54 05 60 00 03 00 00
From a real file, at time 0 in the first track. The hour byte, 60, says
30 frames a second and 0 hours: 0 minutes, 3 seconds and 0 frames. The explorer checks
the ranges and the event’s place in the track and reports any that fail.
Time signature (58)
| Byte | Name | Meaning |
|---|---|---|
| 0 | nn | The numerator: beats in a bar |
| 1 | dd | The denominator as a power of two: 2 is a quarter note, 3 an eighth |
| 2 | cc | MIDI clocks per metronome click; there are 24 MIDI clocks in a quarter note |
| 3 | bb | Thirty-second notes in a MIDI quarter note (24 MIDI clocks), normally 8 |
00 FF 58 04 04 02 18 08
From a real file: 4/4, a click every 24 clocks (every quarter note), 8 thirty-second
notes to a quarter note. 6/8 with a click on every dotted quarter would be
06 03 24 08.
Key signature (59)
| Byte | Name | Meaning |
|---|---|---|
| 0 | sf | Signed: −7 to −1 is that many flats, 0 is none, 1 to 7 that many sharps |
| 1 | mi | 0 major, 1 minor |
sf | Major | Minor | sf | Major | Minor |
|---|---|---|---|---|---|
−7 (F9) | C♭ | A♭ | 1 | G | E |
−6 (FA) | G♭ | E♭ | 2 | D | B |
−5 (FB) | D♭ | B♭ | 3 | A | F♯ |
−4 (FC) | A♭ | F | 4 | E | C♯ |
−3 (FD) | E♭ | C | 5 | B | G♯ |
−2 (FE) | B♭ | G | 6 | F♯ | D♯ |
−1 (FF) | F | D | 7 | C♯ | A♯ |
| 0 | C | A |
00 FF 59 02 00 00
From a real file: C major.
XMF patch type prefix (60)
Defined by RP-032, for Standard MIDI Files inside an XMF (eXtensible Music Format) file. It says where the sounds of the track that follows come from: the General MIDI 1 or 2 sounds supplied by the player, or custom DLS instruments supplied in the XMF file. It is not used outside XMF, and a Standard MIDI File on its own has no reason to carry it.
The event is FF 60 01 pp, one data byte:
| Value | Meaning |
|---|---|
| 1 | General MIDI 1: instruments supplied by the player. GM1 is the default, so this is redundant but allowed. |
| 2 | General MIDI 2: the track is written for the GM2 sound set or controller responses. If GM2 is not available, GM1 is used. |
| 3 | DLS: custom instruments supplied in the XMF file |
RP-032’s rules (2001):
- It says how to read the program changes and bank selects that follow in the same track. Without it, General MIDI 1 applies.
- No track may change to another instrument set, so the event counts only as the first event of a track; anywhere else it must be ignored.
- GM1 System On, GM2 System On, Turn DLS On, Turn DLS Off and GM System Off should never be in the same track, and players must ignore them if they are.
The explorer names the value and reports a prefix that is not the first event of its track, and those system exclusive messages in a track that has one.
Sequencer specific (7F)
Data for one maker’s software: a manufacturer ID, one byte or 00 and two
more, as in system exclusive
messages, then that maker’s own bytes. The explorer names the maker from the
register and shows the rest as
bytes, since no public specification covers them; other readers skip it.
Unknown types
A reader must ignore a meta event whose type it does not know, using the length to skip it. This is what lets new types, such as 08 and 09, be added without breaking older readers. The explorer shows unknown types with their bytes.