Audio recorder program based on API

Source: Internet
Author: User
Tags range

First, the basic knowledge of digital audio

Fourier series:

The waveform of any period can be decomposed into several sine waves, the frequencies of which are integral times. The frequencies of other positive line waves in the series are integral times of the base frequencies. The base frequency is called first-level harmonics.

Pcm:

Pulse code modulation, pulse code modulation, that is, the waveform according to the fixed-cycle frequency sampling. In order to ensure the quality of the sampled data, the sampling frequency must be twice times the maximum frequency of the sample sound, which is the Nyquist frequency.

Sample size: Used to store the amplitude level of the number of digits, the actual pulse code is the number of steps, the larger the number of digits indicates the higher the precision, this point learned that the digital logic circuit should be clear.

Sound intensity:

The square of the waveform amplitude. The difference in two sound intensities is often measured in decibels (db).

The calculation formula is as follows:

20*log (A1/A2) decibels. The A1,A2 is an amplitude of two voices. If the sample size is 8 bits, the sampling dynamic range is 20*log (256) DB =48db. If the sample size is 16 bits, the sampling dynamic range of 20*log (65536) is approximately 96 decibels, close to the human auditory limit and the pain limit, which is ideal for line music. Windows supports both 8-bit and 16-bit sampling sizes.

Ii. related API functions, structures, messages

For recording devices, Windows provides a set of wave*** functions that are more important than the following:

Open Recording device function

MMRESULT waveInOpen(
 LPHWAVEIN phwi,      //输入设备句柄
 UINT uDeviceID,      //输入设备ID
 LPWAVEFORMATEX pwfx,    //录音格式指针
 DWORD dwCallback,     //处理MM_WIM_***消息的回调函数或窗口句柄,线程ID
 DWORD dwCallbackInstance,
 DWORD fdwOpen       //处理消息方式的符号位
);

Preparing a caching function for a recording device

MMRESULT waveInPrepareHeader( HWAVEIN hwi, LPWAVEHDR pwh, UINT bwh );

Add a cache to the input device

MMRESULT waveInAddBuffer( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh );

Start recording

MMRESULT waveInStart( HWAVEIN hwi );

Clear Cache

MMRESULT waveInUnprepareHeader( HWAVEIN hwi,LPWAVEHDR pwh, UINT cbwh);

Stop Recording

MMRESULT waveInReset( HWAVEIN hwi );

Turn off recording equipment

MMRESULT waveInClose( HWAVEIN hwi );

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.