A CaptureBuffer is a buffer of a specified length that reads audio from a Capture object which represents the capture (or input) device, into a one-dimensional array of bytes with a specified WaveFormat.
The capture buffer can be used in two ways. As a static buffer, which stops when the buffer is full, or a streaming buffer, where once the buffer is full it returns to the start and begins overwriting the samples. You obviously need to read and do something with the data before this happens.
One method is to set up a Notify object, giving it an array of BufferPositionNotify objects. These contain the handle for an event, and the buffer offset at which to fire that event. This is usually an AutoResetEvent, monitored by a separate thread which then reads a section of the buffer, and processes that data. One problem is that they can be unreliable if another program is also using DirectSound notifications at the same time. You may start receiving those as well, or even have yours go missing.
The other option is to monitor it yourself, periodically checking the write position of the capture buffer through its GetCurrentPosition function. When you see that it has moved past a certain point (i.e. an offset position) you can then process that chunk of data as before.
To make a CaptureBuffer, first instantiate a new Capture object. Use no parameters or a Guid.Empty for the default device, or give it the Guid or an IntPtr to the device you want to use. The available devices can be discovered by creating a CaptureDevicesCollection object.
Then use this Capture object to a create a new CaptureBuffer, along with a WaveFormat, and the length of the buffer you want.
Reading the buffer is accomplished by simply calling the Read function with the start position, number of bytes to read, and a LockFlag to say if you want to prevent the data from being overwritten while you read it. Finally, cast the resultant Array to an array of bytes.

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.
Your explication is simple but effective
thank you !
thank you for your paper. if you give an example, it can able to perfect explanation.
Very good and nice, thanks for the post.
Can you explain me how to play the sound while capturing.
Unfortunately the docs on this object, as well as this post, are not specific enough to actually implement this in code and this writeup doesn’t add anything new. Read() takes an array of int values called “ranks”. What does this mean? The other overload take the number of bytes to read. How do you figure this out? The values I’m getting from GetCurrentPosition() don’t make any sense.