Click here to Skip to main content
Click here to Skip to main content

Simple audio recording program

, 12 Jul 2007
Rate this:
Please Sign up or sign in to vote.
Simplest way to record sound...

Sample Image - SoundRecord.jpg

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 device

Initially, 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

Share

About the Author

Saneesh
Software Developer (Senior)
United States United States
I am from the beautiful sea side town called Kochi ( cochin), Kerala, South India.

Comments and Discussions

 
GeneralRe: WaveinaddBuffer returns 33! PinmemberSaneesh30-Sep-09 5:45 
GeneralRe: WaveinaddBuffer returns 33! Pinmemberalbertinho8630-Sep-09 11:14 
GeneralRecording Audio Output [modified] Pinmembersairamdp12-Jun-09 21:11 
GeneralRe: Recording Audio Output PinmemberSaneesh14-Jun-09 3:11 
GeneralCalling waveInAddBuffer from waveInProc PinmemberGMV21-May-09 11:39 
GeneralRe: Calling waveInAddBuffer from waveInProc PinmemberSaneesh22-May-09 4:05 
GeneralRe: Calling waveInAddBuffer from waveInProc PinmemberGMV22-May-09 11:17 
GeneralRe: Calling waveInAddBuffer from waveInProc PinmemberSaneesh1-Jun-09 16:24 
Thanks for the information. I never checked it that detail.
 
Saneesh

GeneralNEED VC6 Version Pinmemberwakaley16-Mar-09 23:36 
GeneralRe: NEED VC6 Version PinmemberSaneesh17-Mar-09 4:19 
GeneralUsing your program Pinmemberw1e2i312-Jan-09 19:03 
GeneralRe: Using your program PinmemberSaneesh13-Jan-09 4:21 
GeneralMemory Leak Pinmemberyktan15-Dec-08 1:37 
GeneralRe: Memory Leak PinmemberSaneesh15-Dec-08 8:08 
GeneralI need VC6 version pls... Pinmemberkrishna Vuppala1-Nov-08 22:29 
GeneralRe: I need VC6 version pls... PinmemberSaneesh3-Nov-08 9:41 
GeneralRe: I need VC6 version pls... PinmemberMember 870123527-Apr-12 22:48 
QuestionHow can i add my own format to the drop down PinmemberMember 465536511-Jul-08 0:36 
AnswerRe: How can i add my own format to the drop down PinmemberSaneesh13-Jul-08 16:11 
GeneralVC V6 Pinmemberdave7dave7-Oct-07 12:09 
GeneralRe: VC V6 PinmemberSaneesh4-Jan-08 6:08 
GeneralVB.NET PinmemberBIRDENT30-Jul-07 21:38 
GeneralRe: VB.NET PinmemberSaneesh31-Jul-07 5:56 
GeneralSaving sound (*wav) into access database Pinmemberindray2j16-Jul-07 22:31 
GeneralRe: Saving sound (*wav) into access database PinmemberSaneesh17-Jul-07 4:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140826.1 | Last Updated 12 Jul 2007
Article Copyright 2006 by Saneesh
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid