Microsoft DirectX 8.1 (Visual Basic)

Effect Parameters

To set or retrieve parameters of sound effects, you must first obtain the appropriate object from the buffer that contains the effect. The following classes give you access to parameters of the DMOs supplied with DirectX Audio:

To retrieve an effect object, pass DMUS_PATH_BUFFER_DMO as the lStage parameter to DirectMusicAudioPath8.GetObjectInPath. If the audiopath contains more than one buffer, lBuffer must be the index of the buffer. For information on the index numbers of buffers in standard audiopaths, see the audiopath types under Standard Audiopaths.

The following sample code retrieves an interface for the gargle effect on a buffer. It then uses this interface to change a parameter of the effect. Assume that the DirectMusicAudioPath8 object dmAudioPath has been obtained by calling DirectMusicPerformance8.CreateAudioPath on an audiopath configuration object.

Dim gargleParams As DSFXI3DL2GARGLE
Dim gargleFX As DirectSoundFXGargle8

Set gargleFX = dmAudioPath.GetObjectinPath(DMUS_PCHANNEL_ALL, _
  DMUS_PATH_BUFFER_DMO, 0, DSFX_STANDARD_GARGLE, 0, _
  IID_DirectSoundFXGARGLE)
 
gargleParams = gargleFX.GetAllParameters
gargleParams.lRateHZ = DSFXGARGLE_RATEHZ_MIN 
gargleFX.SetAllParameters gargleParams

If your application is managing its own DirectSound buffers, you might need to take steps to ensure that changes in effect parameters take place immediately. For efficiency, DirectSound processes 100 milliseconds of sound data in a buffer, starting at the play cursor, before DirectSoundSecondaryBuffer8.Play is called. This can happen after any of the following calls:

If you call any of these methods and then change effect parameters, the new parameters will not be heard until the preprocessed data has been played. To avoid this situation, do one of the following: