Using Android's build-in acoustic echo cancellation

£可爱£侵袭症+ 提交于 2019-11-30 13:59:31

I was finally able to get echo cancellation to work on my Arm5 (WM8650) processor (Android 2.2). Below are the steps I took.

  1. I wrapped Speex with JNI and called echo processing routines before sending PCM frames to encoder. No echo was canceled no matter what Speex settings I tried.

  2. Because Speex is very sensitive to delay between playback and echo frames I implemented a queue and queued all packets sent to AudioTrack. The size of the queue should be roughly equal to the size of internal AudioTrack buffer. This way packet were sent to echo_playback roughly at the time when AudioTrack send packets to the sound card from its internal buffer. The delay was removed with this approach but echo was still not cancelled

  3. I wrapped WebRtc echo cancellation part with JNI and called its methods before sending packets to encoder. The echo was still present but the library obviously was trying to cancel it.

  4. I applied the buffer technique described in P2 and it finally started to work. The delay needs to be adjusted for each device though. Note also that WebRtc has mobile and full version of echo cancellation. The full version substantially slows the processor and should probably be run on ARM7 only. The mobile version works but with lower quality

I hope this will help someone.

I've been to the same place, successfully ported Speex AEC to Android and used it in 2 different Android VoIP clients. Most of the echo gets cancelled when on speakerphone at full volume - tested on a variety of devices. The Speex official docs and googling should be enough to get it to work.

Since API Level 11, there is a new value for MediaRecorder.AudioSource, it is VOICE_COMMUNICATION. Android docs say: "Microphone audio source tuned for voice communications such as VoIP. It will for instance take advantage of echo cancellation or automatic gain control if available. It otherwise behaves like DEFAULT if no voice processing is applied." I tried this, but couldn't make it worked. The problem may be the device I'd used, which is Sony Tablet S. Worth trying, though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!