Echo/Feedback loop in VoiceChat over phone/speaker.

We’ve implemented VoiceChat ( https://github.com/fholm/unityassets/tree/master/VoiceChat ) to use it in an Android game.

The problem is, when two people are talking, since the voice is coming from the phone’s speaker instead of headphones, there’ll be a feedback loop of the voice with echo. Why is this happening when it doesn’t happen in normal phone calls with speakers? And is there any way to prevent it in Unity?

The feedback does always happen. So the question should be: Why do you not hear such loopbacks in other pieces of software. The reason is that advanced voice chat software (like skype / teamspeak) have implemented a quite complicated audio analysis of the microphone and with respect to some delay they try to subtract the speaker signal from the microphone input.

This is by far more complicated than it sounds ^^. The phase of the two audio signals have to perfectly match. So the data that goes out the speaker will arrive a tiny bit later at the mic. So depending on the room properties in respect to size and echo that time will vary. Also you can have multiple reflections off walls which makes it even more complicated.

See this post. Also have a look at this post, it’s not directly related but shows some of the problems you have to tackle.