|
-
Jan 7th, 2007, 09:05 PM
#1
EXPERTS ONLY ! Voice chat with multiple clients
Honestly, I don't expect anyone would be able to solve my problem (because of it's difficulty), but I'm gonna try anyways...
I made a voice chat program that works well. It's using ACM to encode to MP3, and the reverse on receiving side. So server and client encodes and decodes simultaniously since sound has to go both ways.
The program is using TCP for general messages, and UDP for sound transfer.
The program sends sound data only when the sound goes over a threshold of 5%, so in other words, the program does not send anything until you make a noise (you talk).
This works fine for a 1 to 1 connection.
What I want is to make the voice chat program connect directly to each client, so for example if there are 3 people talking to each other, I want each one to be connected to the other 2, and so on for more clients.
The problem is handling the sound for multiple users.
Decoding the individual sounds from diferent clients is no problem, the problem is once it becomes wave data, I don't know how to mix the sounds.
I know this sounds ironic since I made a sound tutorial, but this is different, the sound is a stream, and is not always there....
What I mean is, sometimes you have one client talking sometimes to have 2 at the same time (or more), where the sound might or might not overlap at diferent point in time.
I don't know how to keep track of buffer positions, and also how to do the mixing of the sounds.
From what I know the formula for mixing sounds is:
mixed_sound = (sound_1 + sound_2) / 2
in other words, making a average of the 2 sounds, and if there are 3 sounds, then an average of the 3, and so on...
Lets say client A starts talking and he talks to 10 seconds, client B starts 3 seconds after client A started and he talks for 2 seconds.
This means that from secod 3 to 5, it will have to mix the sounds A and B, this also means that client A will sound at lower volume while B is talking (the rule of mixing)
I was thinking not to divide the sounds by number of sounds, just add them together, ie. mixed_sound = sound_1 + sound_2 + .... etc
I know that regular chat programs don't allow you to talk at all when one person is talking, so only one person can voice chat at one point in time, but I want to break that barrier.
Anyways, this is becomming a long post, what do you guys think so far ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|