Click here to Skip to main content
Licence 
First Posted 1 Jan 2006
Views 144,051
Downloads 4,840
Bookmarked 64 times

Simple audio recording program

By | 12 Jul 2007 | Article
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

About the Author

Saneesh

Software Developer (Senior)

United States United States

Member

I am from the beautiful sea side town called Kochi ( cochin), Kerala, South India.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralCan you help? PinmemberMember 779661519:44 22 Apr '11  
GeneralWon't compile using Visual Studio 2010 (SP1) PinmemberMichael B Pliam9:58 13 Apr '11  
GeneralRe: Won't compile using Visual Studio 2010 (SP1) PinmemberSaneesh4:12 23 Apr '11  
AnswerRe: Won't compile using Visual Studio 2010 (SP1) Pinmembertom tom tom tom tom0:37 5 Oct '11  
GeneralRe: Won't compile using Visual Studio 2010 (SP1) PinmemberSaneesh4:45 5 Oct '11  
Generalsource code Pinmembersunilpatilgs19:01 16 Mar '11  
Generalgetting waveform n samples Pinmembersunilpatilgs23:28 10 Mar '11  
GeneralRe: getting waveform n samples PinmemberSaneesh5:58 11 Mar '11  
GeneralRe: getting waveform n samples Pinmemberpeppelisme7:17 5 Jun '11  
Questionhow to display wave form Pinmembersunilpatilgs18:00 8 Mar '11  
AnswerSanesh can you contact me? PinmemberMember 773778321:16 8 Mar '11  
GeneralRe: Sanesh can you contact me? PinmemberSaneesh4:15 9 Mar '11  
AnswerRe: how to display wave form PinmemberSaneesh4:15 9 Mar '11  
GeneralMy vote of 5 Pinmemberboyewa7:30 13 Sep '10  
Generalwriting audio to serial port Pinmemberabhishek50500420:27 26 Mar '10  
GeneralRe: writing audio to serial port PinmemberSaneesh5:22 21 Apr '10  
GeneralTimer is not working when recording a sound PinmemberNightBeforeChirstmas22:32 13 Jan '10  
GeneralRe: Timer is not working when recording a sound PinmemberSaneesh3:34 14 Jan '10  
Questionsegmenting the output Pinmemberwui ngiap4:56 2 Oct '09  
GeneralWaveinaddBuffer returns 33! Pinmemberalbertinho863:48 24 Sep '09  
GeneralRe: WaveinaddBuffer returns 33! PinmemberSaneesh5:45 30 Sep '09  
GeneralRe: WaveinaddBuffer returns 33! Pinmemberalbertinho8611:14 30 Sep '09  
GeneralRecording Audio Output [modified] Pinmembersairamdp21:11 12 Jun '09  
GeneralRe: Recording Audio Output PinmemberSaneesh3:11 14 Jun '09  
GeneralCalling waveInAddBuffer from waveInProc PinmemberGMV11:39 21 May '09  

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.

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