#if !defined _MYRECORD_H
#define _MYRECORD_H
#pragma comment(lib, "winmm.lib")
#include "mmsystem.h"
#include "math.h"
int myplaysound(short * buffer, DWORD size);
class cbhrecord
{
public:
short * ibuf;
short * tbuffer;
DWORD tbsize;
short * buf1;
DWORD bsize;
short * buf2;
WAVEFORMATEX waveformat;
HWAVEIN hwavein;
WAVEHDR pwh1,pwh2;
int state;
DWORD rsize;
double noiselevel;
cbhrecord()
{ state = 0;
tbsize = 4096*128;
bsize = 4096;
rsize = 0;
tbuffer = new short[tbsize];
buf1 = new short[bsize];
buf2 = new short[bsize];
ibuf = new short[bsize];
waveformat.wFormatTag=WAVE_FORMAT_PCM;
waveformat.nChannels=1;
waveformat.nSamplesPerSec = 44100;
waveformat.nAvgBytesPerSec = 44100*2;
waveformat.nBlockAlign = 2;
waveformat.wBitsPerSample = 16;
waveformat.cbSize = 0;
pwh1.dwBufferLength=bsize*2;
pwh1.dwFlags=0;
pwh1.lpData=(char *)buf1;
pwh2.dwBufferLength=bsize*2;
pwh2.dwFlags=0;
pwh2.lpData=(char *)buf2;
};
int start(HWND hWnd);
int resycle(DWORD p);
int stop();
int isnoise(short * buf, DWORD size);
~cbhrecord(){
if(state)
stop();
delete []tbuffer;
delete []buf1;
delete []buf2;
delete []ibuf;
}
};
#endif //!defined _MYRECORD_H