I am trying to cancel Acoustic Echo Cancellation (AEC) using Speex codec library. According to Speex documentation, I need to make two calls:
speex_echo_playback(echo_state, echo_frame);
every time a sound frame is played, and
speex_echo_capture(echo_state, input_frame, output_frame);
for each captured frame.
Since I use DirectSound, I thought I could use the main DirectSound buffer as an echo_frame in a speex_echo_playback call, e.g.
DWORD offset = 0; DWORD length = 0; LPVOID block1, block2; DWORD length1, length2; DWORD flags = DSBLOCK_ENTIREBUFFER; HRESULT hr = primary_buffer->Lock( offset , length , &block1 , &length1 , &block2 , &length2 , flags );
The documentation says that these are pointers for writing only, but is it necessary to use the buffer data at all?
This is basically how I create the buffer:
CComPtr< IDirectSoundBuffer > primary_buffer; DSBUFFERDESC primarydesc = { sizeof( DSBUFFERDESC ), DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D | DSBCAPS_LOCHARDWARE, 0, 0, NULL, DS3DALG_HRTF_LIGHT }; HRESULT hr = directsound_->CreateSoundBuffer( &primarydesc, &primary_buffer, NULL );
An alternative, apparently, to use the DirectSound buffer itself is to use speex_decode () output and inject my own software.
Any pointers or suggestions for getting Speex and DirectSound to work together? Thanks for any help.
c ++ echo audio speex directsound
user19480
source share