Share via


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

How Do I...?

  • Use Effect Parameters

Retrieves a range of Microsoft DirectSound effect objects from a SecondaryBuffer object.

Definition

Visual Basic Public Function GetEffects( _
    ByVal startIndex As Integer, _
    ByVal count As Integer _
) As Object()
C# public object[] GetEffects(
    int startIndex,
    int count
);
C++ public:
array<ObjectLeave Site^>^ GetEffects(
    int startIndex,
    int count
);
JScript public function GetEffects(
    startIndex : int,
    count : int
) : ObjectLeave Site[];

Parameters

startIndex System.Int32
Starting index of the range of DirectSound effect objects to retrieve from the SecondaryBuffer object.
count System.Int32
The number of DirectSound effect objects to retrieve from the SecondaryBuffer object.

Return Value

System.Object[]
An array of DirectSound effect objects, such as EchoEffect, from the SecondaryBuffer object.

Remarks

To retrieve an effect object out of the returned array, first retrieve it as an object, than cast it into the appropriate effect object type as seen in the example below.

[C#]object[] effects_objects = buffer.GetEffects(0,1);
WavesReverbEffect wre = (WavesReverbEffect)effects_objects[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