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:

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, as shown in the following code example.

IDirectSound_GetCaps(lpDirectSound, &dscaps);

Sample Applications

The source code for the following two DirectSound sample applications is installed with Platform Builder and can be found in the %_WINCEROOT%\Public\DirectX\SDK\Samples\DSound directory:

  • CaptureEcho.exe

    This application continuously captures audio information from a DirectSound capture buffer and plays it back using a streaming DirectSound buffer. The total execution time and the size of the transfer block are configurable with command line options.

  • DSPlay.exe

    The DSPlay application plays a standard wave file (.wav) using DirectSound. You can also provide a loop count to cause the sound to be looped any number of times.

The code for these applications is not automatically included in a customized SDK created for a Windows CE-based platform using the Platform Builder IDE. You must include them manually when creating the SDK.

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.