Tutorial 2: Sound Capture

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 Wave.c, a module found with the DSShow3D sample application in the DirectX SDK. In order to implement the techniques shown in the tutorial, you must add Wave.c and Wave.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 Wave.c 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:

·Step 1: Set Up DirectSoundCapture

·Step 2: Set the Capture Format

·Step 3: Create the Capture Buffer

·Step 4: Set Up Capture Notification

·Step 5: Create the Wave File

·Step 6: Handle the Capture Notifications

·Step 7: Stream Data to the Wave File

·Step 8: Stop Capturing

·Step 9: Shut Down DirectSoundCapture