Music Values and MIDI Notes

Notes in a pattern within a DirectMusic style are not fixed notes. Rather they are music values that become actual notes only when they are transposed to the current chord according to the current play mode and subchord level.

A music value is a representation of the note's intended role. For example, a music value can say that a note is intended to be played as the second position in the chord, up one in the scale. When that music value is applied to a particular chord, it is converted to the appropriate MIDI note, the one in the second position in the chord, up one in the scale. For an explanation of the data format of music values, see DMUS_NOTE_PMSG.

The play mode determines how to interpret the note against the chord. For example, if the mode is DMUS_PLAYMODE_NORMALCHORD, the note is interpreted against the intervals of the chord and scale, based on the root of the chord. If the mode is DMUS_PLAYMODE_FIXEDTOKEY, the note is interpreted as a linear value. For more information on the various play modes, see DMUS_PLAYMODE_FLAGS.

The subchord level is a value in the range 0 to 31 that determines which subchords can be used in establishing the music value. A DirectMusic chord (as represented by a DMUS_CHORD_PARAM or DMUS_CHORD_KEY structure) actually consists of one or more subchords, allowing for complex harmonies with multiple parallel chord progressions. Each subchord supports one or more levels, as specified in the dwLevels member of the DMUS_SUBCHORD structure. The author of the music defines the supported levels for each subchord.

When a segment is played, each note is encapsulated in a DMUS_NOTE_PMSG structure. The bMidiValue member of this structure holds the MIDI note value that would normally be sent to the synthesizer. The message also holds the original music value as well as the play mode and subchord level that were used in transposition. A tool can use this information to alter the note in any way it likes. For example, a tool could intercept a note that was transposed in a certain play mode, change the play mode, obtain a new MIDI note by using the IDirectMusicPerformance::MusicToMIDI method, and put the new value in the bMidiValue member of the message before passing it on.

The MusicToMIDI method is at the heart of the style playback mechanism of DirectMusic. It is called by the style track to convert its internal music values into notes, using the current chord in the chord track.

If a tool wants to go the opposite way and obtain a new music value from a MIDI note using a different chord, play mode, or subchord level, it calls the IDirectMusicPerformance::MIDIToMusic method. The new music value can be placed in the wMusicValue member of the note message, where it might be of use to other application-defined tools, but of course the DirectMusic output tool will ignore it and play the note in bMidiValue as usual.