ikbencasdoei/godot-voip

The sound is choppy when the program receives 9+ input signals

Gamemap opened this issue · 21 comments

When many people speak at the same time, the sound is stretched.
Would multi-threading solve the problem?

No threads required! I don't think think Godot even allows multiple threads to play sound.
I think this problem is solved by giving each participant a seperate voip instance. This way (hopefully) they'll use their seperate audio buffers.

I have 3 instances (on diffrent pc's) connected to a server and when 2 or more speak, the sound is not clear.
(So when a program receives 2 (or more) voice signals, the sound is stretched, delayed and choppy.)
I do not know if it is because of how the sound is processed.

Yes. Because a VoipInstance only has space for one input at a time, the audio gets weird when it gets multiple inputs. The solution is creating a new VoipInstance for every connection to your server.

Thanks, I will try to implement this, but I think it would be helpful for others to have some instructions or a hint in the readme/description.

Edit:
Must each client also have a VoipInstance for each connection?
Is the Multiplayer_PlayerID a good solution to sort the diffrent signals to the diffrent VoipInstances?

Yes. I will update the plugin to make it easier.

Thank you

Okay I made some changes which make it possible to receive multiple inputs with a single instance.

I think it is working. Thank you.

@casbrugman If I connect 10 voice programs to a server (and they all speak) the sound is weird again. This can probably only be fixed with a new voip instance. Could you help me figure out how to connect the incoming connections ID's to a new voip instance?
(I'm testing it alone, but if 10 people are talking, it must be a mess ;) but if too many people have background noise, it would probably lag).

With 8 connections the sound is really great now!

Could you explain in what way the sound is weird?

It's stretched, delayed and choppy. (like the first time, but now only for about 9+ connections).

@casbrugman To test multible connections alone I have changed the signal to button_toggled:

func _on_Voice_toggled(button_pressed):
    if button_pressed:
	    voice.recording = true
    else:
	    voice.recording = false

Could this be a problem? (Too many programms that want a microphone signal?)

Should be completely fine

I think this might be a performance issue (not your computers fault of course). I'll have to investigate further.

@casbrugman If I connect 10 voice programs to a server (and they all speak) the sound is weird again. This can probably only be fixed with a new voip instance. Could you help me figure out how to connect the incoming connections ID's to a new voip instance?
(I'm testing it alone, but if 10 people are talking, it must be a mess ;) but if too many people have background noise, it would probably lag).

With 8 connections the sound is really great now!

Like you would when making an online game. For every player you spawn an instance and let each player control their own. However, if you are not familiar with making multiplayer games, it can be quite complex.

Thank you. I think I have an idea to connect the players with the instances. I will try it out in the next few days. Do you think this could solve the problem?

At this moment I'm not sure.

Like you would when making an online game. For every player you spawn an instance and let each player control their own. However, if you are not familiar with making multiplayer games, it can be quite complex.

Added a new VoiceOrchestrator node which works the same as the VoiceInstance but automatically does this^ but with much improved performance.

At the moment I think this is as good as it gets. Closing for now.

@c-as
I tested it on a PC and it worked beautifully until my CPU was at 100% because of all the input with all the programs open.
I will test it on several devices soon, but I think it will work perfectly.

Thank you for making this great and helpful addon.
Gamemap

Thank you, that's very good to hear.