Microsoft DirectX 8.1 (Visual Basic)

Playing Sounds on Audiopaths

If your application has created a default audiopath in the call to DirectMusicPerformance8.InitAudio, you can play a segment on this path by omitting the AudioPath parameter of  DirectMusicPerformance8.PlaySegmentEx.

If there is no default audiopath, or if you want to play a segment on another path, specify the audiopath by using one of the following techniques:

Note   An audiopath created in response to the DMUS_SEGF_USE_AUDIOPATH flag is automatically released as soon as the segment has stopped playing. If the audiopath contains an effect such as reverberation, the effect is cut short prematurely. To prevent this from happening, the application should create the audiopath manually and release it only after a suitable delay.

Bands are not downloaded for segments played with the DMUS_SEGF_USE_AUDIOPATH flag unless automatic downloading is enabled. For more information, see Automatically Downloading Bands.

The following sample code, where dmp is a DirectMusicPerformance8 object and dmSeg is a DirectMusicSegment8 object representing any type of sound file, plays the segment on an embedded audiopath configuration if one is available. If an error occurs on the call to DirectMusicSegment8.GetAudioPathConfig, the value of path remains Nothing and the segment is played on the default audiopath.

Dim path As DirectMusicAudioPath8
Dim Config As IUnknown

If Not (dmSeg Is Nothing) Then

  On Error GoTo NOCONFIG
  Set path = Nothing
  Set Config = dmSeg.GetAudioPathConfig
  Set path = dmp.CreateAudioPath(Config, True)
NOCONFIG:
  On Error Resume Next
  dmp.PlaySegmentEx dmSeg, 0, 0, , path

End If

If you have an audiopath object, you can change the volume by using DirectMusicAudioPath8.SetVolume. Unlike the DirectMusicPerformance8.SetMasterVolume method, which affects all sounds playing on the synthesizer, this method sets the volume only on the performance channels playing on this audiopath.