Microsoft DirectX 9.0

AdjustSound Sample


The AdjustSound sample shows how to create a DirectSound secondary buffer to play a WAV file, and how to change the parameters of the buffer.


Source: (SDK root)\Samples\C++\DirectSound\AdjustSound

Executable: (SDK root)\Samples\C++\DirectSound\Bin

User's Guide

Load a WAV file by clicking Sound File. Select Focus and Buffer Mixing options; note that the various settings are explained under Expected Behavior as you select them. Click Play. If you don't hear any sound, check the Status pane. The application might fail to create the buffer in hardware if this option has been selected.

By using the sliders you can adjust the frequency, pan, and volume dynamically as the buffer is playing.

Programming Notes

To set the focus behavior of the buffer, the application calls IDirectSound8::CreateSoundBuffer with DSBCAPS_GLOBALFOCUS or DSBCAPS_STICKYFOCUS, or neither of these flags. To set the memory location of the buffer, it sets either DSBCAPS_LOCHARDWARE or DSBCAPS_LOCSOFTWARE, or neither of these flags to allow DirectSound to create the buffer in a either hardware or software.

Parameters are set by using IDirectSoundBuffer8::SetFrequency, IDirectSoundBuffer8::SetPan, and IDirectSoundBuffer8::SetVolume.

For a simpler example of how to set up a DirectSound buffer without as many controls, see the Play Sound Sample.

See Also