Platform SDK: DirectX |
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 do not deal directly with MIDI messages because the loader and the performance manage all the details of playback.
MIDI input is converted into performance message format before being routed through tools by the performance. The output tool converts the data back into 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 time stamp, and two MIDI messages with identical time stamps might not be delivered in the expected order. Be sure, in authoring MIDI content, not to give events simultaneous time stamps if they must take place sequentially. For example, do not place a program change at the same time as a note that depends on the program change.
MIDI messages consist of a status byte, usually followed by 1 or 2 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 the running status. Data bytes are recognizable because the high bit is always clear, whereas in status bytes, it is always set.
The time at which MIDI events are 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: