Waveform Capture: (8) using "Capture buffer"

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.