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 );