Microsoft DirectX 8.1 (Visual Basic)

Obtaining the 3-D Buffer Object

The DirectSound3DBuffer8 object is obtained from a secondary DirectSound buffer that has been created with the DSBCAPS_CTRL3D flag in the lFlags member of the DSBUFFERDESC type.

If your application is using the DirectMusic performance and audiopaths, you can create an audiopath containing a 3-D buffer by passing DMUS_APATH_DYNAMIC_3D as the lType parameter to DirectMusicPerformance8.CreateStandardAudioPath.

You can also create a suitable audiopath from a configuration object. An audiopath configuration can specify 3-D parameters for a buffer. When the audiopath is created, the 3-D properties of the buffer are initialized with these parameters.

To obtain an object representing a 3-D buffer in an audiopath, call DirectMusicAudioPath8.GetObjectInPath, with lStage set to DMUS_PATH_BUFFER, as in the following example:

Dim dsb As DirectSound3dBuffer8
 
Set dsb = dmAudioPath.GetObjectinPath(DMUS_PCHANNEL_ALL, _
  DMUS_PATH_BUFFER, 0, GUID_ALL, 0, IID_DirectSound3DBuffer)

The following example, where m_ds is a DirectSound8 object, shows how to create a DirectSound3DBuffer8 object in an application that is not using the DirectMusic performance:

Dim dsbd As DSBUFFERDESC
Dim dsBuffer As DirectSoundSecondaryBuffer8
Dim ds3dBuffer As DirectSound3DBuffer8

' Create the secondary buffer.
 
dsbd.lFlags = DSBCAPS_CTRL3D
Set dsBuffer = m_ds.CreateSoundBufferFromFile("sound.wav", dsbd)
 
' Obtain the 3-D buffer object.
 
Set ds3dBuffer = dsBuffer.GetDirectSound3DBuffer