Microsoft DirectX 8.1 (C++) |
A channel message is addressed to a particular MIDI channel, which corresponds to a single part in the music.
A channel message can be either a mode message or a voice message.
A mode message determines how a channel will deal with subsequent voice messages. For example, a mode message might instruct the channel to remain silent, ignoring all note-on messages until further notice.
Most channel messages are voice messages. They instruct the channel to begin or stop playing a note or to modify the note in some way, or they change the timbre by assigning a different MIDI patch number to the channel.
The following table describes types of voice messages.
Voice message | Purpose |
Note-on | Play a note. |
Note-off | Stop playing the note. |
Control change | Modify the tone with data from a pedal, lever, or other device; also used for miscellaneous controls such as volume and bank select. |
Program (patch) change | Select an instrument for the channel by assigning a patch number. |
Aftertouch | Modify an individual note, or all notes on the channel, according to the aftertouch of a key. |
Pitch bend change | Modify the pitch of all notes played on the channel. |
Keep in mind that these descriptions apply to standard MIDI messages, not MIDI data that has been converted to performance message format. For example, two MIDI messages to start and stop a note are combined by DirectMusic into a single performance message giving the duration of the note. DirectMusic messages also contain much additional information about timing and routing.
The data bytes of a note-on message represent the pitch and
For information on how DirectMusic converts to and from MIDI notes, see Music Values and MIDI Notes.
Program changes and patch numbers are a key concept in MIDI playback and in DirectMusic. A program change assigns a particular instrument (also called a program or timbre) to a channel so that the notes sent to that channel are played with the appropriate sound. Instruments are identified by patch numbers. If the GM instrument set is loaded, a program change specifying patch number 1 always causes the channel to play its notes as an acoustic grand piano. The actual sound produced at the speakers depends on how the instrument is synthesized.
Because a single data byte is used to select the patch number in a program change, and only 7 bits in each data byte of a MIDI message are significant, a program change can select from a maximum of 128 instruments. To provide a greater choice, the MIDI specification allows for the use of up to 16,384 instrument banks, each containing up to 128 instruments.
To select an instrument from a different bank, the MIDI sequencer must first send a control change message called bank select. The 2 data bytes of this message are referred to as the most significant byte (MSB) and least significant byte (LSB), and they are combined to identify a bank. Once the bank has been selected, each subsequent program change selects an instrument from that bank.
In DirectMusic, the instrument patch number is not the 7-bit MIDI patch number but a 32-bit value that packs the MIDI patch number together with the MSB and LSB of the bank select and a one-bit flag for a drum kit. This extended patch number is returned by the IDirectMusicCollection8::EnumInstrument, IDirectMusicCollection8::GetInstrument, and IDirectMusicInstrument8::GetPatch methods. It can be changed for an instrument by using the IDirectMusicInstrument8::SetPatch method.
The organization of DirectMusic patch values is shown in the following table.
Bits | Purpose |
0-7 | MIDI patch number (bit 7 is always 0) |
8-15 | LSB bank select (bit 15 is always 0) |
16-23 | MSB bank select (bit 23 is always 0) |
24-30 | Unused |
31 | Flag for drum kit |