回声抑制器:AEC回声抑制算法

来源:互联网 发布:数据库包含的完整性 编辑:程序博客网 时间:2024/03/28 23:35

回声抑制器:AEC回声抑制算法

疯狂代码 http://www.crazycoder.cn/  ĵ:http:/www.crazycoder.cn/Arithmetic/Article31436.html

 

 

AEC回声抑制算法这个比较难目前可以使用directsound进行处理不过只能在xp下使用别系统不支持!目前gips对本算法有出色实现skype就是使用该引擎!要想自己实现恐怕很困难!

 

AEC 模块是 Microsoft DirectSound 底层结构部分该组件包括下列特性和限制:

 

AEC只在不超过 25×15×9 英尺小房间才会有效; AEC只对单声道有效当输出是多个通道立体声时候只有个通道能够具有回波抵消效果; AEC不能抵消来自其它声音源声音比如背景中收音机放出来歌曲;



IDirectSoundFullDuplex8* DirectSoundFD;
// 
IDirectSoundCaptureBuffer8* DirectSoundCaptureBuf8;
//捕捉缓冲区接口指针 
IDirectSoundBuffer8* DirectSoundBuf8;
//回放缓冲区接口指针 
IDirectSoundBuffer8* pIUnkown;
//回放缓冲区接口指针


extern "C" const GUID IID_IDirectSoundBuffer8 = {0x6825a449, 0x7524, 0x4d82,{ 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e}};
extern "C" const GUID GUID_DSCFX_MS_NS = {0x11c5c73b, 0x66e9, 0x4ba1, {0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d}};
extern "C" const GUID GUID_DSCFX_CLASS_NS = {0xe07f903f, 0x62fd, 0x4e60, {0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5}};
extern "C" const GUID GUID_DSCFX_MS_AEC = {0xcdebb919, 0x379a, 0x488a, {0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40}};
extern "C" const GUID GUID_DSCFX_CLASS_AEC = {0xBF963D80L, 0xC559, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
extern "C" const GUID DAlgorithm ={0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};




//1.创建及化DirectSound 
WAVEFORMATEX WaveDataFormat={WAVE_FORMAT_PCM, 1,8000,16000,2,16, 0};
//回放缓冲区render buffer 
DSBUFFERDESC desc;
mem(&desc, 0, (desc));
desc.dwSize = (desc);
desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_GLOBALFOCUS;
desc.dwBufferBytes = 2000 * NUM_REC_NOTIFICATIONS;
//待定 
desc.dwReserved = 0;
desc.lpwfxFormat = &WaveDataFormat;




//捕捉缓冲区AEC和NS效果 
DSCEFFECTDESC efft[2];
mem(efft, 0, (efft));
//AEC效果 
efft[0].dwSize = (efft[0]);
efft[0].dwFlags = DSCFX_LOCSOFTWARE;
efft[0].guidDSCFXClass = GUID_DSCFX_CLASS_AEC;
efft[0].guidDSCFXInstance = GUID_DSCFX_MS_AEC;
//NS效果 
efft[1].dwSize = (efft[1]);
efft[1].dwFlags = DSCFX_LOCSOFTWARE;
efft[1].guidDSCFXClass = GUID_DSCFX_CLASS_NS;
efft[1].guidDSCFXInstance = GUID_DSCFX_MS_NS;
//捕捉缓冲区capture buffer 
DSCBUFFERDESC cdesc;
mem(&cdesc, 0, (cdesc));
cdesc.dwSize = (cdesc);
cdesc.dwFlags = DSCBCAPS_CTRLFX;


cdesc.dwBufferBytes = 2000 * NUM_REC_NOTIFICATIONS;
//待定 
cdesc.lpwfxFormat = &WaveDataFormat;
cdesc.dwFXCount = 2;
cdesc.lpDSCFXDesc = efft;




HWND win = AfxGetApp->m_pMainWnd->m_hWnd;
hr = DirectSoundFullDuplexCreate8(0, 0,&cdesc, &desc,win, DSSCL_PRIORITY,&DirectSoundFD, &DirectSoundCaptureBuf8,&DirectSoundBuf8, 0);
DXTRACE_ERR( TEXT("DirectSoundFullDuplexCreate8"), hr );

0 0