我正在尝试使用Speex编解码器库执行声学回声消除(AEC).根据Speex文档,我需要执行两个调用:
speex_echo_playback(echo_state, echo_frame);
Run Code Online (Sandbox Code Playgroud)
每次播放音频帧,和
speex_echo_capture(echo_state, input_frame, output_frame);
Run Code Online (Sandbox Code Playgroud)
对于每个捕获的帧.
由于我使用的是DirectSound,我认为我可以在调用speex_echo_playback时使用主DirectSound缓冲区作为echo_frame,例如,
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
);
// Would like to convert the buffer into a form that
// speex_echo_capture() can use.
// Why does length1 == length2 == 0 always?
hr = primary_buffer->Unlock( block1, length1, block2, length2 );
Run Code Online (Sandbox Code Playgroud)
文档确实说这些是只写指针,但是无论如何都不能自己使用缓冲区数据?
这基本上就是我创建缓冲区的方式:
CComPtr< …
Run Code Online (Sandbox Code Playgroud)