c++ - Acoustic Echo Cancellation (AEC) with Speex and DirectSound -
I am trying to do acoustic echo cancellation (AEC) with the Spax codec library. According to the Speex documentation, I need to make two calls:
speex_echo_playback (echo_state, echo_frame); Each time an audio frame is played, and
speex_echo_capture (echo_state, input_frame, output_frame); has been captured for each frame.
Since I am using DirectSound, I was thinking that I use primary directsound buffer as copy in echo_frame as speex_echo_playback, e.g.,
DWORD offset = 0; DWORD Length = 0; LPVOID Block 1, Block 2; DWORD length 1, length 2; DWORD flags = DSBLOCK_ENTIREBUFFER; HRESULT hr = Primary_ buffer-> lock (offset, length, and block 1, and latin 1, and block 2, and latin 2, flags); // would like to convert buffer to a form that can use // speex_echo_capture (). // Why is length 1 == length 2 == 0 always? Hr = primary_buffer-> unlock (block 1, length 1, block 2, length 2); The documentation says that they only write, but do I have any way to use buffer data?
Buffer I'm basically creating:
CComPtr & lt; IDirectSoundBuffer & gt; Primary_buffer; DSBUFFERDESC Primary Disk = {Size (DSBUFFDESC), DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D | DSBCAPS_LOCHARDWARE, 0, 0, NULL, DS3DALG_HRTF_LIGHT}; HRESULT hr = Direct Sounds _- & gt; CreateSoundBuffer (& PrimaryDesk, & Primary_buffer, NULL); To use DirectSound buffer, alternatively, use the output of speex_decode () and mixing my own software.
Any indication or suggestion to make Spacks and DirectSound work together? Thanks for any help.
I did this once. But my approach was:
I have never used the primary buffer instead, instead, I only worked with a secondary buffer. I had two threads - playback thread and capture thread. In addition, I have used another spacx function.
In this way, in my playback thread I have the speex_echo_cancellation function and the first stored playback frame with the exact capture frame in the current playback frame and capture thread in a global buffer.
The DMO was not applicable to me because I also had to support Windows XP.
You can also look for even more interesting information - or even better.
Good luck,
Anthony
Comments
Post a Comment