Share via


Using Buffers Efficiently

[The feature associated with this page, DirectSound, is a legacy feature. It has been superseded by WASAPI and Audio Graphs. Media Casting have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Media Casting instead of DirectSound, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

When using streaming buffers, limit the frequency of notifications and data writes. Do not create buffers with many notification positions, or small buffers with notifications at very short intervals. A streaming buffer can work efficiently and reliably with as few as three notification positions.

Performance is affected when you make control changes on a secondary buffer. To improve performance, reduce the frequency of calls to IDirectSoundBuffer8::SetVolume, IDirectSoundBuffer8::SetPan, and IDirectSoundBuffer8::SetFrequency. For example, if you have a routine that moves a sound from the left to the right speaker in synchronization with animation frames, try calling the SetPan method only every second or third frame.

Keep in mind that 3D buffers in software make high demands on the central processing unit. To limit these demands you can do the following:

  • Put frequently-used sounds in hardware buffers if possible.

  • Don't create 3D buffers for sounds that won't benefit from the effect.

  • Use IDirectSound3DBuffer8::SetMode with the DS3DMODE_DISABLE flag to disable 3D processing on any 3D sound buffer that is no longer moving in relation to the listener.

  • Make parameter changes in batches, or use deferred settings to make changes to all buffers and the listener at once.

See Also