Posts

Showing posts with the label opensource

UniVoice 4.8.0 FishNet support

UniVoice 4.8.0 is out! The key change is that FishNetworking is now finally  supported. Huge thanks to @FrantisekHolubec for this code contribution Technical details Looking at the commit, you will see that the FishNet code is very similar to the Mirror implementation. This is not an accident as FishNet has always tried to position itself as a Mirror++ and has many similarities. Honestly, I like the FishNet APIs a lot more. It's cleaner, has events for everything that was required, and unlike Mirror it didn't need any hacks to get working. A setup sample script has also been made available along with a sample scene that you can simply build and run and get a basic voice chat working. Look around the  samples  and you will realize that the FishNet and Mirror setup scripts are absolutely identical, except for two lines where we construct client and server objects. Thoughts Looking at the FishNet implementation/support scripts, it becomes really obvious that there's a lot o...

UniVoice 4.7.0: Client Tags

UniVoice 4.7.0 has been released and has a major new feature: Client Tags Overview Last year, a team using UniVoice had a question. They had 3 scenes in their Unity app that users could travel between. The app used mono (non positional) audio. But they didn't want people in two different scenes to be able to hear or speak to each other. Similarly, a project I'm consulting on has a unique requirement. It's an academic VR application with a speaker and teachers/judges. The judges should be able to hear the speaker and talk to each other, but the speaker should not hear them so that they don't get interrupted. Similarly, if I were thinking of making a 5v5 game or something similar, I would have to make sure only people on the same team can hear each other so that they can discuss strategies secretly. VoiceSettings until 4.6.0 Until version 4.6.0 VoiceSettings  only allowed to define the following: muteAll : bool mutedPeers : List<int> deafenAll : List<int> dea...

UniVoice 4.6.0: Per peer output filters

UniVoice 4.6.0 is out!  The main change in this release is per-peer output filters (instead of global filters) which fixes a bug.  But before I get into it, there are a couple smaller changes that I'd like to go over: UniMic 3.3.0 UniVoice now uses UniMic 3.3.0. This was a major improvement that I posted about in this post   ClientSession<T> constructor enhancements You don't need to implement an IAudioOutputFactory the client session object can now be constructed using a factory method instead. // This required you to create a StreamedAudioSourceOutput.Factory class that implements IAudioOutputFactory // even though it doesn't do much, it just implements Create() that returns a new object ClientSession = new ClientSession<int>(client, input, new StreamedAudioSourceOutput.Factory()); // But you you can do this. No need to create the Factory class ClientSession = new ClientSession<int>(client, input, () => new StreamedAudioSourceOutput()); Probably on...

UniMic 3.3.0: Many StreamedAudioSource improvements, thanks to MetaVoiceChat

For a couple of months, I have been getting on a weekly call with a team that's integrating UniVoice into a project but they've been facing an issue. When it's just 2 people in the room, they can hear each other perfectly. But as soon as a third person joins, everyone's audio starts popping and gets a little jittery. You can still understand the person but the audio becomes noisy and irritating after a while. The popping effect is often the cause of writing audio data to an AudioClip on a buffer strip that's still being read. Or it can happen when you write data that's too close to your reading head and before the writing operation completes the read head is already on it. I've been looking into StreamedAudioSource.cs to fix a fix for this. But it was only last week that we finally figured out that the issue is in the Concentus Decode Filter instead and I've been looking in the wrong place.  But the great thing about this detour is that during this time ...

UniVoice recipe: Adding proximity audio

 A bunch of people have asked me how can be achieve proximity audio chat. Which is a fair question given that UniVoice is primarily targeted towards games and they're often 3D. Currently proximity audio is not supported out of the box. I do have something under works that would allow you to just drag and drop a component to an avatars head and the audio of players will originate from there.  That said, until that component is ready, it's possible to get proximity audio using some code. Using the OnPeerJoined event  Look at line 128 of  UniVoiceMirrorSetupSample script that is included in the UniVoice package.  That's an event that gets invoked for every other player in the game along with their ID. Note that the peer ID is the ID that Mirror assigns, so it can be used using Mirror APIs. This will come in handy later. Here's how it works. Say you join a game that already has 5 players before you, this event will be fired 5 times immediately upon your joinin...

UniVoice 4.5.1: Mirror Host mode support

A limitation of Mirror support in UniVoice so far as been support for Host mode. The main reason for this is that most teams using UniVoice have been doing so in a dedicated server environment. However, Host mode has its own uses: - makes it much easier to test in Unity. Run the server in the editor and the client on one build. - local networking and co-op experiences. - ParellSync and other tools can be used to test multiplayer using two editor instances So it only made sense to add support for it. I marked this as an enhancement I want to make in April, but recently there was a lot of activity on the Github issue  so I got to work on it. How it works The changes are pretty simple. See the commit  here   When in Host mode, the server needs to register local client with ID 0 immediately after starting up. This happens in MirrorServer.cs on line 85 When the server stops, or goes from Host to ServerOnly mode, the local client should disconnect. This happens on lines 99 and ...

UniVoice 4.4.0: Easy drag and drop integration with Mirror (also, YouTube tutorial)

Image
A tutorial for this blogpost is available on YouTube I've recently helped a lot of people setup a basic UniVoice integration in their projects. And it became clear that the sample scene is not minimal enough. The sample scene is basically an example app that also does some UI stuff. Going through the code shows how it can be used. But what most people are looking for is to get basic voice chat working as soon as possible. I've seen some people adding the example app script to their scenes, which will not work as expected. For this reason, I have now created a basic setup sample that provides a component that you can just add to your Mirror Network manager and get voice chat working immediately. This UniVoiceMirrorSetupSample.cs  easily allows you to check if voice chat is working by making sure you have setup UniVoice properly, pretty much just adding the UNIVOICE_NETWORK_MIRROR  compilation symbol to your Mirror project. The script also provides access to the IAudioServer<...

UniVoice 4.3.0: Easy Push To Talk

Push to Talk is a popular feature to: * Encourage users to user voice chat more intentionally * Reduce CPU and bandwidth usage on both the client and the server * Avoid excess chatter when connected to several peers as they'd all be transmitting audio without it Old approach using VoiceSettings UniVoice provides a VoiceSettings class that allows a client to mute or deafen a peer.  In theory, this can be used to create a push-to-talk feature. However this isn't as straightforward. After modifying VoiceSettings , you need to call SubmitVoiceSettings() to sync it with the server. The server then makes sure that the audio you send to it doesn't get sent to anyone. Usage would be like this: session.Client.YourVoiceSettings.deafenAll = true; session.Client.SubmitVoiceSettings(); This isn't too bad, but there are a couple of limitations: * Syncing the settings with the server takes a while, so it's not as instantaneous. * The client still continues to send audio to the s...

UniVoice 4.x.x: Upgrade guide

A lot has changed between UniVoice v3 and v4, however I've tried to keep the new things "mirror" some old patterns as much as possible. There's no way to upgrade from v3 to v4 without code changes, so getting familiar with some key changes can help. In this post I'll be comparing the sample code for v4 and v3 and try to describe the differences that have been made. v4 sample v3 sample Namespace changes In v3 you'll notice these namespaces  Adrenak.UniVoice.UniMicInput  Adrenak.UniVoice.AudioSourceOutput  Adrenak.UniVoice.AirPeerNetwork  This is a remnant of the previous multi-repo approach where each repo had their own namespaces. UniVoice changed to a mono-repo one as described in an earlier post  with the key reason being ease of maintenance and integration. From v4 onwards, you can expect to need only the following namespaces: Adrenak.UniVoice.Networks; Adrenak.UniVoice.Outputs; Adrenak.UniVoice.Inputs; Adrenak.UniVoice.Filters; With all related implementat...

UniVoice 4.2.0: RNNoise noise cancellation

UniVoice was updated to 4.2.0 recently with the key change being that RNNiose is now supported. RNNoise is an amazing audio noise removal library that I've seen excellent results with. Background noise such as traffic, ambient noise are almost completely gone.  It is available in UniVoice 4.2.0 as an AudioFilter implementation called RNNoiseFilter  and is a one-line integration .    RNNoiseFilter class internally uses is used via RNNoise4Unity , a repository I made that simply makes it available as a UPM package.  Since RNNoise4Unity uses native libraries, it has not been made a direct dependency of UniVoice. Only a RNNoiseFilter.cs  is provided with UniVoice that can be activated using UNIVOICE_FILTER_RNNOISE4UNITY after you import RNNoise4Unity into your project.  Not adding packages that rely on native libraries to UniVoice dependencies is something I'm going to continue. I have highlighted in the 4.2.0 commit the following:  Activating non...

UniVoice 4+: Now a mono repo

UniVoice has been around since Jan 2019 and has been evolving towards becoming a robust VoIP solution for Unity. Recently I released version 4.x, which is a big upgrade from v3. One of the things that's changed is that UniVoice is now a mono repo. Why mono repo Previously the main repository only housed the interfaces and implementations for them were separate repositories . This caused a lot of pain for both me and any users of UniVoice. For me because if I wanted to change something in, let's say, the univoice-unimic-input  repository. I would need to open UniVoice, change the manifest to point to a local copy of the univoice-unimic-input repo so that I can test the changes locally.  For users because when they'd install the univoice package, it wouldn't really have anything usable. They'd need to install implementation packages separately. In v3, to get UniVoice to work you needed at implementations of at least three interfaces: IAudioInput, IAudioOutput and ICha...