
Introduction
This sample program make use of waveInxxxx functions to read from an audio input device like a sound card and write it to a .wav file using mmioxxx functions. It is one of the simplest way to record sound with all the format capabilities supported by the hardware deviceInitially, by using waveInGetNumDevs, we can find all the devices and then by using waveInGetDevCaps, we can find the formats it is supported.
To start recording, first select a device and then open the device with waveInOpen API call with the specified format (i.e. 16 bit etc). The output file is also prepared with all the headers filled in properly. Here i am using only PCM format which is easy. If you have more codecs installed on your PC, you can change that one also. But be sure that you supplied the proper values in the WAVEFORMATEX structure.
waveIn needs buffers to start recording. It is better to give more buffers for buffering to avoid any delays. I have used 3 here, but you can add more if your PC needs more time in writing to the HDD and thus causing the delay. Once the buffers are added in the queue, waveInStart will start recording. For each data chunk, the callback function specified in the waveinOpen will get the buffers. Just write it to the file and mark the buffer again for recording by calling the same addbuffer fn.
Once done with recording, adjust the chunk headers using the mmioascend APIs. Thats it.
License
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
About the Author
Saneesh
| I am from the beautiful sea side town called Kochi ( cochin), Kerala, South India.
|
本文介绍了一个简单的录音程序设计方法,该程序使用 waveIn 函数从音频输入设备读取数据,并使用 mmio 函数将数据写入 .wav 文件。文章详细解释了如何通过 waveInGetNumDevs 和 waveInGetDevCaps 获取设备信息及其支持的格式。
199

被折叠的 条评论
为什么被折叠?



