这段时间写一个录音的控件,参考了一些资料以后,决定采用WavIXXX进行录音以及播放,最后生成WAV格式文件后再使用Lame压缩成MP3格式。
1.录音初始化格式
代码
typedef struct tWAVEFORMATEX
{
WORD wFormatTag; /* format type */
WORD nChannels; /* number of channels (i.e. mono, stereo...) */
DWORD nSamplesPerSec; /* sample rate */
DWORD nAvgBytesPerSec; /* for buffer estimation */
WORD nBlockAlign; /* block size of data */
WORD wBitsPerSample; /* number of bits per sample of mono data */
WORD cbSize; /* the count in bytes of the size of */
/* extra information (after cbSize) */
} WAVEFORMATEX, *PWAVEFORMATEX, NEAR *NPWAVEFORMATEX, FAR *LPWAVEFORMATEX;
{
WORD wFormatTag; /* format type */
WORD nChannels; /* number of channels (i.e. mono, stereo...) */
DWORD nSamplesPerSec; /* sample rate */
DWORD nAvgBytesPerSec; /* for buffer estimation */
WORD nBlockAlign; /* block size of data */
WORD wBitsPerSample; /* number of bits per sample of mono data */
WORD cbSize; /* the count in bytes of the size of */
/* extra information (after cbSize) */
} WAVEFORMATEX, *PWAVEFORMATEX, NEAR *NPWAVEFORMATEX, FAR *LPWAVEFORMATEX;
wFormatTag 录音类型 通常使用WAVE_FORMAT_PCM
nChannels 1单声道 2双声道(立体声)
nSamplesPerSec 采样频率 采样率越高 声音会越清晰
wBitsPerSample 采用多少位存储声音8位和16位
nBlockAlign 音频数据块的大小wBitsPerSample*nChannels/8 例如双声道16位那么要用4个字节(32位)来存储声音
nAvgBytesPerSec 传输比特率 nSamplesPerSec * nBlockAlign (WAVE_FORMAT_PCM)
cbSize 默认为0