Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Audio input and output Speaker: Ching Chen Chang Date:2006.10.30.

Similar presentations


Presentation on theme: "1 Audio input and output Speaker: Ching Chen Chang Date:2006.10.30."— Presentation transcript:

1 1 Audio input and output Speaker: Ching Chen Chang Date:2006.10.30

2 2 Outline Multi-Media API (Input) Multi-Media API (Output) Sample program record1.cpp

3 3 Include #include

4 4 Multi-Media API (input) waveInOpen() waveInPrepareHeader() waveInAddBuffer() waveInStart() waveInReset() waveInUnprepareHeader() waveInClose()

5 5 WAVEFORMATEX typedef struct { WORD wFormatTag; WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; WORD wBitsPerSample; WORD cbSize; } WAVEFORMATEX; This structure defines the format of waveform-audio data.

6 6 WAVEHDR typedef struct { LPSTR lpData; DWORD dwBufferLength; DWORD dwBytesRecorded; DWORD dwUser; DWORD dwFlags; DWORD dwLoops; struct wavehdr_tag* lpNext; DWORD reserved; } WAVEHDR; This structure defines the header used to identify a waveform- audio buffer.

7 7 waveInOpen() MMRESULT waveInOpen( LPHWAVEIN phwi, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen ); Open a specified waveform input device for recording. uDeviceID : WAVE_MAPPER fdwOpen : CALLBACK_WINDOW,CALLBACK_THREAD Return MMSYSERR_NOERROR means success

8 8 waveInPrepareHeader() MMRESULT waveInPrepareHeader( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh ); Prepares a buffer for waveform input. Returns MMSYSERR_NOERROR if successful.

9 9 waveInAddBuffer() MMRESULT waveInAddBuffer( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh ); Sends an input buffer to the specified waveform-audio input device. Returns MMSYSERR_NOERROR if successful.

10 10 waveInStart() MMRESULT waveInStart( HWAVEIN hwi ); Starts input on the specified waveform input device. Returns MMSYSERR_NOERROR if successful.

11 11 waveInReset() MMRESULT waveInReset( HWAVEIN hwi ); Stops input on a specified waveform input device and resets the current position to 0. Returns MMSYSERR_NOERROR if successful.

12 12 waveInUnprepareHeader() MMRESULT waveInUnprepareHeader( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh ); Cleans up the preparation performed by waveInPrepareHeader. Returns MMSYSERR_NOERROR if successful.

13 13 waveInClose() MMRESULT waveInClose( HWAVEIN hwi ); Closes the specified waveform-audio input device. Returns MMSYSERR_NOERROR if successful.

14 14 Multi-Media API (output) waveOutOpen() waveOutPrepareHeader() waveOutWrite() waveOutReset() waveOutUnprepareHeader() waveOutClose( )

15 15 waveOutOpen() MMRESULT waveOutOpen( LPHWAVEOUT phwo, UINT uDeviceID, LPWAVEFORMATEX pwfx, DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen ); Opens a specified waveform output device for playback. Returns MMSYSERR_NOERROR if successful.

16 16 waveOutPrepareHeader() MMRESULT waveOutPrepareHeader( HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh ); Prepares a waveform data block for playback. Returns MMSYSERR_NOERROR if successful.

17 17 waveOutWrite() MMRESULT waveOutWrite( HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh ); Sends a data block to the specified waveform output device. Returns MMSYSERR_NOERROR if successful.

18 18 waveOutReset() MMRESULT waveOutReset( HWAVEOUT hwo ); Stops playback on a specified waveform output device and resets the current position to 0. Returns MMSYSERR_NOERROR if successful.

19 19 waveOutUnprepareHeader() MMRESULT waveOutUnprepareHeader( HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh ); Cleans up the preparation performed by waveOutPrepareHeader. Returns MMSYSERR_NOERROR if successful.

20 20 waveOutClose( ) MMRESULT waveOutClose( HWAVEOUT hwo ); Closes the specified waveform output device. Returns MMSYSERR_NOERROR if successful.

21 21 Sample Program Record Produce the Wave file Play the record voice nChannels=1 nSamplesPerSec=8000 wBitsPerSample=8 Demo http://ms11.voip.edu.tw/~beautidays/recordcode.txt

22 22 Reference Wavefomat http://ccrma.stanford.edu/CCRMA/Courses/422 /projects/WaveFormat/ http://www.sonicspot.com/guide/wavefiles.html Multimedia FILE I/O http://msdn.microsoft.com/library/default.asp?url=/library/en- us/multimed/htm/_win32_multimedia_file_i_o.asp


Download ppt "1 Audio input and output Speaker: Ching Chen Chang Date:2006.10.30."

Similar presentations


Ads by Google