Coder Social home page Coder Social logo

ikbencasdoei / godot-voip Goto Github PK

View Code? Open in Web Editor NEW
188.0 9.0 13.0 229 KB

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.

Home Page: https://godotengine.org/asset-library/asset/425

License: MIT License

GDScript 42.00% Rust 58.00%
godot voip microphone godotengine game-development godot-voip voice-chat godot-addon demo audio

godot-voip's Introduction

godot-voip ๐ŸŽ™๏ธ๐ŸŒ

logo

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.

โš  currently unmaintained โš 

Engine Compatibility

  • Godot Engine 3.2: godot-voip 2.0
  • Godot Engine 3.3+: godot-voip 3.0+
  • Godot Engine 4: โŒunavailableโŒ

Setup

Adding to a existing project

(Any kind of high-level multiplayer peer is required.)

  1. Click on the AssetLib inside editor or go to the Godot Asset Library to download the latest release, or you can clone/download this repository to get the latest commit.
  2. Select the addons/godot-voip/ folder and move it into your Godot project. (Note: make sure the structure is still res://addons/godot-voip/)
  3. Go to project-settings/audio and enable audio input.
  4. Now go to the plugins tab also inside project-settings and enable the godot-voip plugin.
  5. Add either a VoiceInstance (one connection) or a VoiceOrchestrator (more than 2 participants) node to your scene.
  6. Set $VoiceInstance.recording or $VoiceOrchestrator.recording to true and it will send your microphone input to connected participants.

Running demo

  1. Go to the templates tab in the Godot Engine project manager and look for godot-voip, or go to the Godot Asset Library to manually download the latest release, or you can clone/download this repository to get the latest commit.
  2. Open and run downloaded project.

For macOS users

Users running godot-voip on macOS need to make sure the microphone format in macOS audio settings is equal to the mix-rate in Godot project-settings.

GDNative

Some parts of this library have been ported to gdnative-rust to improve performance and to implement compression using the opus-codec and other audio processing. To use the gdnative implementation use the NativeVoiceInstance node instead of the usual VoiceIntance.

Building

To compile the gdnative parts of this library you will need Rust installed on your machine: https://www.rust-lang.org/. Then open addons/gdnative/ in your terminal and run cargo build. You'll find the compiled binary in target/. Then add the compiled binary to your platform in the godot-voip gdnative library called godot-voip-native.tres also found in the gdnative directory.

Todo

  • Implement audio compression.

Documentation

VoiceInstance icon

This node implements a single voice connection.

Signals

  • received_voice_data(data: PoolRealArray, from_id: int) Emitted when voice data is received.
  • sent_voice_data(data: PoolRealArray) Emitted when recording and data is sent.

Properties

Type Name description
NodePath custom_voice_audio_stream_player When used, the referenced AudioStreamPlayer/AudioStreamPlayer2D/AudioStreamPlayer3D will be used as output for incoming audio data.
bool recording If true, the VoiceInstance will process and send microhphone audio to the other VoipInstance.
bool listen If true, the VoiceInstance will also play any microhphone data it records.
float input_threshold Value above which microhphone data will be sent. Set to 0 to disable.

NativeVoiceInstance icon

This node implements a single voice connection using rust-gdnative.

Signals

  • received_voice_data(data: PoolRealArray, sender_id: int) Emitted when voice data is received.
  • sent_voice_data(data: PoolRealArray) Emitted when recording and data is sent.

Properties

Type Name description
NodePath custom_voice_audio_stream_player When used, the referenced AudioStreamPlayer/AudioStreamPlayer2D/AudioStreamPlayer3D will be used as output for incoming audio data.
bool recording If true, the NativeVoiceInstance will process and send microhphone audio to the other NativeVoiceInstance.
bool listen If true, the NativeVoiceInstance will also play any microhphone data it records.
float input_threshold Value above which microhphone data will be sent. Set to 0 to disable.

VoiceOrchestrator icon

This node implements multiple voice connections. It will automatically spawn new VoiceInstances when a player connects to the server and will remove them again after they disconnect.

Signals

  • received_voice_data(data: PoolRealArray, from_id: int) Emitted when voice data is received.
  • sent_voice_data(data: PoolRealArray) Emitted when recording and data is sent.
  • created_instance(id: int) Emitted when a new VoiceInstance is created.
  • removed_instance(id: int) Emitted when a VoiceInstance is removed.

Properties

Type Name description
bool recording If true, the VoiceInstance will process and send microhphone data to the other VoipInstance.
bool listen If true, the VoiceInstance will also play any microhphone data it records.
float input_threshold Value above which microhphone data will be sent. Set to 0 to disable.
enum type_voice_instance Type of VoiceInstance used. NATIVE, GDSCRIPT

VoiceOrchestrator does not support a custom AudioStreamPlayer.

godot-voip's People

Contributors

aaronfranke avatar ikbencasdoei avatar katsurodev avatar mrminimal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godot-voip's Issues

[Feature Request] - encryption

Add an encryption for the voice chat so that no one can eavesdrop on the voice chat.
This Minecraft plugin uses the AES encryption so maybe it is possible to use it too.
Minecraft Plugin: https://github.com/henkelmax/simple-voice-chat
Godot Documentation: https://docs.godotengine.org/de/stable/classes/class_aescontext.html

I don't know how performant and how necessary it is, but maybe you could set it up as a separate branch or add a small documentation where it could be added.

Tip for submitting both a demo and an addon from the same repo

I noticed that you recently submitted Godot VoIP Demo in addition to Godot VoIP. Here's a little trick that I use for my assets GUI in VR Demo and GUI in VR Addon.

We can use the .gitattributes file to tell GitHub to exclude files when generating the ZIP. For GUI in VR Demo, the file looks like this, with very little excluded. Then, I have a separate "addon" branch for the addon, and all it does is add some more lines to this file to exclude more things, such that it looks like this. Any time you update the asset, just rebase this "addon" branch with the added exclusions, force-push, and submit the new commit hashes.

Side note: You should add eol=lf to the existing line in your .gitattributes so that Git automatically fixes line endings.

Crashes Godot on my Windows 10 Machine

This approach looked very promising unfortunately I noticed cracks and pops in the sound probably from the microphone de / activation process involved in this.

(and when I use the microphone effect like that on my (and others) machines running Windows 10 in some more sophisticated application, we suffered from Godot Engine crashes which seemed to be caused by the microphone effect but for now it was not really possible to tackle these crashes down to the exact point of failure)

[HELP WANTED] Any idea on removing echo?

I'm making an imposter party game and use this lib.
Player can hear his/her own echo.
Can some one provides me with some guide or resources on how to remove the echo?

Use Opus

Opus is the industry standard for VOIP audio.

This is because it is an upgrade over Speex & AAC - decoded Opus sounds better at the same bitrate.
Source: https://en.wikipedia.org/wiki/File:Opus_quality_comparison_colorblind_compatible.svg

See Reduz's opinion:

Opus is mostly useful in our conext for VOIP as its a good general purpose replacement for Speex, but Godot will never supply VOIP out of the box given the large and diverse amount of ways to do it.
godotengine/godot#47114 (comment)

If there is concerns about including libopus or some other binary, Android and iOS added an Opus decoder several years ago, and I can make an api to access these decoders. I expect that Windows/Mac/Linux also have an opus decoder available through a platform api.

Can't get audio to work on Linux

First of all: thank you for this project, a lot of people could use a good VOIP implementation for Godot.
This would be perfect for my multiplayer flight simulation.

Problem
When transmitting my voice, I get a cracking sound as shown in this video:
example.zip

System
Kubuntu 20.04 64 bit
Godot 3.1 (and tested on 3.2)
PulseAudio

Did you test this on Linux or was this developed using Windows/MacOS?

Thank you in advance!

Not Working on Android Platform

Godot VoIP version + Godot version:
Using recommended 3.3 version

OS/device including version:
Android

Issue description:
The addone is awesome but unfortunately not working with android at all. I even managed to run it on latest version with Enet.
Running the demo project which is included in project on Windows is perfect and sends the data chunks with 1 or 2 Mega Bytes size. Exporting the exact same demo project for android makes the game lag and sends the data with 6 or 4 Mega Bytes sizes with high latency and the voice is not recognizable at all.
I think it's something related to microphone or data format, mix rate or something like that. I have tested the project with WebSocket and Enet on various version of Godot.

Steps to reproduce:
Just Export the apk file of Demo scene of project and run on two android phone and see the result.

Minimal reproduction project:

Regards,
Mason

Not working using Godot 3.3 and Godot 3.4

Godot VoIP version + Godot version:
I'm using the latest version of Godot VoIP and I tried using Godot 3.3.4 and Godot 3.4.

OS/device including version:
Linux 5.14

Issue description:
I heard a noise, but the voice wasn't recognizable.

Steps to reproduce:
Just try it with Godot 3.3.4 or Godot 3.4.

Minimal reproduction project:
N/A

Buffer consistently growing, making the application lag and unusable

Godot VoIP version + Godot version:
VoIP: 3.2
Godot: 3.4

OS/device including version:
Kubuntu, Manjaro & Windows 10
Kernel: 5.13.0-37-generic & 5.16.2-2-rt19-MANJARO

Issue description:
Playback buffer gets bigger over time if consistently sending frames, getting to 100x bigger (Literally).

Steps to reproduce:

  • Start server
  • Put threshold to 0
  • Put toggle on
  • If alone put Listen on (To send data to the playback buffer)
  • Click on speak
  • Wait for buffer to grow (less than a minute or two)

Minimal reproduction project:
Demo scene

Potential fix:
I tried removing these lines, and it seemed to work well, no audio anomalies, which I got before removing these lines.
It seems you are pushing as much frames as there is in the playback buffer if there is, with no data. Which if it is the cases, would only make the buffer grow exponentially.

https://github.com/c-as/godot-voip/blob/4efda2b88927d5143d57973b6345d6de5da73c32/addons/godot-voip/scripts/voice_instance.gd#L68-L71

[Off-Topic] - How to make a beat detection?

This is off topic! If you do not want this, please delete this issue!

I don't want to create too many accounts for forums, so I want to ask you if you can help/explain me how to create a music beat detection in godot.
I want a pattern to move to the next step to a beat in the music. (Is this possiblein Godot?)

I hope you can help me with that,
Gamemap

Here is an example for an pattern (later as an Animationplayer in Godot)

2021-02-16.03-06-07.mp4

Error In Demo

Screen Shot 2021-05-16 at 1 52 02 PM

I downloaded it straight from your latest release on GitHub. I wouldn't be surprised if I'm just doing it wrong, but I would certainly appreciate your help troubleshooting this. I'm using Godot version 3.3 stable. I read and attempted to follow the readme.

Problem to connect to server

When I run the demo with a lan connection (no internet - direct), it sometimes does not connect to the server. I think the problem occurs when I disconnect the first connection, but restarting the program does not make it work. (It is a strange problem)
I have checked the IP address and the port number.

I don't know if this is a bug or a problem with Godot. I don't think it's because of the connection.

Update to 3.3.1

I cant seem to load the thing without errors right now on 3.3.1 (stable)

Set stereo to false

When I ran this example, the stereo flag was set to true when it printed out, which doubled the bandwidth. Stereo makes no sense if you have a single microphone. Do you know how to switch it off?

(I've also filed this issue at the demo projects repo: godotengine/godot-demo-projects#470 )

[Feature] - Disconnect

Maybe you can add a "Disconnect" button to Server and Client so you can change ip and port without have to close and reopen the programm.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.