AEC (Acoustic Echo Canceller) echo Elimination

Source: Internet
Author: User

The AEC echo suppression algorithm is difficult. Currently, directsound can be used for processing, but it can only be used in xp. It is not supported by other systems!
Currently, gips has excellent implementations of this algorithm. Skype is the engine used!
It may be difficult to implement it on your own!
 

The AEC module is part of the underlying structure of Microsoft directsound. This component includes the following features and restrictions:

The AEC is valid only in a small room of no more than 25 × 15 × 9 feet;
The AEC is only valid for single channels. When the output is a stereo sound of multiple channels, only one channel can have the echo cancellation effect;
AEC cannot offset sounds from other sound sources, such as those on the background radio;
Idirectsoundfullduplex8 * directsoundfd ;//
Idirectsoundcapturebuffer8 * directsoundcapturebuf8; // capture the buffer interface pointer
Idirectsoundbuffer8 * directsoundbuf8; // playback buffer interface pointer
Idirectsoundbuffer8 * piunkown; // playback buffer interface pointer

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, 0x0000a, 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. Create and initialize directsound
Waveformatex wavedataformat = {wave_format_pcm, 1,8000, 16000,2, 16, 0 };
// Playback buffer. 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; // To be determined
Desc. dwreserved = 0;
Desc. lpwfxformat = & wavedataformat;

// Capture the effect of the buffer zone AEC and NS.
Dsceffectdesc efft [2];
Memset (efft, 0, sizeof (efft ));
// AEC Effect
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 Effect
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 the buffer. Capture Buffer
Dscbufferdesc CDESC;
Memset (& CDESC, 0, sizeof (CDESC ));
CDESC. dwsize = sizeof (CDESC );
CDESC. dwflags = dscbcaps_ctrlfx;
CDESC. dwbufferbytes = 2000 * num_rec_notifications; // To be determined
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, and directsoundbuf8 are created successfully, and they are not zero.

If (! Failed (HR ))
Directsoundfd-> QueryInterface (iid_idirectsoundbuffer8, (void **) piunkown );
// The above piunkown was found to be 0. The query failed. Why?
Afxmessagebox ("failed ");

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.