Microsoft DirectX 8.1 (Visual Basic) |
The DirectMusic loader can load compressed wave-form audio files in any format supported by the audio compression manager (ACM), as well as uncompressed wave files.
Segments based on wave files are played just like any other segment. They pass through the performance as messages and are always played on channel 0 of the audiopath. Although waves are not synthesized in the same sense as musical notes, they do pass through the synthesizer and can be manipulated by MIDI controllers.
The following example code, where dmp is a DirectMusicPerformance8 object, sends a pitch change MIDI message to channel 0 on the default audiopath. The change in pitch affects every wave played on that audiopath.
Private Sub sldrPitch_Change()
Dim hi As Byte, lo As Byte
' Split value into 7-bit bytes. The value returned by the slider
' is in the range 0 to 16383.
hi = Fix(sldrPitch.Value / 128)
lo = CByte(sldrPitch.Value And 127)
' Send pitch bend message.
Call dmp.SendMIDIPMSG(0, DMUS_PMSGF_REFTIME, 0, &HE0, _
lo, hi)
End Sub
Note The technique shown in the example is not guaranteed to work if your application uses multiple audiopaths. In DirectX for Visual Basic, there is no way to direct an application-created message to a particular audiopath. Because
Waves can also be embedded in DirectMusic Producer files, where they can behave somewhat like
Waves in segment (.sgt) files must be downloaded to the synthesizer before being played. They are downloaded when the segment's bands are downloaded. For more information, see Downloading and Unloading Bands.