Capturing a sound consists of the following steps:
1. Start the buffer by calling the Idirectsoundcapturebuffer8::start method. Formally, you should set dscbstart_looping as the dwflags parameter so that the buffer will continue to run instead of stopping when it reaches the end of the buffer. The audio data obtained from the input device is populated starting at the beginning of the buffer.
2. Wait until the desired amount of data is reached. A decision on when to capture the pointer to a specific location method, see Waveform Capture: (6) "Capture buffer" notification.
3. When a sufficient amount of data is reached, a portion of the capture buffer is locked by calling the Idirectsoundcapturebuffer8::lock method.
To make sure that the area of memory you are trying to lock is not the area that will be used for capturing, you can first get the position of the read pointer by calling the Idirectsoundcapturebuffer8::getcurrentposition method.
You pass the lock method as an argument to the size and offset of the memory block that will be read. This method returns a pointer to the starting address of the memory block and the size of the piece. If the area wraps from the end of the buffer to the beginning, two pointers are returned, and the first pointer is used for each part of the area. If the locked memory area is not wrapped, the second pointer is null.
4. Copy the data from the buffer using the address and block size returned by the lock method.
5. Unlock the buffer using the Idirectsoundcapturebuffer8::unlock method.
6. Repeat the 2~5 step until you are ready to stop capturing the data. Then call the Idirectsoundcapturebuffer8::stop method.