Most of us are familiar with at least one multimedia recording software. Windows has one of the simplest ones: Sound Recorder. In this article I want to introduce some simple but useful classes for recording/playing back of voice that wrap the WAVE APIs.
Here is the list of all the Wave APIs that I have used:
|Open the Wave device for recording.|
|Prepare the Wave header for recording.|
|Start recording. Recorded data will be saved in a specified buffer.|
|After finishing the record process, should un-prepare Wave header. |
|Close the recording device.|
|Open the Wave device for playing.|
|Prepare the Wave header for playing.|
|Play the buffer.|
|Un-prepare the Wave header.|
|Close the playing device.|
As you can see, working with these APIs are straightforward but if you want to skip them and simply do a copy/paste code in your project, my classes are for you.
Here is the definition of the classes:
void SetFormat(DWORD nSamplesPerSec,
WORD wBitsPerSample,WORD nChannels);
BOOL CopyBuffer(LPVOID lpBuffer, DWORD ntime);
void GetMMResult(MMRESULT res);
BOOL PrepareBuffer(DWORD ntime);
class CVoiceRecording : public CVoiceBase
class CVoicePlaying : public CVoiceBase
Also, for notifying of events, such as finishing recording/playing, I have used two callback functions:
BOOL CALLBACK VoiceWaveInProc(HWAVEIN hwi,
BOOL CALLBACK VoiceWaveOutProc(HWAVEOUT hwi,
Just declare two variables of type
Play member functions to work with them:
I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology
in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acquisition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competition, my articles are:
You can see list of my articles, by clicking here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.