Effect Parameters

To set or retrieve parameters of sound effects, you must first obtain the appropriate effect object from the buffer that contains the effect.

Objects of the following classes give you access to parameters of the Microsoft DirectX Media Objects (DMOs) supplied with DirectX.

To retrieve an effect object, use the SecondaryBuffer.GetEffects method. This method can retrieve a single object or an array of objects.

The following Microsoft Visual Basic sample code retrieves an EchoEffect object representing the first effect set on a buffer, and sets two parameters on the effect. Assume that fxBuffer is a SecondaryBuffer object.
[Visual Basic]Dim echoFx As EchoEffect
Dim echoParams As EffectsEcho
echoFx = fxBuffer.GetEffects(0)
echoParams = echoFx.AllParameters
echoParams.LeftDelay = 500
echoParams.RightDelay = 500
echoFx.AllParameters = echoParams

Effect parameters can be changed while the buffer is playing.

For efficiency, Microsoft DirectSound preprocesses 100 milliseconds of sound data in a buffer, starting at the play cursor, before SecondaryBuffer.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:

  • Write data to the buffer after effect parameters have been changed, not before.
  • Call Stop or SetCurrentPosition on the buffer to force preprocessing after you have set the parameters.
Show: