Static and Streaming Sound Buffers

A static sound buffer contains a complete sound in memory. These buffers are convenient because your application can write the entire sound to the buffer at once. A streaming sound buffer represents only a portion of a sound, such as a buffer that can hold 3 seconds of audio data that plays a 2-minute sound. In this case, your application must periodically write new data to the sound buffer. However, a streaming buffer requires much less memory than a static buffer.

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

If a sound device has onboard sound memory, DirectSound attempts to place static buffers in the hardware memory. These buffers can then take advantage of hardware mixing, and the processing system incurs little or no overhead to mix these sounds. This is particularly useful for sounds your application plays more than once, such as the sounds of footsteps or a weapon, because the sound data must be downloaded only once to the hardware memory.

Streaming buffers are generally located in main system memory to allow efficient writing to the buffer, although you can use hardware mixing on peripheral component interconnect (PCI) machines or other fast buses. There are no requirements for using streaming buffers. For example, you can write an entire sound to a streaming buffer if the buffer is big enough. In fact, if you do not intend to use the sound more than once, it can 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 DirectSound uses the designation of a buffer as static or streaming to optimize performance; it does not restrict how you can use the buffer.