Using Hardware Mixing

[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.]

Modern sound cards are designed to connect to the peripheral component interconnect (PCI) local bus. This bus provides the card with rapid access to system memory. As a result, it is practical for the audio processor to mix data directly from buffers in system memory, and it is unnecessary to have memory buffers on the card itself.

On PCI cards, static buffers and streaming buffers are effectively the same, and the same buffers may be reported in DSCAPS as both static and streaming buffers. The DSBCAPS_STATIC flag in DSBUFFERDESC does not affect the location of a DirectSound buffer.

The following tips will help you make the most of hardware mixing.

  • At run time, use the IDirectSound8::GetCaps method to determine what formats are supported by the sound-accelerator hardware, and use only those formats if possible.

  • Create sound buffers first for the sounds you use the most. There is a limit to the number of buffers that can be mixed by hardware.

  • To force a buffer to be created in hardware, specify the DSBCAPS_LOCHARDWARE flag in the dwFlags member of the DSBUFFERDESC structure. If you do this and resources for hardware mixing are not available, the IDirectSound8::CreateSoundBuffer method will fail.

  • Use voice management to enable DirectSound to assign buffers to hardware resources when they are available, and to force termination of less important buffers in order to free hardware resources. See Dynamic Voice Management.