DirectX SDK

Tutorial 2: Capturing a Sound

[Visual Basic]

The information in this topic pertains only to applications written in C and C++. See DirectSound Visual Basic Tutorials.

[C++]

This tutorial shows how to implement DirectSoundCapture to capture a sound (typically from the microphone input) and write it to a wave file.

The functions for creating, writing, and closing wave files are in Wavwrite.cpp, a module found with the CaptureSound sample application in the DirectX SDK. In order to implement the techniques shown in the tutorial, you must add Wavwrite.cpp and Wavwrite.h to your project and link to Winmm.lib. You must also add Debug.c and Debug.h from the same sample directory, or else edit the calls to the ASSERT macro in Wavwrite.cpp to call the standard assert function.

The method calls in this tutorial are made through the macros defined in Dsound.h, which are valid for both C and C++.

The tutorial is broken down into the following steps: