Click here to Skip to main content
13,900,869 members
Click here to Skip to main content
Add your own
alternative version


78 bookmarked
Posted 1 Jan 2006

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


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.


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

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

You may also be interested in...

Comments and Discussions

GeneralRe: VB.NET Pin
Saneesh31-Jul-07 5:56
memberSaneesh31-Jul-07 5:56 
GeneralSaving sound (*wav) into access database Pin
indray2j16-Jul-07 22:31
memberindray2j16-Jul-07 22:31 
GeneralRe: Saving sound (*wav) into access database Pin
Saneesh17-Jul-07 4:07
memberSaneesh17-Jul-07 4:07 
GeneralRe: Saving sound (*wav) into access database Pin
indray2j17-Jul-07 20:14
memberindray2j17-Jul-07 20:14 
GeneralComplete Program.. Pin
indray2j8-Jul-07 22:05
memberindray2j8-Jul-07 22:05 
GeneralRe: Complete Program.. Pin
Saneesh9-Jul-07 4:18
memberSaneesh9-Jul-07 4:18 
GeneralRe: Complete Program.. Pin
indray2j10-Jul-07 21:47
memberindray2j10-Jul-07 21:47 
GeneralRe: Complete Program.. Pin
Saneesh11-Jul-07 4:04
memberSaneesh11-Jul-07 4:04 
What error are you getting when you are compiling it? Also which version of VC++ are you using? The zip file have all the source code in it, i mean the whole workspace.


GeneralRe: Complete Program.. Pin
indray2j12-Jul-07 3:46
memberindray2j12-Jul-07 3:46 
GeneralRe: Complete Program.. Pin
Saneesh12-Jul-07 5:02
memberSaneesh12-Jul-07 5:02 
GeneralRe: Complete Program.. Pin
indray2j13-Jul-07 2:27
memberindray2j13-Jul-07 2:27 
GeneralRe: Complete Program.. Pin
Member 870123527-Apr-12 20:49
memberMember 870123527-Apr-12 20:49 
Generaloutput wav can't play on Vista Pin
binsonl4-May-07 7:35
memberbinsonl4-May-07 7:35 
GeneralRe: output wav can't play on Vista Pin
Saneesh4-May-07 16:46
memberSaneesh4-May-07 16:46 
GeneralRe: output wav can't play on Vista Pin
binsonl4-May-07 17:17
memberbinsonl4-May-07 17:17 
GeneralRe: output wav can't play on Vista Pin
GabeON6-May-07 5:07
memberGabeON6-May-07 5:07 
GeneralRe: output wav can't play on Vista Pin
binsonl7-May-07 2:18
memberbinsonl7-May-07 2:18 
QuestionRe: output wav can't play on Vista Pin
Saneesh16-May-07 12:58
memberSaneesh16-May-07 12:58 
AnswerRe: output wav can't play on Vista Pin
binsonl16-May-07 20:37
memberbinsonl16-May-07 20:37 
GeneralRe: output wav can't play on Vista Pin
Saneesh17-May-07 4:11
memberSaneesh17-May-07 4:11 
GeneralRe: output wav can't play on Vista Pin
binsonl17-May-07 8:02
memberbinsonl17-May-07 8:02 
GeneralFormat combo box Pin
chris_mezzanine5-Feb-07 4:14
memberchris_mezzanine5-Feb-07 4:14 
GeneralRe: Format combo box Pin
Saneesh6-Feb-07 3:27
memberSaneesh6-Feb-07 3:27 
GeneralRe: Format combo box Pin
chris_mezzanine6-Feb-07 12:22
memberchris_mezzanine6-Feb-07 12:22 
QuestionCompatible for c++ v6.0? Pin
Newbee0724-Jan-07 4:10
memberNewbee0724-Jan-07 4:10 

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

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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190306.1 | Last Updated 12 Jul 2007
Article Copyright 2006 by Saneesh
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid