Obtaining an IDirectSound3DBuffer Interface Pointer
To obtain a pointer to an IDirectSound3DBuffer interface, you must first create a secondary 3D sound buffer. Do this by using the IDirectSound::CreateSoundBuffer method, specifying the DSBCAPS_CTRL3D flag in the dwFlags member of the accompanying DSBUFFERDESC structure. Then, use the IDirectSoundBuffer::QueryInterface method on the resulting buffer to obtain a pointer to an IDirectSound3DListener interface for that buffer.
// lpDsbSecondary was created with DSBCAPS_CTRL3D.
hr = lpDsbSecondary->QueryInterface(IID_IDirectSound3DBuffer,
&lpDs3dBuffer);
if(SUCCEEDED(hr)) {
// Set 3D parameters of this sound.
.
.
.
}
DirectSound supports monaural or a stereo wave format for 3D sound buffers. However, 3D positional sound works best with monaural sounds because the 3D processing creates a stereo output from a monaural input. If an application uses stereo sound buffers, the left and right values for each sample are averaged before the 3D processing is applied. To position the two stereo channels at different locations, the application must divide the stereo stream into two monaural streams, and write this data into two monaural sound buffers.
Note Pan control conflicts with 3D processing. Therefore, if both DSBCAPS_CTRL3D and DSBCAPS_CTRLPAN are specified, DirectSound causes a creation request to fail.