




| Sound Recording with Wave API |
|
|
|
| Written by Zamrony P. Juhara |
| Friday, 13 November 2009 15:26 |
|
Page 1 of 10 This short article teach you how to create simple sound recorder software with Windows Wave Application Programming Interface (Wave API). IntroductionActually with TMediaPlayer, you can do sound recording and it's simple. For example:
but we don't have access to audio data currently being recorded, so if you want to develop professional multiple track sound recorder such as Cakewalk, TMediaPlayer is obviously not an option. Why? Because TMediaPlayer was built on the top of MCI (Media Control Interface). MCI is a generic interface for playback and recording multimedia. To record audio in Windows, we can use DirectX or Windows's built-in Multimedia API. This article will explain how to do sound recording with wavein*** functions in Windows's Multimedia API. Source code is available to download here In Delphi, multimedia API functions are declared in mmsystem.pas unit.
Opening DeviceTo be able to use sound card to record sound we need to open device for recording. Function we need to use is WaveInOpen().
If waveInOpen succeeds, this function returns handle (of type of HWAVEIN) in lphwavein. uDeviceID is device ID we are going to open. If we do not know what device to open, just use WAVE_MAPPER constant. lpFormatEx is our requested recording format. See "Recording Format". dwCallback is callback mechanism that we use. Callback will be called evertytime when an event occured, for example when sound card is finished filling buffer with data, device is open and etc. This parameter is related with dwFlags flag. If dwFlags=CALLBACK_NULL then no callback mechanism is used, if dwFlags=CALLBACK_FUNCTION then dwCallback must hold address of callback function. For info about callback, please see "Callback". If dwFlags=CALLBACK_WINDOW then dwCallback must hold handle of window to receive messages. Messages are:
There are other callback type, but usually CALLBACK_FUNCTION or CALLBACK_WINDOW are used more often. dwInstance adalah user-defined data yang akan dikirim ke callback. Recording FormatTo set recording format, we use TWaveFormatEx record.
|
| Last Updated on Wednesday, 18 November 2009 09:31 |