This section gives an overview of standard MIDI messages and how such messages, typically streamed from a MIDI file, are handled by DirectMusic. Most applications will not have to deal directly with MIDI messages, because the loader and the performance manage all the details of playback. (See Tutorial 1: Playing a MIDI File.)
MIDI input is converted to performance message format (using structures based on DMUS_PMSG) before being routed through tools by the performance. The output tool converts the data back to the standard MIDI message format before passing it to the synthesizer.
Note There is no guarantee that MIDI messages will be processed in the same order in which they occur in the file. DirectMusic messages are delivered in order of timestamp, and two MIDI messages with identical timestamps might not be delivered in the expected order. Care must be taken, in authoring MIDI content, not to give events simultaneous timestamps when they must take place sequentially. For example, don't place a program change at the exact same time as a note that is supposed to use the program change.
MIDI messages consist of a status byte usually followed by one or two data bytes. System exclusive MIDI messages are of variable length. The status byte indicates the type of message and, in some cases, the channel that is to receive the message. When several events of the same kind are in sequence in the file, the status byte can be omitted. This is called running status. Data bytes are recognizable because the high bit is always clear, whereas in status bytes it is always set.
The timing of MIDI events being streamed from a file is controlled by a number before each message indicating how many ticks separate this event from the last. The actual duration of a tick depends on the time format in the file header.
MIDI messages are divided into two main categories: