Share via


SecondaryBuffer.GetEffects(Int32) Method (Microsoft.DirectX.DirectSound)

How Do I...?

  • Use Effect Parameters

Retrieves a Microsoft DirectSound effect object at a particular index from a SecondaryBuffer object.

Definition

Visual Basic Public Function GetEffects( _
    ByVal index As Integer _
) As Object
C# public object GetEffects(
    int index
);
C++ public:
ObjectLeave SiteGetEffects(
    int index
);
JScript public function GetEffects(
    index : int
) : ObjectLeave Site;

Parameters

index System.Int32
Index of DirectSound effect object to retrieve from the SecondaryBuffer object.

Return Value

System.Object
A DirectSound effect object, such as EchoEffect, from the SecondaryBuffer object.

Remarks

When retrieving an effect object, you must cast it into the appropriate effect object type as seen in the example below.

[C#]WavesReverbEffect wre = (WavesReverbEffect)buffer.GetEffects(0);

Exceptions

ArgumentExceptionLeave Site

An invalid parameter was passed to the called method.

ControlUnavailableException

The buffer control (volume, pan, and so on) requested by the caller is not available. Controls must be specified when the buffer is created.

ObjectNotFoundException

The requested object was not found.

SoundException

Root exception type for all DirectSound exceptions. Derives from DirectXException.

How Do I...?

Use Effect Parameters

This C# example demonstrates how to use the parameters of an effect object from a SecondaryBuffer object.

The buffer object in this code snippet is assumed to be the SecondaryBuffer from the code in Add Effects to a SecondaryBuffer Object.

              [C#]
              

//Retrieve the effects object and
//the effect param sturctures and edit parameters.
EchoEffect echo = (EchoEffect)buffer.GetEffects(0);
EffectsEcho echo_params = echo.AllParameters;

echo_params.LeftDelay = 250.0f;
echo_params.RightDelay = 100.0f;
echo_params.Feedback = 85.0f;
echo_params.PanDelay = 1;
echo_params.WetDryMix = 50.0f;

ChorusEffect chorus = (ChorusEffect)buffer.GetEffects(1);
EffectsChorus chorus_params = chorus.AllParameters;

chorus_params.Delay = 15.0f;
chorus_params.Depth = ChorusEffect.DepthMax;
chorus_params.Phase = ChorusEffect.PhaseNegative90;
chorus_params.Waveform = ChorusEffect.WaveSin;
chorus_params.WetDryMix = 50.0f;

//Set the new parameters and play the buffer.
echo.AllParameters = echo_params;
chorus.AllParameters = chorus_params;
buffer.Play(0,BufferPlayFlags.Default);

See Also