DirectX SDK |
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 deals 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 instrument by assigning a different MIDI patch number to the channel.
Voice messages are of the following types:
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. |
These descriptions apply to standard MIDI messages, not MIDI data that has been converted to performance message format. For example, a pair of MIDI messages to start and stop a note are combined by DirectMusic into a single message giving the duration of the note. DirectMusic messages also contain much additional information about the timing and routing of the message.
The data bytes of a note-on message represent the pitch and velocity. In most cases, a pitch value of 0 represents C below subcontra C (called C0 in MIDI notation), 12 represents subcontra C (or C1), 60 is middle C (or C5), and so on. For drum kits, the data byte represents a particular drum sound instead. For example, as long as the General MIDI (GM) percussion key map is being adhered to, a value of 60 represents a high bongo sound. Channel 10 is reserved for drum kits, so the synthesizer knows that note-on messages on that channel are to be treated differently than on other channels.
For information on how DirectMusic converts to and from MIDI notes, see Music Values and MIDI Notes.
Program changes and patch numbers are very important 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. (Of course, 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.
This topic pertains only to applications written in C++. DirectX for Visual Basic does not allow applications to change patch numbers except by using the DirectMusicPerformance.SendPatchPMSG method.
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 1-bit flag for a drum kit. This extended patch number is returned by the IDirectMusicCollection::EnumInstrument, IDirectMusicCollection::GetInstrument, and IDirectMusicInstrument::GetPatch methods. It can be changed for an instrument by using the IDirectMusicInstrument::SetPatch method.
The organization of DirectMusic patch values is as follows:
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 |