ikbencasdoei / godot-voip

godot-voip is a Godot Engine addon which makes it very easy to setup a real-time voice-chat system in your Godot game. This addon also includes a demo project.
https://godotengine.org/asset-library/asset/425
MIT License
196 stars 13 forks source link

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

Closed Gamemap closed 3 years ago

Gamemap commented 3 years ago

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

ikbencasdoei commented 3 years ago

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.

Gamemap commented 3 years ago

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.

ikbencasdoei commented 3 years ago

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.

Gamemap commented 3 years ago

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?

ikbencasdoei commented 3 years ago

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

Gamemap commented 3 years ago

Thank you

ikbencasdoei commented 3 years ago

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

Gamemap commented 3 years ago

I think it is working. Thank you.

Gamemap commented 3 years ago

@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!

ikbencasdoei commented 3 years ago

Could you explain in what way the sound is weird?

Gamemap commented 3 years ago

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

Gamemap commented 3 years ago

@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?)

ikbencasdoei commented 3 years ago

Should be completely fine

ikbencasdoei commented 3 years ago

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

ikbencasdoei commented 3 years ago

@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.

Gamemap commented 3 years ago

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?

ikbencasdoei commented 3 years ago

At this moment I'm not sure.

ikbencasdoei commented 3 years ago

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.

ikbencasdoei commented 3 years ago

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

Gamemap commented 3 years ago

@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

ikbencasdoei commented 3 years ago

Thank you, that's very good to hear.