DirectX SDK |
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 specify 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.
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 CONST_DMUS_PLAYMODE_FLAGS.
The subchord level is a value in the range from 0 trhough 31 that determines which subchords can be used in establishing the music value. A DirectMusic chord consists of one or more subchords, allowing for complex harmonies with multiple parallel chord progressions. Each subchord supports one or more levels. 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 type. The midiValue member of this type 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.
Music values and play modes are primarily of interest to tools, which are not supported by DirectX for Visual Basic. If you want to inject a note into the performance by using DirectMusicPerformance.SendNotePMSG, specify the desired midiValue in the DMUS_NOTE_PMSG type, and ignore the musicValue, playModeFlags, and subChordLevel members.
The following code example sends a message to play middle C immediately:
' perf is the DirectMusicPerformance. Dim note As DMUS_NOTE_PMSG note.midiValue = 60 note.mtDuration = 500 note.flags = DMUS_NOTEF_NOTEON note.velocity = 127 Call perf.SendNotePMSG(0, DMUS_PMSGF_REFTIME, 1, note)
For more information on the various play modes, see DMUS_PLAYMODE_FLAGS.
The subchord level is a value in the range from 0 through 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) 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 reverse the process 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, in which it might be of use to other application-defined tools. However, the DirectMusic output tool ignores it and plays the note in bMidiValue as usual.