Static and Streaming Sound Buffers

A static sound buffer contains a complete sound in memory. These buffers are convenient because the entire sound can be written once to the buffer.

A streaming buffer only represents a portion of a sound, such as a buffer that can hold three seconds of audio data that plays a two-minute sound. In this case, your application must periodically write new data into the sound buffer. However, a streaming buffer requires much less memory than a static buffer.

When creating a sound buffer, you can indicate that a buffer is static by specifying the DSBCAPS_STATIC flag. If this flag is not specified, the buffer is a streaming buffer.

If a sound device has onboard sound memory, DirectSound will attempt to place static buffers in the hardware memory. These buffers can then take advantage of hardware mixing, with the benefit that the processing system incurs little or no overhead to mix these sounds. This is particularly useful for sounds that will be played more than once, such as the sound a character makes while walking or a firearm going off, since the sound data only needs to be downloaded once to the hardware memory.

Streaming buffers are generally located in main system memory to allow efficient writing to the buffer, although hardware mixing can be used on peripheral component interconnect (PCI) machines or other fast buses. There are no requirements on the use of streaming buffers. For example, you can write an entire sound into a streaming buffer if it is big enough. In fact, if you do not intend to use the sound more than once, it may be more efficient to use a streaming buffer because there is no need for the sound data to be downloaded to the hardware memory.

Note The designation of a buffer as static or streaming is used by DirectSound to optimize performance; it does not restrict how you can use the buffer.