Platform SDK: DirectX |
The information in this topic pertains only to applications written in C and C++. See DirectSound Visual Basic Tutorials.
The tutorial requires the following definitions and global declarations:
#define NUMCAPTUREEVENTS 2 LPDIRECTSOUNDCAPTURE lpdsc; LPDIRECTSOUNDCAPTUREBUFFER lpdscb; LPDIRECTSOUNDNOTIFY lpdsNotify; DSCBUFFERDESC dscbDesc; HANDLE rghEvent[NUMCAPTUREEVENTS]; DSBPOSITIONNOTIFY rgdscbpn[NUMCAPTUREEVENTS]; WAVEFORMATEX wfx = {WAVE_FORMAT_PCM, 1, 22050, 44100, 2, 16, 0}; HMMIO hmmio; MMCKINFO mmckinfoData, mmckinfoParent; MMIOINFO mmioinfo; DWORD dwTotalBytesWritten;
It is not necessary to create a DirectSound object in order to use DirectSoundCapture. However, if your application will be playing back sound as well as recording it, you should create DirectSound first.
In this tutorial, all the initialization of the capture system takes place in a function called InitDSoundCapture, which takes no parameters. The first step is to create the DirectSoundCapture object. You associate the object with the default capture device by passing NULL as the first parameter to the DirectSoundCaptureCreate function.
BOOL InitDSoundCapture(void) { if FAILED(DirectSoundCaptureCreate(NULL, &lpdsc, NULL)) return FALSE;