Wad*_*ade 7 c++ audio directsound echo speex
我正在尝试使用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< 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 );
Run Code Online (Sandbox Code Playgroud)
看来,使用DirectSound缓冲区本身的替代方法是使用speex_decode()的输出并进行自己的软件混合.
让Speex和DirectSound一起工作的任何指针或建议?谢谢你的帮助.
我曾经做过一次。但我的方法如下:
我从未直接使用过主缓冲区。相反,我只使用一个辅助缓冲区。我有两个线程 - 播放线程和捕获线程。另外,我还使用了另一个 speex 函数 - speex_echo_cancellation。
因此,在我的播放线程中,我将当前播放帧保存在全局缓冲区中,并在名为 speex_echo_cancellation 函数的捕获线程中保存当前捕获帧和先前存储的播放帧。
DMO 不适合我,因为我还必须支持 Windows XP。
您还可以浏览 - speex 邮件列表存档,甚至更好地订阅此处以获得更多有趣的信息。
祝你好运,
安东尼
| 归档时间: |
|
| 查看次数: |
5966 次 |
| 最近记录: |