DirectSound Essentials

This section gives a practical overview of how the various DirectSound interfaces are used in order to play and capture sound. The following topics are discussed:

·DirectSound Devices

·DirectSound Buffers

·DirectSound in 3-D

·DirectSound 3-D Buffers

·DirectSound 3-D Listeners

·DirectSoundCapture

·DirectSound Property Sets

·Optimizing DirectSound Performance

·Using Wave Files

·Reading Wave Data from a Resource

Note Most of the examples of method calls throughout this section are given in the C language form, which accesses methods by means of a pointer to a table of pointers to functions, and requires a this pointer as the first parameter in any call. For example, a C call to the IDirectSound::GetCaps method takes this form:

lpDirectSound->lpVtbl->GetCaps(lpDirectSound, &dscaps);

The same method call in the C++ form, which treats COM interface methods just like class methods, looks like this:

lpDirectSound->GetCaps(&dscaps);

Dsound.h contains macros that expand to either the C or C++ form of the method call, depending on the environment. These macros simplify the C calls and also make it possible to develop routines that can be used in either language. For example:

IDirectSound_GetCaps(lpDirectSound, &dscaps);