2

I have an assignment to make an audio conference chat room using sockets. Is this the right approach to mix audio?

  • s is byte array which will be sent to client cl.
  • cl.ar is a byte array that contains PCM samples received from cl.
  • ar is a float array that contains sum of samples from all clients.

I subtract the sample of cl from the total sum divide it by number of other logged in users and send it to cl.

s[i] = (byte)((ar[i] - cl.ar[i]) / (activeClients.Count - 1));

Is this the correct way?

Rodrigo de Azevedo
  • 1,097
  • 9
  • 17
AgentX4000
  • 77
  • 1
  • 6
  • 1
    and the language? I also very much doubt your output buffer makes 8-bit signed audio samples. What is it? – marko Oct 12 '16 at 21:38
  • The language is C#. I'm using NAudio to get microphone input and it is giving me 16 bit each for 2 channels. – AgentX4000 Oct 13 '16 at 22:25
  • I doubt the division is reasonable. When only one client sends audio, it will effectively get damped just by the bare presence of other clients. I would go with the pure sum (subtracting the client's own audio). Also, watch out for type compatibility. Subtracting a byte from a float may not produce the result you like (watch the signs). – Nico Schertler Oct 14 '16 at 21:08

0 Answers0