MIDI Meta Events for Tempo and Key Signatures

Standard MIDI Files (SMF) use non-routable control instructions called meta events to convey non-musical session information. Within this specification, tempo changes are designated by the Set Tempo meta event (0xFF 0x51), which specifies the speed of playback in microseconds per quarter note, while harmonic tonality is managed by the Key Signature meta event (0xFF 0x59), which defines the number of sharps or flats and the scale mode.

The Set Tempo Meta Event

In Standard MIDI Files, tempo is defined using the Set Tempo meta event rather than traditional beats per minute (BPM).

The three payload bytes (tt tt tt) form a 24-bit integer representing the tempo in microseconds per quarter note (\(\mu s\)/qn).

To convert this value to standard BPM: \[\text{BPM} = \frac{60,000,000}{\text{Microseconds Per Quarter Note}}\]

For example, a tempo of 120 BPM corresponds to 500,000 microseconds per quarter note, represented in hexadecimal as 07 A1 20. The full event sequence in the MIDI track chunk appears as: FF 51 03 07 A1 20

If an SMF does not contain a Set Tempo event, software sequencers default to 120 BPM (500,000 \(\mu s\)/qn). Multiple Set Tempo events can occur throughout a track to trigger mid-piece tempo changes.

The Key Signature Meta Event

The Key Signature meta event designates the tonal center and mode (major or minor) of the piece or section.

The payload consists of two parameters:

  1. sf (Sharps/Flats): A signed 8-bit byte specifying the number of accidentals:
    • Values from -7 to -1 represent the number of flats (e.g., FF in two's complement represents -1, indicating F Major or D Minor).
    • 0 represents no sharps or flats (C Major or A Minor).
    • Values from 1 to 7 represent the number of sharps (e.g., 03 represents 3 sharps, indicating A Major or F# Minor).
  2. mi (Major/Minor): A single byte designating the scale mode:
    • 0x00 indicates a Major key.
    • 0x01 indicates a Minor key.

For example, the key of E♭ Major (3 flats) is represented by the bytes: FF 59 02 FD 00
(where FD is the signed byte for -3, and 00 signifies Major)

Standard Usage and Placement

In Format 0 MIDI files, these events are placed along the single track timeline with their corresponding delta-times. In Format 1 MIDI files, the convention is to place both Set Tempo and Key Signature events within Track 0 (the tempo map track), ensuring global synchronization across all independent instrument tracks.