Microsoft Windows CE 3.0  

Creating a Capture Buffer

This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

You create a capture buffer by calling the IDirectSoundCapture::CreateCaptureBuffermethod of the DirectSoundCapture object.

One of the parameters to the method is a DSCBUFFERDESCstructure that describes the characteristics of the desired buffer. The last member of this structure is a WAVEFORMATEXstructure, which must be initialized with the details of the desired wave format. For more information on this structure, see Sound Data.

Note that if your application is using DirectSound as well as DirectSoundCapture, capture buffer creation can fail when the format of the capture buffer is not the same as that of the primary buffer. The reason is that some cards have only a single clock and cannot support capture and playback at two different frequencies.

The following example sets up a capture buffer that will hold 1 second of data:

/* In this example it is assumed that pDSC is a
valid pointer to a DirectSoundCapture object. */ DSCBUFFERDESC
{WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0}; // wFormatTag,
nChannels, nSamplesPerSec, mAvgBytesPerSec, // nBlockAlign,
wBitsPerSample, cbSize dscbd.dwSize = sizeof(DSCBUFFERDESC);
dscbd.dwFlags = 0; dscbd.dwBufferBytes = wfx.nAvgBytesPerSec;
dscbd.dwReserved = 0; dscbd.lpwfxFormat = &wfx; pDSCB = NULL;
HRESULT hr = pDSC->CreateCaptureBuffer(&dscbd, &pDSCB,

 Last updated on Tuesday, May 18, 2004

© 2004 Microsoft Corporation. All rights reserved.