Search code examples
c#audiocodec

Mixing two or more G.711 raw streams


I am trying to do a real-time on-the-fly mixing of several G.711 raw RTP streams (each RTP packet holds 160 bytes of raw G.711 A/U payload) and streams are all time-synchronized.

I've tried taking the average for each byte in all streams and build a new array of the same size (160) but its values are the average of the original streams, but when playing out the audio, I find it too noisy.

I tried also taking the Max and Min, the mixed output is better, but still noisy ..

What is the proper way to mix 2 or more G.711 raw streams?

If I have 3 phones in a conference, each packetization interval (say 20ms), I need to mix two RTP packets from two phones into one RTP packet and stream it to the third one and so on.

BR, Moatassem


Solution

  • I found the solution already. I had to decode the streams into PCM 16-bit samples, then perform normal average then re-encode the resultant