现在的位置: 首页 > 综合 > 正文

AEC (Acoustic Echo Canceller) 回音消除初探

2012年11月19日 ⁄ 综合 ⁄ 共 2512字 ⁄ 字号 评论关闭

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;
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_GLOBALFOCUS;
desc.dwBufferBytes = 2000 * NUM_REC_NOTIFICATIONS;//待定
desc.dwReserved = 0;
desc.lpwfxFormat = &WaveDataFormat;
   

//捕捉缓冲区AEC和NS效果。
DSCEFFECTDESC efft[2];
memset(efft, 0, sizeof(efft));
//AEC效果
efft[0].dwSize = sizeof(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 = sizeof(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;
memset(&cdesc, 0, sizeof(cdesc));
cdesc.dwSize = sizeof(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 );
//成功创建DirectSoundFD,DirectSoundCaptureBuf8,DirectSoundBuf8,均不为零。

if(!FAILED(hr))
    DirectSoundFD->QueryInterface(IID_IDirectSoundBuffer8, (void**)pIUnkown);
//发现上面的pIUnkown=0,查询失败,为什么?
    AfxMessageBox("失败");

 

抱歉!评论已关闭.