Changes
Jump to navigation
Jump to search
no edit summary
wrong value when played on a General MIDI instrument. Intelligent software can use the
Program Name event to look up the correct value for the <B>MIDI Program Change</B> event.
Note that <I><FONT COLOR=GREEN><B>len</B></FONT></I> could be a series of bytes since it
is expressed as a variable length quantity.
----
===== Device (Port) Name =====
FF 09 <I><FONT COLOR=GREEN><B>len</B></FONT></I> <I><FONT COLOR=RED><B>text</B></FONT></I>
The name of the MIDI device (port) where the track is routed. This replaces the "MIDI Port"
Meta-Event which some sequencers formally used to route MIDI tracks to various MIDI ports (in
order to support more than 16 MIDI channels).
For example, assume that you have a MIDI interface that has 4 MIDI output ports. They are
listed as "MIDI Out 1", "MIDI Out 2", "MIDI Out 3", and "MIDI Out 4". If you wished a particular
MTrk to use "MIDI Out 1" then you would put a Port Name Meta-event at the beginning of the MTrk,
with "MIDI Out 1" as the <I><FONT COLOR=RED><B>text</B></FONT></I>.
All MIDI events that occur in the MTrk, after a given Port Name event, will be routed to that
port.
In a format 0 MIDI file, it would be permissible to have numerous Port Name events intermixed
with MIDI events, so that the one MTrk could address numerous ports. But that would likely make
the MIDI file much larger than it need be. The Port Name event is useful primarily in format 1
MIDI files, where each MTrk gets routed to one particular port.
Note that <B>len</B> could be a series of bytes since it is expressed as a variable length
quantity.
----
===== End of Track =====
FF 2F 00
This event is <u>not</u> optional. It must be the last event in every MTrk. It's used as a definitive marking of the end of an MTrk. Only 1 per MTrk.
----
===== Tempo =====
FF 51 03 <I><FONT COLOR=RED><B>tt tt tt</B></FONT></I>
Indicates a tempo change. The 3 data bytes of <B>tt tt tt</B> are the tempo in microseconds per quarter note. In other
words, the microsecond tempo value tells you how long each one of your sequencer's "quarter notes" should be. For example,
if you have the 3 bytes of 07 A1 20, then each quarter note should be 0x07A120 (or 500,000) microseconds long.
So, the MIDI file format expresses tempo as "the amount of time (ie, microseconds) per quarter note".
<B><FONT COLOR=RED>NOTE:</FONT></B> If there are no tempo events in a MIDI file, then the
tempo is assumed to be 120 BPM
In a format 0 file, the tempo changes are scattered throughout the one
MTrk. In format 1, the very first MTrk should consist of only the tempo (and time signature) events
so that it could be read by some device capable of generating a "tempo map". It is best not to
place MIDI events in this MTrk. In format 2, each
MTrk should begin with at least one initial tempo (and time signature) event.
----
===== SMPTE Offset =====
FF 54 05 <I><FONT COLOR=RED><B>hr mn se fr ff</B></FONT></I>
Designates the SMPTE start time (hours, minutes, seconds, frames, subframes) of the MTrk. It should
be at the start of the MTrk. The hour should not be encoded with the SMPTE format as it is in
<B>MIDI Time Code</B>. In a format 1 file, the SMPTE OFFSET must be stored with the tempo
map (ie, the first MTrk), and has no meaning in any other MTrk. The <FONT COLOR=RED><B>ff</B></FONT>
field contains fractional frames in 100ths of a frame, even in SMPTE based MTrks which specify a different
frame subdivision for delta-times (ie, different from the subframe setting in the MThd).
----
===== Time Signature =====
FF 58 04 <I><FONT COLOR=RED><B>nn dd cc bb</B></FONT></I>
Time signature is expressed as 4 numbers. <I><FONT COLOR=RED><B>nn</B></FONT></I>
and <I><FONT COLOR=RED><B>dd</B></FONT></I> represent the
"numerator" and "denominator" of the signature as notated on sheet music. The denominator is a
negative power of 2: 2 = quarter note, 3 = eighth, etc.
The <I><FONT COLOR=RED><B>cc</B></FONT></I> expresses the number of
MIDI clocks in a metronome click.
The <I><FONT COLOR=RED><B>bb</B></FONT></I> parameter expresses the number of notated
32nd notes in a MIDI quarter note (24 MIDI clocks). This event allows a program to relate what
MIDI thinks of as a quarter, to something entirely different.
For example, 6/8 time with a
metronome click every 3 eighth notes and 24 clocks per quarter note would be the following
event:
FF 58 04 06 03 18 08
<B><FONT COLOR=RED>NOTE:</FONT></B> If there are no time signature events in a MIDI file,
then the time signature is assumed to be 4/4.
In a format 0 file, the time signatures changes are scattered throughout the one
MTrk. In format 1, the very first MTrk should consist of only the time signature (and tempo) events
so that it could be read by some device capable of generating a "tempo map". It is best not to
place MIDI events in this MTrk. In format 2, each
MTrk should begin with at least one initial time signature (and tempo) event.
----
===== Key Signature =====
FF 59 02 <I><FONT COLOR=RED><B>sf mi</B></FONT></I>
<I><FONT COLOR=RED><B>sf</B></FONT></I> = -7 for 7 flats, -1 for 1 flat, etc, 0 for key of c, 1 for 1 sharp, etc.
<I><FONT COLOR=RED><B>mi</B></FONT></I> = 0 for major, 1 for minor
----
===== Proprietary Event =====
FF 7F <I><FONT COLOR=GREEN><B>len</B></FONT></I> <I><FONT COLOR=RED><B>data</B></FONT></I>
This can be used by a program to store proprietary data. The first byte(s) should be a unique ID
of some sort so that a program can identity whether the event belongs to it, or to some other
program. A 4 character (ie, ascii) ID is recommended for such.
Note that <I><FONT COLOR=GREEN><B>len</B></FONT></I> could be a series of bytes since it
is expressed as a variable length quantity.