Playback Overview |
The Microsoft DirectSound Device object represents a sound playback device and is used to manage that device and create sound buffers.
Multiple applications can create Device objects for the same sound device. When the input focus changes between applications, the audio output automatically switches from one application's streams to the other's. As a result, applications do not have to repeatedly play and stop their buffers when the input focus changes.
The primary buffer holds the audio that the listener will hear. Secondary sound buffers each contain a single sound or stream of audio. DirectSound automatically creates a primary buffer, but it is the application's responsibility to create secondary buffers. When sounds in secondary buffers are played, DirectSound mixes them in the primary buffer and sends them to the output device. Only the available processing time limits the number of buffers that DirectSound can mix.
Buffers are represented by either the Buffer class or the SecondaryBuffer class. Most applications use only the SecondaryBuffer class, which inherits from Buffer. However, an object representing the primary buffer must be a Buffer object.
A short sound can be loaded into a buffer in its entirety and played at any time by a simple method call. Longer sounds have to be streamed. An application can ascertain when it is time to stream more data into the buffer either by polling the position of the play cursor or by requesting notification when the play cursor reaches certain points.
Managed Microsoft DirectX provides a method for loading nonstreaming (static) buffers from a WAV file directly into a secondary buffer but, for streaming buffers, you are responsible for parsing the file and copying the data into the buffer.
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center