microsoft / MixedReality-WebRTC

MixedReality-WebRTC is a collection of components to help mixed reality app developers integrate audio and video real-time communication into their application and improve their collaborative experience
https://microsoft.github.io/MixedReality-WebRTC/
MIT License
908 stars 282 forks source link

Acoustic Echo Cancellation does not working #157

Open jameszhong2008 opened 4 years ago

jameszhong2008 commented 4 years ago

Use MixedReality-WebRTC and test it on a PC, seem like the Echo cancellation has no effect(echo and howling sound). Is there anyway to turn it on or adjust it?

djee-ms commented 4 years ago

Hi @jameszhong2008, I thought AEC was always active by default in Google's code, but I have to admit I never really looked into the details. We don't currently expose any audio settings; this will likely change with the introduction of standalone track objects (#152) but this is not available yet. I need to try to reproduce that issue, but I won't be able to do so until I'm back in the office next week, sorry for the delay. In the meantime you can try locally to change the audio options passed to the audio engine when created the track: https://github.com/microsoft/MixedReality-WebRTC/blob/f6ae23ad60944679872ed5b2908d27ddea3b7cf0/libs/Microsoft.MixedReality.WebRTC.Native/src/interop/interop_api.cpp#L845 You can pass a custom cricket::AudioOptions instance and try forcing echo_cancellation=true, and maybe even extended_filter_aec=true and/or delay_agnostic_aec=true too, although I would try with the former only first.

jameszhong2008 commented 4 years ago

@djee-ms, thanks a lot, I pass AudioOption forcing echo_cancellation=true seems no difference. then I pass extended_filter_aec=true, still have howling sound, then I add delay_agnostic_aec=true. there is no howling sound but some of the voice was lose and some lower noisy sound occured. any suggestion? sorry for my bad english.

djee-ms commented 4 years ago

Sorry I never tried AEC myself and I'm not an audio expert. It seems that the issue is more with the AEC experience itself, rather than with MixedReality-WebRTC. Could you maybe try to get in touch with the WebRTC folks directly and ask them? I would understand that MixedReality-WebRTC can potentially change the the audio timing, but if you have problems even with delay_agnostic_aec=true then it sounds like this is a more general issue with AEC itself, and not with MixedReality-WebRTC. Of course we can discuss adding more audio options if you find what option helps in your case.

WebRTC bug tracker : https://bugs.chromium.org/p/webrtc/issues

Note: I remember reading that if you ear an acoustic echo issue on one peer, then the problem is AEC on the other peer. Did you change the options on the correct peer? On both?

jameszhong2008 commented 4 years ago

Yes, I change both side, about the lower noisy sound , I add noise_suppression=true then it disappeared. With delay_agnostic_aec=true, I changed position of the microphone, echo cancellation effect is better than before. thank you.

djee-ms commented 4 years ago

I'll mark this issue as a feature request to expose the audio options then.

kspark-scott commented 4 years ago

Coincidentally, we (Kognitiv Spark) noticed the lack of echo cancellation in mid-December 2019 (even though it has been present in every previous version, including our original uwp-sdk m62 build). I can confirm that explicitly setting the cricket::AudioOptions() addresses our issue as well, so we would also like to see this feature added.

For the record, I found that setting echo_cancellation=true was not sufficient on its own. Setting either delay_agnostic_aec=true OR extended_filter_aec=true alone was sufficient to remove the echo, though with delay agnostic AEC I could still hear faint traces of an echo from time to time. Extended filter AEC was impressive and seems to remove it completely. There also seems to be no conflict between the two options -- setting them both also removed the echo entirely.

kspark-scott commented 4 years ago

@djee-ms, I could make an attempt at the audio option configuration if you like. My thinking is to just copy the existing pattern used by the VideoDeviceConfiguration struct, adding an AudioDeviceConfiguration with a set of mrsBool members that reflect at least some of the cricket::AudioOption members and adding it as a required parameter for mrsPeerConnectionAddLocalAudioTrack(). If you think you might accept a PR like that, would you like to see all audio options exposed, or just the echo cancellation ones with others to be added on demand?

djee-ms commented 4 years ago

@kspark-scott thanks for the offer, but #152 is coming really soon (matter of days) and will already have added an AudioDeviceConfiguration (see here), so your PR would conflict anyway. So I'm thinking instead to add those settings to it just after, should be fairly straightforward.

sananbintahir commented 4 years ago

I'm also having trouble with acoustic echo cancellation on Unity (PC and Android). Since #152 is now in, is there a way to enable echo cancellation?

@djee-ms could you shed some light on this maybe?

fibann commented 4 years ago

@sananbintahir #152 has added a per-track audio configuration, but settings for AEC haven't been exposed there yet.

sananbintahir commented 4 years ago

@fibann Is this on the roadmap? and is there a workaround for now? Not having AEC makes the library pretty much unusable for my application, which targets the Oculus Quest.

fibann commented 4 years ago

@sananbintahir sorry, no ETA for this at the moment.

You can work around this by compiling MR-WebRTC from source and passing the AEC options mentioned in the comments above to the audio source creation, the relevant lines are now at https://github.com/microsoft/MixedReality-WebRTC/blob/e7773933c14d10090ecfb34cd7e777f72bbc10f8/libs/mrwebrtc/src/media/device_audio_track_source.cpp#L23

sananbintahir commented 3 years ago

https://github.com/microsoft/MixedReality-WebRTC/blob/e7773933c14d10090ecfb34cd7e777f72bbc10f8/libs/mrwebrtc/src/media/device_audio_track_source.cpp#L23

@fibann I tried the workaround and built the library from source, I tried passing

options.echo_cancellation = true;
options.extended_filter_aec = true;
options.delay_agnostic_aec = true;
options.highpass_filter = true;
options.noise_suppression = true;

But all combinations of these options produced little to no effect on the echo. I suppose this is because I am working on Unity, which adds a delay between the signals, causing AEC to not function as it should. Is this possible or am I missing something?

I was also looking into a custom AEC implementation, but that would require access to the incoming audio stream and access to the microphone signal. Is it possible to get access to these in the library?

KarthikRichie commented 3 years ago

@sananbintahir Where you able to get a workaround for your problem? I'm facing the same problem as yours and tried setting all the solutions given in this thread. But, it's not resolved yet. If you've found a workaround, could you please share ?

sananbintahir commented 3 years ago

@KarthikRichie I tried a lot of things, but unfortunately could not find a workaround. Eventually had to give up trying to use MixedReality-WebRTC for my application. Not sure why something as essential as echo cancellation in a communication library is not prioritized.

KarthikRichie commented 3 years ago

@sananbintahir Okay. I as well tried every possible solution, but nothing seemed to work. Any other webrtc alternatives would you recommend/have tried for use within UWP app which overcomes these limitations ?

sananbintahir commented 3 years ago

@KarthikRichie Since my application mainly works on Unity, so far I haven't come across any good cross-platform solutions. There is always something you have to sacrifice. For communication just inside unity, there are many alternatives, but none of them have browser support. So it's a tricky situation. This library seemed the most promising until the echo cancellation issue came up.