Microsoft DirectX 8.1 (Visual Basic)

Setting Effects on Buffers

If you are playing segments authored in DirectMusic Producer with audiopath configurations, any effects are set up when you create the audiopath from the configuration object. A standard audiopath might also contain effects. However, in some cases you may prefer to implement an effect on a custom audiopath at run time or add an effect to a standard audiopath. For example, you might want to add an effect to a standard audiopath so that you can apply the effect to wave or MIDI files.

To apply an effect to an audiopath, first obtain a DirectSoundSecondaryBuffer8 object for a buffer on the path. Then set one or more effects on that buffer by using DirectSoundSecondaryBuffer8.SetFX. The audiopath must be inactive.

To learn how to obtain a buffer object, see Retrieving Objects from an Audiopath. For information on how to identify standard audiopath buffers in the call to GetObjectInPath, see the audiopath types under Standard Audiopaths.

The following sample code, where dmPerformance is a DirectMusicPerformance8 object, sets a standard audiopath, retrieves a buffer from the path, and sets an echo effect on the buffer:

Dim dmAudioPath As DirectMusicAudioPath8
Dim dsBuffer As DirectSoundSecondaryBuffer8
Dim DSEffects(0) As DSEFFECTDESC
Dim lResults(0) As Long

' Create a standard audiopath with a source and
' environment reverb buffers. Don't activate the path;
' SetFX fails if the buffer is running.
 
Set dmAudioPath = dmPerformance.CreateStandardAudioPath( _
  DMUS_APATH_DYNAMIC_3D, 128, False)
 
' Get the buffer in the audiopath.
 
Set dsBuffer = dmAudioPath.GetObjectinPath(DMUS_PCHANNEL_ALL, _
  DMUS_PATH_BUFFER, 0, GUID_ALL, 0, IID_DirectSoundSecondaryBuffer)
 
' Describe the effect.
 
DSEffects(0).lFlags = 0
DSEffects(0).guidDSFXClass = DSFX_STANDARD_ECHO
 
' Set the effect on the buffer.
 
dsBuffer.SetFX 1, DSEffects, lResults
 
' You can check the value of lResults(0) here to see if and how 
' the effect was allocated.
 
dmAudioPath.Activate (True)