WaveIn.h
上传用户:amei960
上传日期:2007-02-05
资源大小:143k
文件大小:1k
- #ifndef _WAVEIN_H_
- #define _WAVEIN_H_
- #define HERTZ_POOR 8000
- #define HERTZ_LOW 11025
- #define HERTZ_NORMAL 22050
- #define HERTZ_HIGH 44100
- #define NUM_BUF 5
- #define SIZE_AUDIO_FRAME 4800
- //#define SIZE_AUDIO_PACKED 240
- #include <mmsystem.h>
- //音频输入(得到音频数据)-从硬件上得到音频数据
- class CWaveIn
- {
- private:
- WAVEINCAPS waveCaps;
- BOOL bDevOpen;
- BOOL bStartData;
- BOOL bBuffer;
- HWAVEIN m_hWave;
- WAVEHDR* m_pHead;
- HWND m_hWnd;
- private:
- WORD nChannels;
- DWORD dwHertZ;
- WORD wBits;
- private:
- BOOL Open();
- BOOL StartData();
- void Close();
- void CloseData();
- BOOL PerpareBuffer();
- void UnperpareBuffer();
- void FreeBuffer();
- public:
- CWaveIn();
- ~CWaveIn();
- //check
- public:
- BOOL IsExistDevice();
- WAVEINCAPS * GetDeviceCap();
- BOOL IsOpen() { return bDevOpen;}
- //setting
- public:
- enum CHANNEL { SINGLE , STEREO };
- inline void SetChannel(CHANNEL Channel);
- inline void SetHertZ(DWORD HertZ);
- inline void SetBit(WORD Bits);
- inline void SetHwnd(HWND hWnd);
- //operation
- public:
- BOOL Start();
- void Stop();
- };
- inline void CWaveIn::SetChannel(CHANNEL Channel)
- {
- switch( Channel )
- {
- case SINGLE:
- nChannels = 1;
- break;
- case STEREO:
- nChannels = 2;
- break;
- }
- }
- inline void CWaveIn::SetHertZ(DWORD HertZ)
- {
- dwHertZ = HertZ;
- }
- inline void CWaveIn::SetBit(WORD Bits)
- {
- wBits = Bits;
- }
- inline void CWaveIn::SetHwnd(HWND hWnd)
- {
- m_hWnd = hWnd;
- }
- #endif