Audio capture technology on Windows

Source: Internet
Author: User

In the production of the publishing side, you need to collect the sound card output signal, in order to mix with the microphone input signal, for audio processing technology, mainly the following:

    • Capture Microphone Input
    • Collect sound card output
    • Send audio data to the sound card for playback
    • Mixing multi-channel audio inputs

Here are two codes to refer to:

A.XP DirectSound Audio acquisition with Echo cancellation

Windows Core Audio with echo cancellation above B.vista

API for audio processing on 1.Windows

On the Windows operating system, the most commonly used audio processing technologies include: Wave series API functions, DirectSound, Core audio.

Of these, Core audio can only be used in more than Vista (including Vista) operating systems, mainly to replace the Wave series API functions and DirectSound.

Core Audio is also more powerful, enabling the acquisition of microphones, the acquisition of sound card output, and the playback of sound control.

The Wave series API functions are mainly used to achieve the acquisition of the microphone input (using the WaveIn Series API functions) and control the playback of the sound (after using the Waveout series functions).

DirectSound can achieve the function estimate and Wave series API almost, may be stronger (because no use of DirectSound, not sure!).

In order to realize the compatibility of the acquisition module to the operating system better, basically the acquisition of microphone input using the WaveIn series API function more;

In a Windows XP system, there is no direct API to capture the output of the sound card, so the acquisition of the sound card output by Windows XP can be tricky. It is often possible to choose a sound card that supports mixing, and then capture it by using a sound card's mixing module, but not all sound cards support mixing, and such schemes are not universal.

To achieve universality, you can use the way of virtual sound card to achieve, from the drive layer to obtain the sound card output data, but this scheme is more difficult to achieve.

In more than Vista systems, such as Win7, you can use the API functions in core audio to achieve the ability to collect sound card output.

For the implementation of the mixing module, the basic method is to use a custom mixing algorithm to complete the function, the system does not have a direct API function to call.

2. Using the WaveIn Series API functions for microphone input acquisition

The API functions involved:

    • Waveinopen

      The audio capture device is turned on, and the device handle is returned after success, and subsequent APIs need to use the handle

      The calling module needs to provide a callback function (WAVEINPROC) to receive the collected audio data

    • Waveinclose

      Turn off the Audio capture module

      After success, the device handle returned by Waveinopen will no longer be valid?

    • Waveinprepareheader

      Preparing the space for the audio capture data cache

    • Waveinunprepareheader

      Emptying the data cache for audio capture

    • Waveinaddbuffer

      Provide ready-to-use audio data caches to audio capture devices

      You need to call Waveinprepareheader before calling the API.

    • Waveinstart

      Acquisition of audio data by controlling the audio acquisition device

    • Waveinstop

      Control audio acquisition device stop audio data acquisition

Once the audio data has been collected by the acquisition device, the callback function set in Waveinopen is called.

The parameters include a message type, which can be manipulated according to its message type.

If the Wim_data message is received, the new audio data is collected so that the audio data can be processed as needed.

3. Use core audio to capture sound card output

The interfaces involved are:

    • Immdeviceenumerator

    • Immdevice

    • Iaudioclient

    • Iaudiocaptureclient

Main process:

    • Creating a multimedia Device enumerator (Immdeviceenumerator)

    • Get the sound card interface (Immdevice) via the multimedia device enumerator

    • Obtaining the sound card client interface via the sound card Interface (iaudioclient)

    • Through the sound card Client interface (iaudioclient) to obtain audio parameters of the sound card output, initialize the sound card, get the size of the sound card output buffer, turn on/Stop the acquisition of the sound card output

    • Acquisition of sound card output data and control of internal buffers via the sound card capture Client interface (iaudiocaptureclient)

4. Commonly used mixing algorithms

Mixing algorithm is the multi-channel audio input signal according to a certain rule of operation (multi-channel audio signal added to do the limiting processing), to obtain a mixed audio, and as the process of output.

I've done this one, and I've been searching for a bit. There are several mixing algorithms:

    • Multiple audio input signals are added directly and as output

    • The multi-channel audio input signal is added directly and then divided by the number of mixing channels to prevent overflow

    • The multi-channel audio input signal is added directly and after the clip operation (the data is limited to the maximum and minimum), if there is overflow, set the maximum value

    • The multi-channel audio input signal is added directly to and after saturation processing, near the maximum distortion

    • The multi-channel audio input signal is added directly after the sum, do normalization processing, all multiply a coefficient, so that the amplitude of normalization

    • Using the attenuation factor to limit the amplitude after adding the multi-channel audio input signal directly

Finish

Related Article

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.