Platform SDK: DirectX

Step 3: Create the Capture Buffer

[Visual Basic]

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

[C++]

Once you have ensured that the WAVEFORMATEX structure is valid for the user's device, you can go ahead and create a capture buffer in that format.

    dscbDesc.dwSize = sizeof(DSCBUFFERDESC);
    dscbDesc.dwFlags = 0;
    // Buffer will hold one second's worth of audio
    dscbDesc.dwBufferBytes = wfx.nAvgBytesPerSec;
    dscbDesc.dwReserved = 0;
    dscbDesc.lpwfxFormat = &wfx;
 
    if FAILED(IDirectSoundCapture_CreateCaptureBuffer(lpdsc, 
            &dscbDesc, &lpdscb, NULL))
        return FALSE;
 

You now have a pointer to the buffer object in lpdscb.

Next: Step 4: Set Up Capture Notification