meshenger-android
meshenger-android copied to clipboard
About echo cancellation
When two device output via speakphone and there will be much echo. Is there any method to add echo cancellation process?
I found webrtc has aec module, is there any hint about how to integrate it into the code
I have some local code to enable AEC, but it is not tested yet.
I can do some test, can u share the code, or some tips how to ? I have tried use android.media.AudioTrack(not webrtc AudioTrack) and Speex to cancel the echo, and it worked. But I have no idea how to add the code into this project.
In my code, I should set sample rate at 8k and single track, enable aec, and use Speex at audio encoder and decoder, but webrtc has no entry. And in this project, I also tried disable the hardware echo cancellation and other code like below: WebRtcAudioUtils.setDefaultSampleRateHz(8000) WebRtcAudioUtils.setWebRtcBasedNoiseSuppressor(true) WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true) WebRtcAudioUtils.setWebRtcBasedAutomaticGainControl(true) var audioDeviceModule = JavaAudioDeviceModule.builder(App.getInstance()) .setUseHardwareAcousticEchoCanceler(false) .setUseHardwareNoiseSuppressor(false) .setSampleRate(8000) .createAudioDeviceModule() var initializationOptions = PeerConnectionFactory.InitializationOptions.builder(App.getInstance()) .createInitializationOptions() PeerConnectionFactory.initialize(initializationOptions) factory = PeerConnectionFactory.builder() .setAudioDeviceModule(audioDeviceModule) .setVideoEncoderFactory(encoderFactory) .setVideoDecoderFactory(decoderFactory) .createPeerConnectionFactory()
but all failed
I would want to try this: https://webrtc.googlesource.com/src/+/refs/heads/main/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java#535
I have seen this code, dump the stream into a tmp file(like the aecDump method), and do aec ops? Am i right?
Yes. But I would leave out the recording stuff.
Any detailed information? I don't understand? I searched over the internet, not too much talked about aec based on webrtc.
The line with setSamplesReadyCallback seems to be for recording audio. Let's leave out that line out if you plan to make a merge request.
I'll have a try, thanks
Did you get echo cancellation to work?
I have added the JavaAudioDevice code. But it does not seem to work for me.