# Table of Contents - [Dissonance Voice Chat](#dissonance-voice-chat) - [Other Integrations - Dissonance Voice Chat](#other-integrations-dissonance-voice-chat) - [Choosing A Network - Dissonance Voice Chat](#choosing-a-network-dissonance-voice-chat) - [Forge Networking Remastered - Dissonance Voice Chat](#forge-networking-remastered-dissonance-voice-chat) - [Photon Fusion - Dissonance Voice Chat](#photon-fusion-dissonance-voice-chat) - [Mirror Networking - Dissonance Voice Chat](#mirror-networking-dissonance-voice-chat) - [Photon Unity Networking - Dissonance Voice Chat](#photon-unity-networking-dissonance-voice-chat) - [WebRTC Network (self contained) - Dissonance Voice Chat](#webrtc-network-self-contained-dissonance-voice-chat) - [Licensing - Dissonance Voice Chat](#licensing-dissonance-voice-chat) - [Linux - Dissonance Voice Chat](#linux-dissonance-voice-chat) - [Android (Including Oculus Quest) - Dissonance Voice Chat](#android-including-oculus-quest-dissonance-voice-chat) - [Quick Start Steamworks.Net P2P - Dissonance Voice Chat](#quick-start-steamworks-net-p2p-dissonance-voice-chat) - [Dark Rift 2 - Dissonance Voice Chat](#dark-rift-2-dissonance-voice-chat) - [TNet3 - Dissonance Voice Chat](#tnet3-dissonance-voice-chat) - [Quick Start Photon Bolt - Dissonance Voice Chat](#quick-start-photon-bolt-dissonance-voice-chat) - [Unity Networking HLAPI - Dissonance Voice Chat](#unity-networking-hlapi-dissonance-voice-chat) - [Getting Started - Dissonance Voice Chat](#getting-started-dissonance-voice-chat) - [Basic Concepts - Dissonance Voice Chat](#basic-concepts-dissonance-voice-chat) - [MacOS - Dissonance Voice Chat](#macos-dissonance-voice-chat) - [Unity Netcode For GameObjects - Dissonance Voice Chat](#unity-netcode-for-gameobjects-dissonance-voice-chat) - [iOS - Dissonance Voice Chat](#ios-dissonance-voice-chat) - [BaseMicrophoneSubscriber - Dissonance Voice Chat](#basemicrophonesubscriber-dissonance-voice-chat) - [IMicrophoneCapture - Dissonance Voice Chat](#imicrophonecapture-dissonance-voice-chat) - [IMicrophoneSubscriber - Dissonance Voice Chat](#imicrophonesubscriber-dissonance-voice-chat) - [Voice Settings - Dissonance Voice Chat](#voice-settings-dissonance-voice-chat) - [Dissonance Comms - Dissonance Voice Chat](#dissonance-comms-dissonance-voice-chat) - [Voice Broadcast Trigger - Dissonance Voice Chat](#voice-broadcast-trigger-dissonance-voice-chat) - [Voice Proximity Broadcast Trigger - Dissonance Voice Chat](#voice-proximity-broadcast-trigger-dissonance-voice-chat) - [Voice Proximity Receipt Trigger - Dissonance Voice Chat](#voice-proximity-receipt-trigger-dissonance-voice-chat) - [Voice Receipt Trigger - Dissonance Voice Chat](#voice-receipt-trigger-dissonance-voice-chat) - [IServerClientState - Dissonance Voice Chat](#iserverclientstate-dissonance-voice-chat) - [Network Protocol - Dissonance Voice Chat](#network-protocol-dissonance-voice-chat) - [PlayerChannel - Dissonance Voice Chat](#playerchannel-dissonance-voice-chat) - [PlayerChannels - Dissonance Voice Chat](#playerchannels-dissonance-voice-chat) - [RemoteChannel - Dissonance Voice Chat](#remotechannel-dissonance-voice-chat) - [RoomChannel - Dissonance Voice Chat](#roomchannel-dissonance-voice-chat) - [RoomChannels - Dissonance Voice Chat](#roomchannels-dissonance-voice-chat) - [Rooms - Dissonance Voice Chat](#rooms-dissonance-voice-chat) - [TextChat - Dissonance Voice Chat](#textchat-dissonance-voice-chat) - [VoicePlayerState - Dissonance Voice Chat](#voiceplayerstate-dissonance-voice-chat) - [Voice Settings - Dissonance Voice Chat](#voice-settings-dissonance-voice-chat) - [Access Tokens - Dissonance Voice Chat](#access-tokens-dissonance-voice-chat) - [Audio Mixing For Voice - Dissonance Voice Chat](#audio-mixing-for-voice-dissonance-voice-chat) - [Channel Volume - Dissonance Voice Chat](#channel-volume-dissonance-voice-chat) - [Magic Leap - Dissonance Voice Chat](#magic-leap-dissonance-voice-chat) - [Oculus OVR - Dissonance Voice Chat](#oculus-ovr-dissonance-voice-chat) - [Channel Priority - Dissonance Voice Chat](#channel-priority-dissonance-voice-chat) - [Writing A Custom Microphone Capture System - Dissonance Voice Chat](#writing-a-custom-microphone-capture-system-dissonance-voice-chat) - [Collider Chat Rooms - Dissonance Voice Chat](#collider-chat-rooms-dissonance-voice-chat) - [Writing A Custom Network Integration - Dissonance Voice Chat](#writing-a-custom-network-integration-dissonance-voice-chat) - [Windows (Desktop) - Dissonance Voice Chat](#windows-desktop-dissonance-voice-chat) - [Windows (UWP/Hololens) - Dissonance Voice Chat](#windows-uwp-hololens-dissonance-voice-chat) - [Server Scripting API - Dissonance Voice Chat](#server-scripting-api-dissonance-voice-chat) - [Script Controlled Speech - Dissonance Voice Chat](#script-controlled-speech-dissonance-voice-chat) - [Spatialization Plugins - Dissonance Voice Chat](#spatialization-plugins-dissonance-voice-chat) - [Push-To-Talk - Dissonance Voice Chat](#push-to-talk-dissonance-voice-chat) - [Text Chat - Dissonance Voice Chat](#text-chat-dissonance-voice-chat) - [Other Integrations - Dissonance Voice Chat](#other-integrations-dissonance-voice-chat) - [Team Chat Rooms - Dissonance Voice Chat](#team-chat-rooms-dissonance-voice-chat) - [Transmit to Player - Dissonance Voice Chat](#transmit-to-player-dissonance-voice-chat) - [Direct Access To Recorded Audio - Dissonance Voice Chat](#direct-access-to-recorded-audio-dissonance-voice-chat) - [Writing A Custom IDissonancePlayer - Dissonance Voice Chat](#writing-a-custom-idissonanceplayer-dissonance-voice-chat) - [Global Chat Room - Dissonance Voice Chat](#global-chat-room-dissonance-voice-chat) - [Position Tracking For BOLT - Dissonance Voice Chat](#position-tracking-for-bolt-dissonance-voice-chat) - [Using Channels - Dissonance Voice Chat](#using-channels-dissonance-voice-chat) - [Acoustic Echo Cancellation - Dissonance Voice Chat](#acoustic-echo-cancellation-dissonance-voice-chat) - [Proximity Chat - Dissonance Voice Chat](#proximity-chat-dissonance-voice-chat) - [Custom AudioSource Settings - Dissonance Voice Chat](#custom-audiosource-settings-dissonance-voice-chat) - [Finding Players - Dissonance Voice Chat](#finding-players-dissonance-voice-chat) - [Position Tracking - Dissonance Voice Chat](#position-tracking-dissonance-voice-chat) - [Dissonance Voice Chat](#dissonance-voice-chat) --- # Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/#dissonance-voip) Home ==== Dissonance VoIP[⚓︎](https://placeholder-software.co.uk/dissonance/docs/#dissonance-voip "Permanent link") ---------------------------------------------------------------------------------------------------------- [Dissonance](https://placeholder-software.co.uk/dissonance/) is a realtime Voice over IP (VoIP) system designed to be built directly into Unity games. * Low latency/real-time voice communications. * Compact Opus encoding. * Multiple chat rooms. * Private messages to individual players. * Voice Activation and Push To Talk. * Positional Audio. * Echo cancellation. * Flexible Networking. Getting Started[⚓︎](https://placeholder-software.co.uk/dissonance/docs/#getting-started "Permanent link") ---------------------------------------------------------------------------------------------------------- The [**Project Setup**](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) will guide you through importing Dissonance into your project and then present you with links to tutorials. Intermediate Topics[⚓︎](https://placeholder-software.co.uk/dissonance/docs/#intermediate-topics "Permanent link") ------------------------------------------------------------------------------------------------------------------ These tutorials are intended for after you understand how to use the basic core features of Dissonance, they will guide you on how to get the most out of voice communication for your game. Advanced Topics[⚓︎](https://placeholder-software.co.uk/dissonance/docs/#advanced-topics "Permanent link") ---------------------------------------------------------------------------------------------------------- If you want to do something unusual with Dissonance the advanced tutorials are the place to start. However we can't cover everything so if what you want to achieve isn't covered try [asking the community](https://www.reddit.com/r/dissonance_voip) or [reporting an issue](https://github.com/Placeholder-Software/Dissonance) . --- # Other Integrations - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Other-Integrations.html#salsa-lip-sync) Other Integrations ================== Dissonance has optional integrations with some non-networking assets to add/improve certain features. SALSA Lip Sync[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Other-Integrations.html#salsa-lip-sync "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------- [SALSA Lip Sync](https://assetstore.unity.com/packages/tools/animation/salsa-lipsync-suite-148442?aid=1100lJDF) provides real-time lip synchronisation. The `SalsaDissonanceLink` integration connects the Dissonance audio system to the lip sync system to provide real-time lip synchronisation for other speakers in the VoIP session. For a download link and more information, see the [full documentation](https://crazyminnowstudio.com/docs/salsa-lip-sync/addons/using-with-dissonance/) on the SALSA docs. [FMOD Playback](https://assetstore.unity.com/packages/slug/213415?aid=1100lJDF) [⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Other-Integrations.html#fmod-playback "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [FMOD](https://assetstore.unity.com/packages/tools/audio/fmod-for-unity-161631?aid=1100lJDF) is a powerful alternative audio system for Unity. The [FMOD Playback](https://assetstore.unity.com/packages/slug/213415?aid=1100lJDF) integration package outputs Dissonance audio into the FMOD audio system. This allows you to mix Dissonance audio in the FMOD mixer and to completely disable the Unity audio system. If you completely disable the Unity audio system you **must** also use the FMOD Recording package. [FMOD Recording](https://assetstore.unity.com/packages/slug/213412?aid=1100lJDF) [⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Other-Integrations.html#fmod-recording "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [FMOD](https://assetstore.unity.com/packages/tools/audio/fmod-for-unity-161631?aid=1100lJDF) is a powerful alternative audio system for Unity. The [FMOD Recording](https://assetstore.unity.com/packages/slug/213412?aid=1100lJDF) integration package provides higher quality and lower latency audio to Dissonance through FMOD. Using this integration does **not** require that you are using FMOD for audio playback. You can install FMOD just for the higher quality audio recording and continue to use the normal Unity audio systems. --- # Choosing A Network - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#free-integrations) Choosing A Network ================== The core Dissonance package does not include any network - instead Dissonance relies on integrations with other network systems to send and receive data. This gives you a lot of flexibility in choosing how you want voice data to be sent over the network. If none of the existing integrations are suitable for you you can also write a custom network integration. Free Integrations[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#free-integrations "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------- Dissonance has support for 10 network systems. All of these packages can be downloaded from the asset store for free and receive support as part of Dissonance. * [Mirror Networking](https://assetstore.unity.com/packages/slug/143290?aid=1100lJDF) * [Unity Netcode For GameObjects](https://assetstore.unity.com/packages/slug/206514?aid=1100lJDF) * [UNet HLAPI](https://assetstore.unity.com/packages/slug/143285?aid=1100lJDF) * [Dark Rift 2](https://assetstore.unity.com/packages/slug/143293?aid=1100lJDF) * [Forge Remastered](https://assetstore.unity.com/packages/slug/143286?aid=1100lJDF) * [Photon Unity networking (2)](https://assetstore.unity.com/packages/slug/143288?aid=1100lJDF) * [Photon Bolt](https://assetstore.unity.com/packages/slug/143291?aid=1100lJDF) * [TNet3](https://assetstore.unity.com/packages/tools/integration/dissonance-for-tnet3-154374?aid=1100lJDF) * [Steamworks.NET (P2P)](https://assetstore.unity.com/packages/slug/143292?aid=1100lJD) * [WebRTC Network (P2P)](https://assetstore.unity.com/packages/tools/network/webrtc-video-chat-68030?aid=1100lJDF) There are also community developed and maintained packages. * [Fish Networking](https://assetstore.unity.com/packages/tools/network/fish-net-networking-evolved-207815?aid=1100lJDF) , available from [GitHub](https://github.com/LambdaTheDev/DissonanceVoiceForFishNet) . * [PurrNet](https://assetstore.unity.com/packages/tools/network/purrnet-297320?aid=1100lJDF) , available from [GitHub](https://github.com/BobsiUnity/PurrNet-VoiceChat) . My Application Already Has Networking[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#my-application-already-has-networking "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ If you already have a network system set up in your application then simply sending voice through that system is the easiest option. If there is an integration package listed above for your networking system it is recommended to use that. However, if there is no available integration package then there are two options. The first option is to build your own [custom network integration](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html) . Dissonance includes base classes which can be extended to create a new network integration relatively easily - all that is required is writing the code to send packets, receive packets and inform Dissonance about session events (leave/join/connect/disconnect etc). This requires that your networking system supports **Unreliable & Unordered** packets (e.g. UDP), TCP is **not** suitable for high quality voice chat. The second option is to establish another network session just for voice, using one of the existing integrations. Any integration can be used for this. My Application Does Not Have Networking[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#my-application-does-not-have-networking "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- If you do not have any network system already set up in your application then you can choose any supported network integration. Which One To Choose?[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#which-one-to-choose "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------- ### Mirror[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#mirror "Permanent link") [Mirror](https://assetstore.unity.com/packages/tools/network/mirror-129321?aid=1100lJDF) is a community built replacement for UNet. **If you are just starting out with Unity networking, this is our recommendation**. * [Discord](https://discord.gg/8pmJkfH) * Client/Server * No CCU limit ### Fish Networking[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#fish-networking "Permanent link") [Fish Networking](https://assetstore.unity.com/packages/tools/network/fish-net-networking-evolved-207815?aid=1100lJDF) is a free open source, easy to use, feature rich networking library for Unity. Dissonance has support for Fish networking through a **community developed** integration package, [available here](https://github.com/LambdaTheDev/DissonanceVoiceForFishNet) . * [Discord](https://discord.gg/fishnetworking) * [Documentation](https://fish-networking.gitbook.io/docs/) * Client/Server * No CCU limit ### PurrNet[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#purrnet "Permanent link") [PurrNet](https://assetstore.unity.com/packages/tools/network/purrnet-297320?aid=1100lJDF) is a free open source networking package designed for ease of use, scalability and performance. Dissonance has support for PurrNet through a **community developed** integration package, [available here](https://github.com/BobsiUnity/PurrNet-VoiceChat) . * [Discord](https://discord.gg/NP9tP9Qx9R) * [Documentation](https://purrnet.gitbook.io/) * Client/Server * No CCU limit ### Unity Netcode For GameObjects[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#unity-netcode-for-gameobjects "Permanent link") [Netcode for GameObjects](https://docs-multiplayer.unity3d.com/) is the new multiplayer solution developed by Unity. * [Documentation](https://docs-multiplayer.unity3d.com/) * Client/Server * No CCU limit ### Coherence[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#coherence "Permanent link") [Coherence](https://assetstore.unity.com/packages/tools/network/coherence-multiplayer-networking-301977?aid=1100lJDF) is a free to use network engine with scalable hosting. Coherence have developed their own integration package for Dissonance. * [Documentation](https://docs.coherence.io/manual/networking-voice) * Client/Server with Replication Server * Complete networking platform (scaling, matchmaking, persistence etc) ### Forge Remastered[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#forge-remastered "Permanent link") [Forge Remastered](https://assetstore.unity.com/packages/tools/network/forge-networking-remastered-38344?aid=1100lJDF) is a free networking system available on the asset store. * [Discord](https://discord.gg/5kMT7zN) * Client/Server * No CCU limit ### Dark Rift 2[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#dark-rift-2 "Permanent link") [Dark Rift 2](https://assetstore.unity.com/packages/tools/network/darkrift-networking-2-95309?aid=1100lJDF) is a free networking system available on the asset store. * [Discord](https://discord.gg/3dxyu3g) * Client/Server * No CCU limit * Standalone server - does not require Unity on the server ### TNet3[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#tnet3 "Permanent link") [TNet3](https://assetstore.unity.com/packages/tools/network/networking-and-serialization-tools-tnet-3-56798?aid=1100lJDF) is a networking and serialization system available on the asset store. * [Discord](https://discord.gg/tasharen) * Client/Server * No CCU limit ### Photon Unity Networking 2[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#photon-unity-networking-2 "Permanent link") [Photon Unity Networking 2](https://assetstore.unity.com/packages/tools/network/pun-2-free-119922?aid=1100lJDF) is the upgrade to the very popular Photon Unity Networking asset. It is a free (up to 20 CCU) networking system available on the asset store. * [Forum](https://forum.photonengine.com/) * Photon Cloud Hosting * CCU Limit (20 free) ### Photon Fusion[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#photon-fusion "Permanent link") [Photon Fusion](https://assetstore.unity.com/packages/tools/network/photon-fusion-267958?aid=1100lJDF) is a new network package from the developer of the very popular Photon Unity Networking asset. * [Forum](https://forum.photonengine.com/) * Photon Cloud Hosting ### WebRTC Video Chat[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#webrtc-video-chat "Permanent link") [WebRTC Video Chat](https://assetstore.unity.com/packages/tools/network/webrtc-video-chat-68030?aid=1100lJDF) is a p2p networking, voice and video chat application. This integration uses **just the networking** part of the asset to carry Dissonance voice traffic - it does _not_ integrate in a way that allows `WebRTC Voice Chat` and `Dissonance Voice Chat` to understand each other. This can be used to quickly set up a fully p2p chat session requiring only a very lightweight session server (which carries no voice traffic). * Full P2P * No CCU limit ### UNet HLAPI[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html#unet-hlapi "Permanent link") UNet is the **deprecated** Unity networking system. It is **not** recommended to use this for new applications. --- # Forge Networking Remastered - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Forge-Remastered.html#step-1-dissonance-comms-object) Forge Networking Remastered =========================== This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Dissonance/Integrations/ForgeNetworkingRemastered/Demo` folder. Please make sure to read the include readme file before trying the demo scene. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Forge-Remastered.html#step-1-dissonance-comms-object "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This game object contains the main "Dissonance Comms" behaviour, together with the Forge networking script. To place the default Dissonance game object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/ForgeNetworkingRemastered` folder into your scene. This should create a game object with two scripts attached: "Dissonance Comms" and "Forge Remastered Comms Network". Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Forge-Remastered.html#step-2-add-a-broadcast-trigger "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to our scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Forge-Remastered.html#step-3-add-a-receipt-trigger "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Forge-Remastered.html#youre-done "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------ Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # Photon Fusion - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Fusion.html#fusion-multi-peer) Photon Fusion ============= > This Quick Start guide is for those of you integrating Dissonance into a game with **Photon Fusion**. This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Dissonance/Integrations/PhotonFusion/Demo` folder. Fusion Multi Peer[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Fusion.html#fusion-multi-peer "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------- Photon Fusion Multi Peer Dissonance does not support [Fusion Multi Peer Mode](https://doc.photonengine.com/fusion/current/manual/multipeer) . Photon Fusion supports [multi peer mode](https://doc.photonengine.com/fusion/current/manual/multipeer) which allows multiple clients to run in one Unity editor instance, this is great for rapid testing. However, Dissonance uses some resources that fundamentally cannot be shared (e.g. the microphone) and does not support this mode. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Fusion.html#step-1-dissonance-comms-object "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be created as a child of your Photon Fusion "Network Runner". This object contains the main "Dissonance Comms" behaviour, together with the Photon Fusion networking script. To place the default Dissonance object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/PhotonFusion` folder into your "Network Runner" GameObject. Once you have instantiated the `DissonanceSetup` prefab, you should have an object with two scripts attached: `DissonanceComms` and `FusionCommsNetwork`. Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Fusion.html#step-2-add-a-broadcast-trigger "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to our scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Fusion.html#step-3-add-a-receipt-trigger "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Fusion.html#youre-done "Permanent link") -------------------------------------------------------------------------------------------------------------------------------- Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # Mirror Networking - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Mirror.html#step-1-dissonance-comms-object) Mirror Networking ================= > This Quick Start guide is for those of you integrating Dissonance into a game with the **Mirror Networking**. You must use a network backend which supports unreliable networking such as **Ignorance**. This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Dissonance/Integrations/MirrorIgnorance/Demo` folder. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Mirror.html#step-1-dissonance-comms-object "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This object contains the main "Dissonance Comms" behaviour, together with the Mirror networking script. To place the default Dissonance object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/MirrorIgnorance` folder into your scene. Once you have instantiated the `DissonanceSetup` prefab, you should have an object with two scripts attached: "Dissonance Comms" and `MirrorIgnoranceCommsNetwork`. ### Step 1a: Setup Network Manager[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Mirror.html#step-1a-setup-network-manager "Permanent link") In this configuration Dissonance sends it's network packets through Mirror - this means you need a Mirror session setup for Dissonance to use. To create a high level network session add a `Network Manager` to your scene, this is a Mirror component which will handle setting up your network. If you need a basic UI for test purposes also add a `Network Manager HUD` to your scene, this is another Mirror component which shows a simple UI for creating and joining sessions. Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Mirror.html#step-2-add-a-broadcast-trigger "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to our scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Mirror.html#step-3-add-a-receipt-trigger "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Mirror.html#youre-done "Permanent link") -------------------------------------------------------------------------------------------------------------------------------- Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # Photon Unity Networking - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon.html#step-1-dissonance-comms-object) Photon Unity Networking ======================= > This Quick Start guide is for those of you integrating Dissonance into a game with **Photon Unity Networking**. This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Dissonance/Integrations/Photon/Demo` folder. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon.html#step-1-dissonance-comms-object "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This object contains the main "Dissonance Comms" behaviour, together with the Photon networking script. To place the default Dissonance object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/Photon` folder into your scene. Once you have instantiated the `DissonanceSetup` prefab, you should have an object with two scripts attached: "Dissonance Comms" and `PhotonCommsNetwork`. > The Photon integration will automatically route Dissonance traffic through the Photon cloud network. Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon.html#step-2-add-a-broadcast-trigger "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to our scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon.html#step-3-add-a-receipt-trigger "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon.html#youre-done "Permanent link") -------------------------------------------------------------------------------------------------------------------------------- Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # WebRTC Network (self contained) - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-PureP2P.html#step-1-dissonance-comms-object) WebRTC Network (self contained) =============================== > This Quick Start guide is for those of you integrating Dissonance into a game with the **WebRTC Network** asset. > > **This integration requires Dissonance 6.2.5 or greater.** This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Assets/Dissonance/Integrations/PureP2P/Demo` folder. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-PureP2P.html#step-1-dissonance-comms-object "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This object contains the main "Dissonance Comms" behaviour, together with the PureP2P networking script. To place the default Dissonance object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/PureP2P` folder into your scene. Once you have instantiated the `DissonanceSetup` prefab, you should have an object with two scripts attached: `Dissonance Comms` and `Pure P2P Comms Network`. ### Step 1a: Setup Network Session[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-PureP2P.html#step-1a-setup-network-session "Permanent link") Dissonance internally manages the WebRTC network session, automatically hosting a session and connecting to other peers as they join. From your script you simply need to call `InitializeAsServer` or `InitializeAsClient` on the `PureP2PCommsNetwork` component and supply the same session ID to both calls. If the peer leaves the session you will need to start a new server with a new session ID and connect all the clients again. Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-PureP2P.html#step-2-add-a-broadcast-trigger "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to our scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-PureP2P.html#step-3-add-a-receipt-trigger "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-PureP2P.html#youre-done "Permanent link") --------------------------------------------------------------------------------------------------------------------------------- Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # Licensing - Dissonance Voice Chat Licensing ========= Dissonance uses some open source libraries to provide audio preprocessing, postprocessing, encoding and decoding. The distribution requirements for the projects used are all very simple - you must include copies of the license files in distributions of your project. * [Opus License](https://opus-codec.org/license/) * [WebRTC License](https://webrtc.org/support/license/) * [RNNoise License](https://github.com/xiph/rnnoise/blob/master/COPYING) --- # Linux - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Platforms/Linux.html#linux) Linux[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/Linux.html#linux "Permanent link") ========================================================================================================== Running Dissonance on a Linux PC has no runtime dependencies. --- # Android (Including Oculus Quest) - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Platforms/Android.html#android-including-oculus-quest) Android (Including Oculus Quest)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/Android.html#android-including-oculus-quest "Permanent link") ================================================================================================================================================================ On Android the user must grant permission before the Microphone is accessed. Since Dissonance uses the Unity `Microphone` class the `Record_Audio` permission should have already been added to the [app manifest](https://docs.unity3d.com/Manual/android-manifest.html) . When the application is started the user is asked for all of the permissions in the manifest in one dialog. If `Microphone` permission is not granted when Dissonance is started it will operate in listen-only mode. The [Runtime Permission System](https://docs.unity3d.com/Manual/android-RequestingPermissions.html) may be be used to request permission from the user again at any time. If permission is granted after Dissonance has already started you should call [DissonanceComms.ResetMicrophoneCapture](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#resetmicrophonecapture) to restart the microphone recording system. --- # Quick Start Steamworks.Net P2P - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Steamworks.Net-P2P.html#step-1-dissonance-comms-object) Quick Start Steamworks.Net P2P ============================== > This Quick Start guide is for those of you integrating Dissonance into a game with the **Steamworks.NET P2P API** This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Dissonance/Integrations/SteamworksP2P/Demo` folder. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Steamworks.Net-P2P.html#step-1-dissonance-comms-object "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This object contains the main "Dissonance Comms" behaviour, together with the Steamworks P2P networking script. To place the default Dissonance object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/SteamworksP2P` folder into your scene. Once you have instantiated the `DissonanceSetup` prefab, you should have an object with two scripts attached: "Dissonance Comms" and `SteamworksP2PCommsNetwork`. ### Step 1a: Setup Network Session[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Steamworks.Net-P2P.html#step-1a-setup-network-session "Permanent link") Dissonance does not manage your steamworks session, instead it uses whatever session you have already setup. This gives you maximum control over how you want the network session to be configured. Refer to the [Steamworks Networking Documentation](https://partner.steamgames.com/doc/features/multiplayer/networking) for details on how to setup a session. You can see example code in the `SteamworksDemoUi` component in the `Assets/Dissonance/Integrations/SteamworksP2P/Demo` folder. Once you have a Steamworks session running you need to inform Dissonance about the state of the session when it changes. When you have a session running you need to start Dissonance, call one of `InitializeAsDedicatedServer`, `InitializeAsServer` or `InitializeAsClient` on the `SteamworksP2PCommsNetwork` component. The server is the central control point of the session, if it leaves the game you must stop Dissonance and pick a new server. When a player joins the session you must call the `PeerConnected` method. When a player leaves the session you must call the `PeerDisconnected` method. Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Steamworks.Net-P2P.html#step-2-add-a-broadcast-trigger "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to our scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Steamworks.Net-P2P.html#step-3-add-a-receipt-trigger "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Steamworks.Net-P2P.html#youre-done "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------- Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # Dark Rift 2 - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-DR2.html#step-1-dissonance-comms-object) Dark Rift 2 =========== > This Quick Start guide is for those of you integrating Dissonance into a game with **Dark Rift 2**. This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Dissonance/Integrations/DarkRift2/Demo` folder. Note that to use the demo scene you must install the server plugins (see section 1a). Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-DR2.html#step-1-dissonance-comms-object "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This game object contains the main "Dissonance Comms" behaviour, together with the Dark Rift networking script. To place the default Dissonance game object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/DarkRift2` folder into your scene. This should create a game object with two scripts attached: "Dissonance Comms" and "Dark Rift 2 Comms Network". Step 1a: Server Setup[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-DR2.html#step-1a-server-setup "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ Dark Rift has a system of server side plugins to process packets, Dissonance includes two plugins. For the demo scene there is a `DissonanceDemoPlugin.dll`, this is a very basic plugin to synchronise the positions of characters in the demo scene. There is also the `DissonanceServerPlugin.dll` which runs the Dissonance server logic. The precompiled plugin DLL files are included in the package, simply drop them into the plugins folder on your dark rift server. Sometimes these plugins can confuse Unity because they are not Unity plugins but Unity might try to load them anyway - if you have an error which mentions `... ambiguous between the following methods or properties` then you should remove the server plugins from with the Unity project to prevent Unity from trying to load them. If you need to modify the code of the plugins contact `admin@placeholder-software.co.uk` with your invoice number to request the source code. Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-DR2.html#step-2-add-a-broadcast-trigger "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to your scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-DR2.html#step-3-add-a-receipt-trigger "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-DR2.html#youre-done "Permanent link") ----------------------------------------------------------------------------------------------------------------------------- Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # TNet3 - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-TNet3.html#step-1-dissonance-comms-object) TNet3 ===== > This Quick Start guide is for those of you integrating Dissonance into a game with the **[TNet3](https://assetstore.unity.com/packages/tools/network/networking-and-serialization-tools-tnet-3-56798?aid=1100lJDF) > ** asset. > > **This integration requires Dissonance 6.4.2 or greater.** This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Assets/Dissonance/Integrations/TNet3/Demo` folder. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-TNet3.html#step-1-dissonance-comms-object "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This object contains the main "Dissonance Comms" behaviour, together with the TNet3 networking script. To place the default Dissonance object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/TNet3` folder into your scene. Once you have instantiated the `DissonanceSetup` prefab, you should have an object with two scripts attached: `Dissonance Comms` and `Tnet3 Comms Network`. ### Step 1a: Network Channel Setup[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-TNet3.html#step-1a-network-channel-setup "Permanent link") A single TNet3 server hosts multiple channels at once, players can only send and receive packets to channels they have joined. The Dissonance integration automatically hosts a voice session in a separate channel - this means you can potentially host multiple completely independent voice chat sessions on a single TNet3 server. Once your game is started you need to choose which voice session to host/join for each peer that connects: To begin hosting a new session in a channel: `var tcnc = FindObjectOfType(); tncn.HostVoiceChannel(channel_id, max_players, "password", is_dedicated_server);` This will begin hosting a new Dissonance voice chat session in the channel identified by `channel_id`. If `is_dedicated_server` is true then the local instance will _not_ be able to send or receive audio - it is simpl acting as a network host. To join an existing session: `var tcnc = FindObjectOfType(); tcnc.JoinVoiceChannel(channel_id, "password");` This will attempt to join a session in the specified `channel_id`. These methods can be called again at any time to change the mode of Dissonance. Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-TNet3.html#step-2-add-a-broadcast-trigger "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to the scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-TNet3.html#step-3-add-a-receipt-trigger "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-TNet3.html#youre-done "Permanent link") ------------------------------------------------------------------------------------------------------------------------------- Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # Quick Start Photon Bolt - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon-Bolt.html#setup-bolt) Quick Start Photon Bolt ======================= > This Quick Start guide is for those of you integrating Dissonance into a game with the **[Photon BOLT networking asset](https://www.assetstore.unity3d.com/en/#!/content/83233) > ** This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Dissonance/Integrations/PhotonBolt/Demo` folder. Setup BOLT[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon-Bolt.html#setup-bolt "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------- Photon BOLT requires defining the packet types it can send and receive in the Unity editor. Add two new Events (both with no properties): * DissonanceToClient * DissonanceToServer For the Demo scene to correctly synchronise player positions you will also need to add a new "State", details of this are in the README in the demo folder. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon-Bolt.html#step-1-dissonance-comms-object "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This object contains the main "Dissonance Comms" behaviour, together with the Photon networking script. To place the default Dissonance object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/PhotonBolt` folder into your scene. Once you have instantiated the `DissonanceSetup` prefab, you should have an object with two scripts attached: "Dissonance Comms" and `Bolt Comms Network`. > The Photon BOLT integration will automatically route Dissonance traffic through an established BOLT session. Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon-Bolt.html#step-2-add-a-broadcast-trigger "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to our scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon-Bolt.html#step-3-add-a-receipt-trigger "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon-Bolt.html#youre-done "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------- Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) Note that setting up positional audio for bolt requires some extra steps, see this article for more detail: * [3D Positional Audio For BOLT](https://placeholder-software.co.uk/Tutorials/Position-Tracking-For-Bolt) --- # Unity Networking HLAPI - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-UNet-HLAPI.html#step-1-dissonance-comms-object) Unity Networking HLAPI ====================== > This Quick Start guide is for those of you integrating Dissonance into a game with the **Unity Networking High Level API**. This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Dissonance/Integrations/UNet_HLAPI/Demo` folder. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-UNet-HLAPI.html#step-1-dissonance-comms-object "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This object contains the main "Dissonance Comms" behaviour, together with the UNet HLAPI networking script. To place the default Dissonance object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/UNet_HLAPI` folder into your scene. Once you have instantiated the `DissonanceSetup` prefab, you should have an object with two scripts attached: "Dissonance Comms" and `HlapiCommsNetwork`. ### Step 1a: Setup Network Manager[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-UNet-HLAPI.html#step-1a-setup-network-manager "Permanent link") In this configuration Dissonance sends it's network packets through the UNet High Level API - this means you need a high level network session setup for Dissonance to use. To create a high level network session add a `Network Manager` to your scene, this is a Unity component which will handle setting up your network. If you need a basic UI for test purposes also add a `Network Manager HUD` to your scene, this is another Unity component which shows a simple UI for creating and joining sessions. Dissonance needs two network channels to send it's data through. On the `Network Manager` component check the `Advanced Configuration` checkbox and add two new channels, configure one as `Reliable Sequenced` and the other as `Unreliable`. In the Dissonance `Hlapi Comms Network` inspector check the `Reliable Channel` and `Unreliable Channel` fields correspond to the channels numbers in the `Network Manager`. ![HLAPI QoS Channels](https://placeholder-software.co.uk/dissonance/docs/images/HLAPI_QoS_Channels.png) Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-UNet-HLAPI.html#step-2-add-a-broadcast-trigger "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to our scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-UNet-HLAPI.html#step-3-add-a-receipt-trigger "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-UNet-HLAPI.html#youre-done "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------ Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # Getting Started - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html#1-import-dissonance) Getting Started =============== In this tutorial you will create a new project, import Dissonance and change some settings required for Dissonance to work properly. ### 1\. Import Dissonance[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html#1-import-dissonance "Permanent link") Import the Dissonance asset into the project. This will install two folders into your project: `Assets/Plugins/Dissonance` contains the main source code of Dissonance, `Assets/Dissonance` will contain any integration packages which you install. ### 2\. Download Integrations[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html#2-download-integrations "Permanent link") When you import a new version of Dissonance a window will pop up with a list of available integrations, you can launch this window again by navigating to `Windows > Dissonance > Download Integrations`. To use Dissonance you **must** install at a network backend integration - without this Dissonance cannot send anything over the network! Refer to [these docs](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html) for help on choosing which one to use. Each integration package includes a demo scene, you should run this demo scene once you have installed the package to verify that Dissonance is properly installed and working in your project. You may also wish to use some of our other integrations. Refer to [these docs](https://placeholder-software.co.uk/dissonance/docs/Basics/Other-Integrations) for a list of what's available. ### 3\. Run In Background[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html#3-run-in-background "Permanent link") Multiplayer games need to keep running (and processing network packets) even when the game window does not have focus. To do this navigate to `Edit -> Project Settings -> Player` and enable **Run In Background**. ### 4\. Per Platform Specific Setup[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html#4-per-platform-specific-setup "Permanent link") Some platforms have special setup requirements, make sure to read the documentation for the platforms you want to work with: * [Android & Oculus Go](https://placeholder-software.co.uk/dissonance/docs/Platforms/Android.html) * [iOS](https://placeholder-software.co.uk/dissonance/docs/Platforms/iOS.html) * [Linux](https://placeholder-software.co.uk/dissonance/docs/Platforms/Linux.html) * [MacOS](https://placeholder-software.co.uk/dissonance/docs/Platforms/MacOS.html) * [Magic Leap](https://placeholder-software.co.uk/dissonance/docs/Platforms/Magic%20Leap.html) * [Windows (Desktop)](https://placeholder-software.co.uk/dissonance/docs/Platforms/Windows%20Desktop.html) * [Windows (UWP/Hololens)](https://placeholder-software.co.uk/dissonance/docs/Platforms/Windows%20UWP%20%26%20Hololens.html) * [Oculus OVR](https://placeholder-software.co.uk/dissonance/docs/Platforms/Oculus%20OVR.html) 4\. Complete![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html#4-complete "Permanent link") ------------------------------------------------------------------------------------------------------------------------------ That's all you need to get a project set up and ready for Dissonance. Next, follow the appropriate Quick Start tutorial for the network system you plan to use: * [Quick Start - Mirror](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Mirror.html) * [Quick Start - Forge Remastered](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Forge-Remastered.html) * [Quick Start - Photon (PUN2)](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon.html) * [Quick Start - Photon Bolt](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Photon-Bolt.html) * [Quick Start - Unity Netcode For GameObjects](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Unity-NFGO.html) * [Quick Start - Unity Networking HLAPI](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-UNet-HLAPI.html) * [Quick Start - Dark🗲Rift 2](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-DR2.html) * [Quick Start - WebRTC Network](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-PureP2P.html) * [Quick Start - Steamworks.NET](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Steamworks.Net-P2P.html) * [Quick Start - TNet3](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-TNet3.html) --- # Basic Concepts - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Introduction-To-Chat-Rooms.html#who-hears-whom) Basic Concepts ============== Who Hears Whom?[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Introduction-To-Chat-Rooms.html#who-hears-whom "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------- By default when a player speaks no one one will hear them - before players can communicate you need to set up where to send voice to on the speaking end and where to receive voice from on the listening end. Where to send to is controlled by a "[Voice Broadcast Trigger](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html) " component and where to receive from is controlled by a "[Voice Receipt Trigger](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Receipt-Trigger.html) " component. Speech Intent[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Introduction-To-Chat-Rooms.html#speech-intent "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------- The "Voice Broadcast Trigger" does not only control who sends to where it also controls _when_ voice is transmitted to the given target. This is referred to as "Activation" and is divided into two further section: does the user _want_ to speak and is the user _allowed_ to speak. The "Activation Mode" setting on the "Voice Broadcast Trigger" determines how the user indicates if they want to speak, this can be set to: "None", "Voice Activation" and "Push To Talk" (see the [Voice Broadcast Trigger](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html) reference documentation for further details). The "Trigger Activation" setting is the setting for if the user is allowed to speak, an associated trigger volume can enable and disable the broadcast as the player moves in and out of the volume. This can be used to create areas in the scene the player needs to stand inside to be heard (e.g. proximity chat). Sender Target[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Introduction-To-Chat-Rooms.html#sender-target "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------- ![Target setting highlighted on broadcast trigger inspector](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Targets.png "Target setting highlighted on broadcast trigger inspector") The broadcast trigger component supports three types of target: Room, Player and Self. The setting for this highlighted in the image above. #### Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Introduction-To-Chat-Rooms.html#room "Permanent link") When the target of a broadcaster is set to "Room" then the local voice will be sent to the given room. Other players who have subscribed to the same room will hear what is said. If a player is both sending and receiving from the same room they will _not_ hear themselves speaking. #### Player[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Introduction-To-Chat-Rooms.html#player "Permanent link") When the target of a broadcaster is set to "Player" the the local voice will be sent only to the player specified by the "Recipient Player Name" field. The receiving player will automatically receive this without setting up a "Voice Receipt Trigger". #### Self[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Introduction-To-Chat-Rooms.html#self "Permanent link") When the target of a bradocaster is set to "Self" the broadcaster will look for a "Dissonance Player" component attached to the same game object and will send the local voice to the player represented by that component. This is equivalent to the player mode. The receiving player will automatically receive this without setting up a "Voice Receipt Trigger". Receiver[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Introduction-To-Chat-Rooms.html#receiver "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------- ![Rooms setting on the receipt trigger inspector](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Rooms.png "Rooms setting on the receipt trigger inspector") If the sending target is "Player" or "Self" then the receiving player automatically hears anything transmitted to them. However this is not the case for rooms, receiving players need to subscribe to rooms they wish to listen to, this is controlled by the "Voice Receipt Trigger". When the trigger component is activated voice will be received from the given room. Specific Setups[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Introduction-To-Chat-Rooms.html#specific-setups "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ This system of broadcasters and receivers is very flexible and allows for a variety of different setups. This documentation includes some specific examples but if you have a specific design in mind which is not covered here feel free to [raise an issue](https://github.com/Placeholder-Software/Dissonance/issues) or [discuss it](https://www.reddit.com/r/dissonance_voip/) with the community. --- # MacOS - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Platforms/MacOS.html#macos) MacOS[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/MacOS.html#macos "Permanent link") ========================================================================================================== Running Dissonance on MacOS has no runtime dependencies. Permission[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/MacOS.html#permission "Permanent link") ==================================================================================================================== To record audio a MacOS app requires permission from the user. See the Unity docs [here](https://docs.unity3d.com/ScriptReference/Application.RequestUserAuthorization.html) and the Apple docs [here](https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos) on how to request permission. Notarization[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/MacOS.html#notarization "Permanent link") ======================================================================================================================== All applications running on MacOS Catalina 10.15 require "notarization". See the Apple docs [here](https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution) and a tutorial on permissions and notarization for Unity apps [here](https://gist.github.com/dpid/270bdb6c1011fe07211edf431b2d0fe4) . To access the microphone you will need to add two keys to the entitlements file: * com.apple.security.device.audio-input * com.apple.security.device.microphone You may need to add other keys to enable access to networking. --- # Unity Netcode For GameObjects - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Unity-NFGO.html#step-1-dissonance-comms-object) Unity Netcode For GameObjects ============================= > This Quick Start guide is for those of you integrating Dissonance into a game with **Unity Netcode For GameObjects**. This tutorial will guide you through the steps required to get a basic Dissonance setup working in your project. By the end of this tutorial, you will having working voice comms with all users talking in a global chat room. Before beginning this tutorial, please refer to the [installation guide](https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html) to learn how to install Dissonance into your project. A demo scene for this tutorial can be found in the `Dissonance/Integrations/UNet_NFGO/Demo` folder. Step 1: Dissonance Comms Object[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Unity-NFGO.html#step-1-dissonance-comms-object "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Dissonance runs mostly from a single game object, which should be placed somewhere near the root of your scene. This object contains the main "Dissonance Comms" behaviour, together with the UNet HLAPI networking script. To place the default Dissonance object into your scene, drag and drop the `DissonanceSetup` prefab from the `Dissonance/Integrations/UNet_NFGO` folder into your scene. Once you have instantiated the `DissonanceSetup` prefab, you should have an object with two scripts attached: `DissonanceComms` and `NfgoCommsNetwork`. Step 2: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Unity-NFGO.html#step-2-add-a-broadcast-trigger "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a functional Dissonance comms system, but you are not yet transmitting anything. Before you can speak to anyone, you need to add a "Voice Broadcast Trigger" script to our scene. This script can be placed anywhere, but for this tutorial, you should simply add it to the DissonanceSetup game object you created in step 1. The "Voice Broadcast Trigger" controls when the user's microphone is being transmitted to other players, and to whom the user is talking. There are many configuration options on this script to provide more advanced control of under what situations we should be transmitting and who to, but for this tutorial simply leave the settings at default. ![Broadcast Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Default.png) To set up the broadcast trigger, change the following two settings: 1. Transmit on _Voice Activation_. This means Dissonance will transmit whenever it detects that the user is speaking. 2. Transmit to the 'Global' chat room. Step 3: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Unity-NFGO.html#step-3-add-a-receipt-trigger "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you are talking into the 'Global' room automatically whenever you speak. However, you still can't hear anyone speaking. This is because you are not listening to the 'Global' room and so you are not receiving any of these transmissions. To listen to the 'Global' room, add a "Voice Receipt Trigger" to the scene. Like the "Voice Broadcast Trigger", this script can be placed anywhere, but for this tutorial you should simply add it to the DissonanceSetup game object. ![Receipt Trigger Configuration](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Default.png) Again, leave this on the default configuration, which should have trigger activation disabled and be listening to the 'Global' chat room. You're Done![⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Quick-Start-Unity-NFGO.html#youre-done "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------ Congratulations, you have now added voice comms to your game! What to do next? * [Transmit on key press with Push-to-Talk](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html) * [Set up per-team chat channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html) * [Direct message another player](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) * [Send text chat messages](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) * [3D Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) * [3D Area Chat Rooms](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) * [Proximity Chat: Talk to players near each other](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html) --- # iOS - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Platforms/iOS.html#ios) iOS[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/iOS.html#ios "Permanent link") ==================================================================================================== Running Dissonance on iOS has no runtime dependencies. In the [Player Settings for iOS](https://docs.unity3d.com/Manual/class-PlayerSettingsiOS.html) there are four settings relevant to voice chat: * `Microphone Usage Description`: You **_must_** enter the reason for accessing the microphone on the iOS device. * `Prepare iOS for Recording`: You **_must_** enable this setting to enable low latency audio recording. * * * * `Mute Other Audio Sources`: You **_may_** enable this to ensure that background audio does not interfere with voice audio. * `Force iOS Speakers when Recording`: You **_may_** enable this to force audio to the speakers even when headphones are plugged in. If this is not enabled _all_ application audio will be played through the call speakers instead of the main speakers as soon as recording starts. --- # BaseMicrophoneSubscriber - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/BaseMicrophoneSubscriber.html#basemicrophonesubscriber) BaseMicrophoneSubscriber[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/BaseMicrophoneSubscriber.html#basemicrophonesubscriber "Permanent link") ========================================================================================================================================================================= This script makes it easier to directly access the recorded audio data. All methods on this script are called on the main thread. Implement a new script with `BaseMicrophoneSubscriber` as the base class instead of `MonoBehaviour`, once you have done this register an instance of the behaviour to receive data by calling `DissonanceComms.SubscribeToRecordedAudio`. See also [IMicrophoneSubscriber](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneSubscriber.html) which does not have any of the ease-of-use features of this script, providing more direct access. ### ResetAudioStream(WaveFormat waveFormat)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/BaseMicrophoneSubscriber.html#resetaudiostreamwaveformat-waveformat "Permanent link") This method is called by Dissonance whenever the audio stream is being reset, or the audio format is changing. The `waveFormat` argument indicates the format of the next data which will be delivered. When this is called you should immediately finish any work you were doing with the audio and prepare for more audio to be delivered soon. For example if you are recording audio to a file you would flush the file writer and close the file handle. ### ProcessAudio(ArraySegment data)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/BaseMicrophoneSubscriber.html#processaudioarraysegment-data "Permanent link") This method is called by Dissonance for every frame of recorded audio data. The `data` argument contains raw PCM audio data. After this method has finished executing you **must not** hold any references to the `data` argument. Any data that you want to store for processing later must be copied out of the `data`. --- # IMicrophoneCapture - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#imicrophonecapture) IMicrophoneCapture[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#imicrophonecapture "Permanent link") ======================================================================================================================================================= This interface designates a behaviour as a microphone capture system which feeds audio into Dissonance. Default Microphone Capture[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#default-microphone-capture "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- When the DissonanceComms component `Start` method is called (just once when the component is first enabled) Dissonance will look for a sibling component which implements the `IMicrophoneCapture` interface. If it does not find a suitable component it will create a `BasicMicrophoneCapture` component which internally uses the Unity [Microphone API](https://docs.unity3d.com/ScriptReference/Microphone.html) . To use your custom microphone script simply drop it onto the same gameObject as DissonanceComms. ### bool IsRecording[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#bool-isrecording "Permanent link") This property indicates if the microphone component is currently recording. While this is true audio **must** be delivered to subscribers at approximately realtime rates. Delivering audio too quickly will cause buffer overflows (these are handled by Dissonance, but audio will be lost). If your capture system does not have audio available when `Update` is called it is ok to not supply audio for one or two calls (as long as a subsequent call delivers enough audio to make up for that dead time). However, if the capture system has truly stopping supply audio you must either return `true` from `Update` (to force a reset) or just return silence (to cover up for the problem). ### TimeSpan Latency[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#timespan-latency "Permanent link") This property should give the estimated latency of the microphone capture system. This is the total time from audio physically hitting the microphone hardware to the data being passed on to subscribers. ### WaveFormat StartCapture(string mic\_name)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#waveformat-startcapturestring-mic_name "Permanent link") Attempt to begin recording. The return value indicates what format the captured data will be. If microphone capture cannot be started for any reason this method should return null. The microphone name is passed through from the UI, how it is interpreted depends upon what kind of audio capture system you are using. Once this method has returned a non-null value `IsRecording` _must_ be set to `true` until `StopCapture` is called. ### StopCapture()[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#stopcapture "Permanent link") Immediately stops microphone capture, discarding any data remaining in internal buffers. `IsRecording` _must_ be set to `false` after this is called. ### Subscribe(IMicrophoneSubscriber subscriber)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#subscribeimicrophonesubscriber-subscriber "Permanent link") Subscribes a new object to receive raw microphone data. ### bool Unsubscribe(IMicrophoneSubscriber subscriber)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#bool-unsubscribeimicrophonesubscriber-subscriber "Permanent link") Attempts to remove a previously subscribed object. Returns whether the object was found (if it was found it is assumed it was successfully removed). ### bool Update()[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html#bool-update "Permanent link") Pass buffered data on to the subscribers. Returns true if the microphone needs to be reset. In this case Stop will immediately be called (and start may be called afterwards). --- # IMicrophoneSubscriber - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneSubscriber.html#imicrophonesubscriber) IMicrophoneSubscriber[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneSubscriber.html#imicrophonesubscriber "Permanent link") ================================================================================================================================================================ This interface allows a script to be added into the Dissonance audio recording pipeline, giving you direct access to the audio data. Once you have implemented the `IMicrophoneSubscriber` on a class you can register an instance of the class to receive data by calling `DissonanceComms.SubscribeToRecordedAudio`. See [this tutorial](https://placeholder-software.co.uk/dissonance/docs/Tutorials/UsingIMicrophoneSubscriber.html) for more information. The methods on this interface are automatically called by Dissonance, they **are not called on the main thread**. You must be careful in implementations of this interface to handle See also [BaseMicrophoneSubscriber](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/BaseMicrophoneSubscriber.html) which implements this interface in an more convenient package. ### Reset[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneSubscriber.html#reset "Permanent link") This method is called by Dissonance whenever the audio pipeline is being reset. When this is called you should immediately finish any work you were doing with the audio and prepare for more audio to be delivered soon. For example if you are recording audio to a file you would flush the file writer and close the file handle. ### ReceiveMicrophoneData[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneSubscriber.html#receivemicrophonedata "Permanent link") This method is called by Dissonance for every frame of recorded audio data. The `buffer` argument contains raw PCM audio data. The `format` argument indicates the format of the data in the buffer, this will only change after `Reset` has been called. After this method has finished executing you **must not** hold any references to the `buffer` argument. Any data that you want to store for processing later must be copied out of the `buffer`. --- # Voice Settings - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#voice-settings) Voice Settings[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#voice-settings "Permanent link") ========================================================================================================================================== Voice settings is a central place to control various audio settings Dissonance uses. Voice settings can be accessed through `Window > Dissonance > Quality Settings`. ![Voice Settings Editor](https://placeholder-software.co.uk/dissonance/docs/images/VoiceSettings_Editor.png) Persistence[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#persistence "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------ These settings are serialized into an asset file at `Assets/Plugins/Dissonance/Resources/VoiceSettings.asset` and are also saved into [PlayerPrefs](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html) . `PlayerPrefs` override the values saved in the asset. Because the settings are saved into an asset the values you choose will be built into your game and will be the default values used by all players. Because settings are saved into `PlayerPrefs` you can expose the settings to end users in your UI and the values will be saved on a per user basis. Frame Size[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#frame-size "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------- * Tiny (10ms) **LAN ONLY** * Small (20ms) * Medium (40ms) * Large (60ms) This setting determines how much voice data is sent in a single network packet. There is some overhead associated with each individual packet - using larger values will send less packets-per-second and thus reduce CPU load and network usage. However, larger packets introduce more latency (more delay between speaking and hearing). Latency is a very important aspect of perceived voice quality and lowering this will improve the flow of conversations. The `Tiny` option (10ms packets) is the lowest latency option. However due to the very high rate of packets (100/second) it is **not suitable for use over the internet**, only use it in a local area network when latency is very important (e.g. shared space VR). Audio Quality[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#audio-quality "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------- * Low (~10KB/s) * Medium (~17KB/s) * High (~24KB/s) This setting determines the bitrate the encoder will target - higher values result in higher audio quality but slightly more CPU load and network usage. Forward Error Correction[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#forward-error-correction "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------- Forward error correction includes extra information in audio packets when network conditions are bad. When a packet is lost due to bad network conditions the audio decoder can use this extra information in other packets to reconstruct a lower quality version of the lost audio. This can almost completely conceal small amounts of packet loss at the cost of ~10% more data used when bad network conditions are detected. Noise Suppression[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#noise-suppression "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ This setting determines how much noise suppression will be applied to the microphone signal before transmission. Noise in this sense is any sound which is not speech such as computer fans or microphone hiss. Noise suppression will not remove echoes other other voices playing through your speakers. Noise suppression is not perfect and may sometimes distort speech, higher levels will remove more background noise but also risk more distortion of speech. However, the risk is fairly low - the distortion is quite minor and the noise suppressor is adaptive so it will only apply really high noise suppression when there is a lot of background noise. Voice Detector Sensitivity[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#voice-detector-sensitivity "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ This setting determines how sensitive the voice detector is. This settings is a tradeoff between accuracy (never classifying non-voice audio as voice) and sensitivity (never classifying voice audio as non-voice). Higher values will send more non-voice background noise. Acoustic Echo Cancellation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#acoustic-echo-cancellation "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ These settings control the acoustic echo canceller, this observes sounds coming out of the speakers and then attempts to remove these sounds from the microphone signal after a short delay. It automatically calibrates the delay so expect a short period (10-40 seconds) where no echoes will be cancelled, if there is no sounds coming out of the speakers at all (or the microphone is not detecting those sounds) it will not be able to calibrate the delay. Refer to [these docs](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html) for a tutorial on correctly setting up the acoustic echo canceller. #### Mobile Echo Cancellation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#mobile-echo-cancellation "Permanent link") This controls how much the echo canceller tries to cancel echo on mobile devices. #### Desktop Echo Cancellation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#desktop-echo-cancellation "Permanent link") This controls how much the echo canceller tries to cancel echo on desktop PCs. Audio Duck Attenuation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/VoiceSettings.html#audio-duck-attenuation "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------- This controls how much remote voices will be attenuated by (reduced in volume) when the local speaker is transmitting. --- # Dissonance Comms - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#dissonance-comms) Dissonance Comms[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#dissonance-comms "Permanent link") ====================================================================================================================================================== The Dissonance Comms component is the central place to configure Dissonance. There must be an active one within the scene for Dissonance to work. ![Dissonance Comms Inspector](https://placeholder-software.co.uk/dissonance/docs/images/DissonanceComms_Inspector.png "Dissonance Comms Inspector") Playback Prefab[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#playback-prefab "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------- This is a prefab for the audio playback system. For every remote player who is in the voice session Dissonance will instantiate this prefab, and use it to play the voice from that player. If left blank the default playback prefab included with Dissonance will be used. Read more about the playback prefab and how you can customise it [here](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Playback-Prefab.html) . Mute[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#mute "Permanent link") ------------------------------------------------------------------------------------------------------------------------------ This will prevent the local player from sending any voice. Access Tokens[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#access-tokens "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ This is the set of [access tokens](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html) which the local player has. Voice Settings[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#voice-settings "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------- Clicking this button opens an inspector where audio settings relating to voice may be changed. Configure Rooms[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#configure-rooms "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------- Clicking this button opens an inspector where rooms can be created or deleted. Diagnostic Settings[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#diagnostic-settings "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------ Clicking this button opens an inspector where Dissonance diagnostic settings may be changed (e.g. log levels). Scripting[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#scripting "Permanent link") ======================================================================================================================================== Dissonance Comms is also the central place to access Dissonance from scripts. Readonly Properties[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#readonly-properties "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------ ### IsNetworkInitialised : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#isnetworkinitialised-bool "Permanent link") Indicates if the Dissonance network has been successfully initialised yet. ### Rooms : Rooms[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#rooms-rooms "Permanent link") An object which exposes various properties and methods to do with rooms the local player is listening to. See further documentation [here](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/Rooms.html) . ### PlayerChannels : PlayerChannels[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#playerchannels-playerchannels "Permanent link") An object which exposes various properties and method to do with players the local player is speaking to. See further documentation [here](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannels.html) . ### RoomChannels : RoomChannels[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#roomchannels-roomchannels "Permanent link") An object which exposes various properties and methods to do with room the local player is speaking to. See further documentation [here](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannels.html) . ### Text : TextChat[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#text-textchat "Permanent link") An object which exposes various properties and methods to do with text chat. See further documentation [here](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/TextChat.html) . ### Players : ReadOnlyCollection[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#players-readonlycollectionvoiceplayerstate "Permanent link") A list of `VoicePlayerState` objects, one for each remote player currently in the session. See further documentation on `VoicePlayerState` [here](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html) . ### TopPrioritySpeaker : ChannelPriority[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#toppriorityspeaker-channelpriority "Permanent link") The highest [priority](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Channel-Priority.html) of all remote players currently speaking in the session. ### Tokens : IEnumerable[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#tokens-ienumerablestring "Permanent link") The set of [tokens](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html) which the local player possesses. ### MicrophoneCapture : IMicrophoneCapture[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#microphonecapture-imicrophonecapture "Permanent link") The microphone capture object which Dissonance is currently using. This may be null if Dissonance has not initialised yet or if the local instance is a dedicated server. * * * Properties[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#properties "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------ ### LocalPlayerName : String[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#localplayername-string "Permanent link") The name of the local player, this will be initialised to a unique ID per player when Dissonance starts. This may not be changed once Dissonance has started. ### PlayerPriority : ChannelPriority[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#playerpriority-channelpriority "Permanent link") The [priority](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Channel-Priority.html) of the local player, if a channel is opened with no priority set this priority will be used as a default. ### MicrophoneName : string[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#microphonename-string "Permanent link") Get or set the name of the microphone to use to capture voice. This may be changed at any time, if the microphone has already begun recording with a different name it will be reset to use the new name. ### PlaybackPrefab : VoicePlayback[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#playbackprefab-voiceplayback "Permanent link") Get or set the playback prefab which Dissonance will use to play back remote voices. This may not be changed once Dissonance has started. ### IsMuted : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#ismuted-bool "Permanent link") Get or set if the local player is muted (i.e. prevented from sending any voice transmissions). ### IsDeafened : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#isdeafened-bool "Permanent link") Get or set if the local player is deafened (i.e. prevented from hearing any remote voice transmissions). * * * Events[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#events "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------- ### OnPlayerJoinedSession : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#onplayerjoinedsession-event-actionvoiceplayerstate "Permanent link") This event runs whenever a new player joins the Dissonance voice chat session. It is passed the object which represents the new player. ### OnPlayerLeftSession : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#onplayerleftsession-event-actionvoiceplayerstate "Permanent link") This event runs whenever a player leaves the Dissonance voice chat session. It is passed the object which represents the player. The object will never be touched by Dissonance again - if the player rejoins a new object will be created for them. ### OnPlayerStartedSpeaking : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#onplayerstartedspeaking-event-actionvoiceplayerstate "Permanent link") This event runs whenever a remote player begins speaking in a channel which the local player can hear. ### OnPlayerStoppedSpeaking : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#onplayerstoppedspeaking-event-actionvoiceplayerstate "Permanent link") This event runs whenever a remote player stops speaking in all channels which the local player can hear. This may not indicate that the remote player has actually stopped talking completely, it is possible that the local player simply stopped listening. For example if you are listening to _Room A_ and they are talking to _Room A_ and _Room B_, then when you stop listening to _Room A_ you will receive this event (even though they are still talking to _Room B_) because they have stopped speaking _from your point of view_. ### OnPlayerEnteredRoom : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#onplayerenteredroom-event-actionvoiceplayerstate-string "Permanent link") This event runs whenever a remote player begins listening to a new room. It is passed the object which represents the player and the name of the room. ### OnPlayerExitedRoom : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#onplayerexitedroom-event-actionvoiceplayerstate-string "Permanent link") This event runs whenever a remote player stops listening to a room. It is passed the object which represents the player and the name of the room. ### LocalPlayerNameChanged : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#localplayernamechanged-event-actionstring "Permanent link") This event runs whenever the local player name is changed. Local player name may only be changed before the DissonanceComms component has been started. ### TokenAdded : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#tokenadded-event-actionstring "Permanent link") An event which runs whenever a token is added to the local player. ### TokenRemoved : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#tokenremoved-event-actionstring "Permanent link") An event which runs whenever a token is removed from the local player. * * * Methods[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------ ### FindPlayer(string name) : VoicePlayerState[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#findplayerstring-name-voiceplayerstate "Permanent link") Attempt to find the player with the given Dissonance ID. Will return null if no such player can be found. ### SubscribeToVoiceActivation(IVoiceActivationListener) [⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#subscribetovoiceactivationivoiceactivationlistener "Permanent link") Subscribes the given listener object to the voice activation detector (VAD) for the local player. When VAD detects speech the `VoiceActivationStart` method will be called. When the VAD stops detecting speech the `VoiceActivationStop` method will be called. ### UnsubscribeFromVoiceActivation(IVoiceActivationListener)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#unsubscribefromvoiceactivationivoiceactivationlistener "Permanent link") Unsubscribes a previously subscribed listener object from the VAD. ### SubscribeToRecordedAudio(IMicrophoneSubscriber) [⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#subscribetorecordedaudioimicrophonesubscriber "Permanent link") Subscribes the given listener object to the microphone recorded audio _after_ it has been preprocessed. This will receive all audio recorded by the mic whether or not it is being sent over the network. Use `DissonanceComms.RoomChannels.Count` and `DissonanceComms.PlayerChannels.Count` to determine if the audio is being sent anywhere. ### UnsubscribeFromRecordedAudio(IMicrophoneSubscriber)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#unsubscribefromrecordedaudioimicrophonesubscriber "Permanent link") Unsubscribes a previously subscribed listener object from the microphone audio stream. ### TrackPlayerPosition(IDissonancePlayer)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#trackplayerpositionidissonanceplayer "Permanent link") Begins [position tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) for the player represented by the given object. ### StopTracking(IDissonancePlayer)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#stoptrackingidissonanceplayer "Permanent link") Stops [position tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) for the player represented by the given object. ### AddToken(string)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#addtokenstring "Permanent link") Adds a [token](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html) to the local player. ### RemoveToken(string) : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#removetokenstring-bool "Permanent link") Removes a [token](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html) from the local player and returns a bool indicating if that token was removed. This will return false if the player never had the token in the first place. ### ContainsToken(string) : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#containstokenstring-bool "Permanent link") Returns a boolean value indicating if the local player has the [token](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html) with the given name. ### HasAnyToken(TokenSet) : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#hasanytokentokenset-bool "Permanent link") Returns a boolean value indicating if the local player has _any_ of the [tokens](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html) in the given TokenSet. ### ResetMicrophoneCapture[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#resetmicrophonecapture "Permanent link") Forces a complete restart of the audio capture pipeline. ### GetMicrophoneDevices(List output)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html#getmicrophonedeviceslist-output "Permanent link") Get a list of available microphones. Microphone names will be added to the `output` list. --- # Voice Broadcast Trigger - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#voice-broadcast-trigger) Voice Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#voice-broadcast-trigger "Permanent link") =========================================================================================================================================================================== The Voice Broadcast Trigger controls when and where the local voice data is sent to. ![Voice Broadcast Trigger Inspector](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_SectionsOverview.png "Voice Broadcast Trigger Inspector") Channel Type[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#channel-type "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------- This section controls which channel voice data will be sent to with this trigger. There are three channel type options, which one you choose will change the rest of the channel type UI to match. Channel type can be set from scripts by modifying the `ChannelType` property. ![Voice Broadcast Trigger - Channel Type](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Section_ChannelType.png) #### Channel Type : Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#channel-type-room "Permanent link") When using the "Room" channel type broadcaster sends voice to the specified room (a single room may have multiple speakers and multiple listeners). Available rooms are listed in a dropdown box and new rooms may be added by clicking the "Config Rooms" button. The target room name can be set from scripts by modifying the `RoomName` property. #### Channel Type : Player[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#channel-type-player "Permanent link") When set to "Player" the broadcaster sends voice directly to the specified player. The inspector will show a text box to enter the name of the player to send to. The target player name can be configured from a script by modifying the `PlayerId` field. To get the names of other players inspect the DissonanceComms component at runtime - when in a session it will show a list of all players in the session. To get the name of players by script enumerate the `DissonanceComms:Players` property. #### Channel Type : Self[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#channel-type-self "Permanent link") If you have set up [Position Tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) then your player object will have an `IDissonancePlayer` component which identifies it to Dissonance. You can take advantage of this to send directly to players without having to know their name. When set to "Self" the broadcast component will look for an `IDissonancePlayer` component in this GameObject or any ancestor and will send directly to that player. Channel Metadata[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#channel-metadata "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------- This section controls which metadata is sent along with the channel. ![Voice Broadcast Trigger - Channel Metadata](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Section_ChannelMetadata.png) #### Use Positional Data[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#use-positional-data "Permanent link") This determines whether the playback of the data sent through this broadcaster should use 3D audio playback (i.e. voice will sound as if it is coming from a certain position in space). Positional audio requires some additional setup (but does not use _any_ additional CPU or network bandwidth at all when enabled). See the [Position Tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) tutorial for information about how to set up your project for position tracking of player objects. This option can be set from a script by modifying the `BroadcastPosition` field. #### Priority[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#priority "Permanent link") This determines the priority which this voice has for playback. Everyone who receives audio will compare the priority of all the audio streams they are receiving and will only play out the streams with the highest priority. "None" is a special value which indicates that this broadcast trigger is setting no particular priority - the default priority for this player will be used instead. The default priority is set on the DissonanceComms component with the `PlayerPriority` property (if you do not set it it will have the priority `Default`). The priority values have this order: 1. Low 2. Default 3. Medium 4. High #### IsMuted : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#ismuted-bool "Permanent link") When set to `true` this trigger will never activate. This can be used to create a UI push-to-talk activated broadcast trigger - set the `Activation Mode` to `Voice Activation` and toggle the `IsMuted` property with a button. When muted by the UI no voice will be sent, when unmuted the trigger will automatically transmit when speech is detected. Activation Mode[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#activation-mode "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------- This section controls how the broadcast trigger decides when to send voice. There are three activation options, which one you choose will change the rest of the activation mode UI to match. Activation mode can be set from scripts by modifying the `Mode` property. ![Voice Broadcast Trigger - Activation Mode](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Section_ActivationMode.png) #### Activation Mode : None[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#activation-mode-none "Permanent link") When set to "None" the broadcaster will never broadcast any voice. #### ActivationMode : Voice Activation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#activationmode-voice-activation "Permanent link") When set to "Voice Activation" the broadcaster will automatically transmit when voice is detected in the microphone signal. #### ActivationMode : Push To Talk[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#activationmode-push-to-talk "Permanent link") When set to "Push To Talk" the broadcaster will transmit when a given input axis is chosen. You must set the name of a Unity input axis and then configure it in the Unity input manager. #### Activation Mode : Open[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#activation-mode-open "Permanent link") When set to "Open" the broadcaster will constantly transmit (unless muted). #### Collider Volume Activation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#collider-volume-activation "Permanent link") Using collider volume activation requires [Position Tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) to be set up. When active the broadcast trigger will find a sibling physics trigger volume and will only send voice if the local player (as defined by the `IDissonancePlayer` component) is inside the volume. Access Tokens[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#access-tokens "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------- This section controls which [Access Tokens](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html) are required to send with this broadcaster. ![Voice Broadcast Trigger - Access Tokens](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Section_AccessTokens.png) The DissonanceComms component keeps a set of tokens which the local player has. The broadcast trigger will only send voice if the player has one or more of the necessary tokens. Amplitude Faders[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#amplitude-faders "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------- This section controls the amplitude and soft fading of voice sent with this trigger. "PushToTalk Fade" (precise name depends upon which activation mode you have chosen) applies a soft fade in and out _every time_ speech is started or stopped (e.g. every time the push to talk key is pressed or released). This setting should be used with care; applying any fade in is inadvisable as it will cut off the start of what is being said. This fader can be configured from scripts by accessing the `ActivationFader` property. "Volume Trigger Fade" (only available when volume trigger is in use) applies a soft fade every time the player enters or exits the volume. This fader can be configured from scripts by accessing the `ColliderTriggerFader` property. Since there are two faders this means the trigger will have two different volumes to use, they will be multiplied together and the result is used as the actual volume value. ![Voice Broadcast Trigger - Amplitude Faders](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Section_AmplitudeFaders.png) #### Channel Volume[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#channel-volume "Permanent link") This controls the maximum volume of the fader (in decibels). #### Fade In Time[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#fade-in-time "Permanent link") This controls how long it takes this fader to increase volume from silence to the `Channel Volume` slider level at the start of speech. Warning Use with caution. This will cut off the start of speech and should rarely be used! #### Fade Out Time[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html#fade-out-time "Permanent link") This controls how long it takes this fader to decrease volume from `Channel Volume` slider level to silence at the end of speech. Warning Use with caution. Voice will continue to be transmitted even after the user has stopped pressing the push to talk key, which could be a privacy violation. In general you should use very small values (e.g. 0.2s). --- # Voice Proximity Broadcast Trigger - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#voice-proximity-broadcast-trigger) Voice Proximity Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#voice-proximity-broadcast-trigger "Permanent link") ========================================================================================================================================================================================================= The Voice Proximity Broadcast Trigger sends voice to an infinite grid of "virtual rooms", creating a proximity chat system by placing nearby players into the same rooms. ![Voice Proximity Broadcast Trigger Inspector](https://placeholder-software.co.uk/dissonance/docs/images/ProximityBroadcastTrigger_Inspector.png "Voice Proximity Broadcast Trigger Inspector") Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#room "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------- This section controls which room the trigger sends to. #### Chat Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#chat-room "Permanent link") It is possible to have several proximity broadcast systems running simultaneously (e.g. one per team), the room name uniquely identifies this room. #### Range[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#range "Permanent link") Set the distance to transmit voice, players within this distance will be considered "near" and will be placed into the same room. Hint The range must be exactly the same for the broadcast trigger and the receipt trigger! Channel Metadata[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#channel-metadata "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- #### Priority[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#priority "Permanent link") This determines the priority which this voice has for playback. Everyone who receives audio will compare the priority of all the audio streams they are receiving and will only play out the streams with the highest priority. "None" is a special value which indicates that this broadcast trigger is setting no particular priority - the default priority for this player will be used instead. The default priority is set on the DissonanceComms component with the `PlayerPriority` property (if you do not set it it will have the priority `Default`). The priority values have this order: 1. Low 2. Default 3. Medium 4. High Activation Mode[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#activation-mode "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------------- #### Mute[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#mute "Permanent link") When set to `true` this trigger will never activate. Hint This can be used to create a UI push-to-talk activated broadcast trigger - set the `Activation Mode` to `Voice Activation` and toggle the `IsMuted` property with a button. When muted by the UI no voice will be sent, when unmuted the trigger will automatically transmit when speech is detected. #### Activation Mode[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#activation-mode_1 "Permanent link") This controls how the broadcast trigger decides when to send voice. Activation mode can be set from scripts by modifying the `Mode` property. * `None`: Never broadcast any voice. * `Voice Activation`: Automatically broadcast when voice is detected. * `Push To Talk`: Broadcast when a given input axis is pressed. You must set the name of a Unity input axis and then configure it in the Unity input manager. * `Open`: Constantly broadcast unless muted. #### Collider Activation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#collider-activation "Permanent link") Only broadcast when the local player is inside a sibling collider volume. Access Tokens[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Broadcast-Trigger.html#access-tokens "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Add [Access Tokens](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html) which are required for this broadcaster to broadcast voice. This trigger will only broadcast if the DissonanceComms component has one or more of the necessary tokens. --- # Voice Proximity Receipt Trigger - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Receipt-Trigger.html#voice-proximity-receipt-trigger) Voice Proximity Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Receipt-Trigger.html#voice-proximity-receipt-trigger "Permanent link") =================================================================================================================================================================================================== The Voice Proximity Receipt Trigger receives voice to an infinite grid of "virtual rooms", creating a proximity chat system by placing nearby players into the same rooms. ![Voice Proximity Receipt Trigger Inspector](https://placeholder-software.co.uk/dissonance/docs/images/ProximityReceiptTrigger_Inspector.png "Voice Proximity Receipt Trigger Inspector") Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Receipt-Trigger.html#room "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------- This section controls which room the trigger receives from. #### Chat Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Receipt-Trigger.html#chat-room "Permanent link") It is possible to have several proximity broadcast systems running simultaneously (e.g. one per team), the room name uniquely identifies this room. #### Range[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Receipt-Trigger.html#range "Permanent link") Set the distance to receive voice, players within this distance will be considered "near" and will be placed into the same room. Hint The range must be exactly the same for the broadcast trigger and the receipt trigger! Access Tokens[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Receipt-Trigger.html#access-tokens "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------- Add [Access Tokens](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html) which are required for this broadcaster to broadcast voice. This trigger will only receive if the DissonanceComms component has one or more of the necessary tokens. #### Collider Activation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Proximity-Receipt-Trigger.html#collider-activation "Permanent link") Only receive when the local player is inside a sibling collider volume. --- # Voice Receipt Trigger - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Receipt-Trigger.html#voice-receipt-trigger) Voice Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Receipt-Trigger.html#voice-receipt-trigger "Permanent link") ===================================================================================================================================================================== The Voice Receipt Trigger controls which rooms are being listened to by the local player. ![Voice Receipt Trigger Inspector](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Overview.png "Voice Receipt Trigger Inspector") Trigger Activation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Receipt-Trigger.html#trigger-activation "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------- This determines whether the receiver will only receive when the local player is within a trigger zone. See the Unity documentation on [Trigger Zones](https://unity3d.com/learn/tutorials/topics/physics/colliders-triggers) . Using trigger activation requires the same basic setup as using [Positional Audio](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) . This setting can be configured from a script by modifying the `UseTrigger` field. Chat Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Receipt-Trigger.html#chat-room "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------- Determines which room this receiver is for. Available rooms are listed in a dropdown box and new rooms may be added by clicking the "Config Rooms" button. The target room name can be configured from a script by modifying the `RoomName` field. --- # IServerClientState - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#iserverclientstate) IServerClientState[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#iserverclientstate "Permanent link") ============================================================================================================================================================ Represents a single client in the server admin API. Properties[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#properties "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------- ### Name : String[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#name-string "Permanent link") The name of this client. This is the same as the `DissonanceComms.LocalPlayerName` property for this client. ### IsConnected : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#isconnected-bool "Permanent link") Indicates if this client is still connected to the voice session. ### Rooms: ReadOnlyCollection[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#rooms-readonlycollection "Permanent link") A collection of all the rooms this player is currently listening to. ### Channels : ReadOnlyCollection[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#channels-readonlycollection "Permanent link") A collection of all the channels this player is currently speaking through. ### LastChannelUpdateUtc : DateTime[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#lastchannelupdateutc-datetime "Permanent link") When the `Channels` collection was last updated ### PacketLoss : float[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#packetloss-float "Permanent link") Get the estimated packet loss factor for this client (0 to 1). Events[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#events "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------ ### OnStartedListeningToRoom : Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#onstartedlisteningtoroom-action "Permanent link") Event fires when player starts listening to a room channel. ### OnStoppedListeningToRoom : Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#onstoppedlisteningtoroom-action "Permanent link") Event fires when player stops listening to a room channel. ### StartedSpeaking : Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#startedspeaking-action "Permanent link") StartedSpeaking event requires `EnableChannelMonitoring = true` Event fires when player starts speaking to any channel. ### StoppedSpeaking : Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#stoppedspeaking-action "Permanent link") StoppedSpeaking event requires `EnableChannelMonitoring = true` Event fires when player stops speaking to all channels. ### OnVoicePacket : VoicePacket[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#onvoicepacket-voicepacket "Permanent link") OnVoicePacket event requires `EnableChannelMonitoring = true` Event fires for every voice packet from this player. Methods[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#methods "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------- ### RemoveFromRoom(string roomName)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#removefromroomstring-roomname "Permanent link") Immediately remove this player from a room, preventing them from listening to it. This does **not** prevent the client from immediately re-joining the room. ### Reset()[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#reset "Permanent link") Remove this client from the voice session, forcing them to immediately reconnect. IServerClientState[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#iserverclientstate_1 "Permanent link") ============================================================================================================================================================== Dissonance network integrations must specify a `TPeer` type, which represents a network connection from the server to a specific client. The exact type depends on the network integration you are using. An `IServerClientState` object can be cast to an `IServerClientState` object to access additional properties. Properties[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#properties_1 "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------- ### Peer : ClientInfo[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html#peer-clientinfo "Permanent link") Access the `ClientInfo` object for this client. This object exposes a `TPeer Connection { get; }` property. --- # Network Protocol - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#network-format) Network Format[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#network-format "Permanent link") ================================================================================================================================================== Network Protocol Knowledge of the network format is not necessary to work with Dissonance in most cases. This documentation is only required if you want to interact with Dissonance over the network from your own non-Unity code. For example writing a Dissonance server in another language. The Dissonance network system manages three main bits of data: * Who is in the session * Who is listening to which rooms * Voice packets This document will give you an overview of how the Dissonance network system manages this data. To see the exact packet format look at `PacketWriter.cs` and `PacketReader.cs` in the Dissonance package, these structs have a method for writing/reading each different packet type. Glossary[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#glossary "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------- #### Peer[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#peer "Permanent link") Every different machine in the session is a peer. This include both the server and the client. #### Client[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#client "Permanent link") A peer which is recording and playing voice. #### Server[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#server "Permanent link") A which manages the organisation of the session and relays voice to clients. #### Host[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#host "Permanent link") A peer which is both a server and a client. #### Dedicated Server[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#dedicated-server "Permanent link") A server which is not a client (i.e. no auto recording or playback). #### Reliable[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#reliable "Permanent link") Some packets are sent _reliably_. This means that the packets **will** arrive at their destination in the order they were sent, there are no lost packets. This is used for all non-voice packets. #### Unreliable[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#unreliable "Permanent link") Some packets are sent _unreliably_. This means that the packets may be lost in transport or arrive in a different order. This is always used for voice packets. #### Frame[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#frame "Permanent link") Audio is recorded, processed and played back in _frames_, this is a buffer of 10-40ms of audio. Every frame is packed into a single network packet. #### Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#room "Permanent link") A room is a type of channel which requires the listener to explicitly subscribe to the room to hear any audio sent to that room. Rooms have a name (a string) but on the network rooms are generally referred to by a 16 bit ID which is calculated by the `ToRoomId(string name)` method. Packet Header[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#packet-header "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ All packets contain a header which is used to check that the packet is valid. The first 16 bits of every Dissonance packet are a 16 bit _magic number_ `0x8BC7`. This is read from the start of the packet and if it's incorrect the packet is immediately discarded. If something goes wrong and non-Dissonance packets are sent to Dissonance this prevents them from being decoded. The next 8 bits are the packet type, this tells Dissonance how the contents of the packet should be decoded. The values used for this are defined in `MessageTypes.cs`. After that all packets (except `HandshakeRequest`) have a 32 bit session number, this is a unique number randomly generated by the server when it starts a new session. If the session number does not match the packet is immediately discarded. If something goes wrong and packets from one Dissonance session are sent to another Dissonance session this prevents them from being decoded. Kicking From A Session[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#kicking-from-a-session "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ If a packet with an incorrect session number is received by the server it will send back an `ErrorWrongSession` packet to the client which contains the session number being used by the server. If the client is not using this session number it will disconnect and reconnect to the server. Joining A Session[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#joining-a-session "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------- 1. A new client sends a `HandshakeRequest` message to the server. This tells the server the codec settings in use by this client as well as it's name. 2. The server replies with a `HandshakeResponse` message. This sends the complete state of the server to the client: 3. the session ID. A unique value prepended to all packets. 4. The client ID. A unique 16 bit ID for this client. 5. Client list. A list of all other clients in the session (name, codec setting, unique ID). 6. Room list. A list of the room names which at least one client is currently listening to. 7. Listeners list. A list of clients and the rooms which they are currently listening to. 8. The client replies with a `ClientState` message. This tells the server the complete state of the client: 9. Name 10. Client ID 11. Codec Settings 12. Rooms list. A list of the rooms this client is currently listening to. Info The `HandshakeResponse` message contains data about _all_ clients currently in the session. In a very large session this can cause a problem with oversize packets. It is valid for the server to send some/none of the client data in the initial `HandshakeResponse` packet and instead to send it in individual `ClientState` messages immediately after the `HandshakeResponse` Joining Or Leaving A Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#joining-or-leaving-a-room "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ The server maintains a list of which rooms every client is currently listening to. Sending a complete `ClientState` message every time a client join or leaves a room would be wasteful, instead a `DeltaClientState` message is sent. This contains: * Flag indicating `joining` or `leaving` * Client ID * Room name Replicating Data[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#replicating-data "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------ The update messages `ClientState` and `DeltaClientState` are sent from clients to the server, which updates it's internal state. The server also broadcasts these messages out to all clients which update their own state. This means that every client has exactly the same list of who is listening to which rooms. Peer To Peer[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#peer-to-peer "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------- It's possible for peers to communicate directly. When this is setup the metadata messages are still sent to the server but voice packets are sent directly from one client to another. To set this up a client sends a `HandshakeP2P` message to every peer which it knows how to directly contact. The `HandshakeP2P` message contains the ID of the sending client. When a client receives a `HandshakeP2P` message from another client it can take note of the connection which that message came through, send back a `HandshakeP2P` message in response over that connection, and now the two peers can communicate directly. Voice Packets[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#voice-packets "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ Each client records audio, preprocesses it to improve audio quality, encodes it (using opus) and then sends the packet. The client decides who to send the packet to based on it's knowledge of who is listening to what. The client sends the voice packet via P2P to as many client as possible. The remaining packets are relayed via the server. The `VoiceData` packet contains: * Sender Client ID * 8 bit bitfield of packet flags * Sequence number. A number which can be used to put packets into the correct order * A list of channels which this voice is addressed to. For each channel: * 16 bit channel bitfield * 16 Bit channel ID * A frame of encoded audio #### Bitfield[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#bitfield "Permanent link") The 8 bit bitfield contains: - The MSB is always set to `1` - The remaining 7 bits contain a wrapping counter which increments every time the "channel session" changes. The "channel session" changes whenever all sending channels are closed (i.e. there is an interruption in the voice stream). Relayed Packets[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#relayed-packets "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------- When packets cannot be sent directly with P2P they can be relayed via the server. The `ServerRelayReliable` and `ServerRelayUnreliable` packets are used for this purpose. These packets contain a list of destination client IDs and then an array of bytes. When the server receives one of these packets it sends the array of bytes out to all of the listed clients. The server will discard attempts to relay `HandshakeP2P` packets. Text Packets[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#text-packets "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------- Text packets can be sent through the Dissonance session, unlike voice they are always relayed via the server. The `TextData` packet contains: * Recipient type. This indicates if the packet is targeted at a player or a room. * Sender ID. Client ID of the sender. * Recipient ID. This is either a room ID or a client ID, depending upon the recipient type. * A string of UTF8 encoded text. Leaving A Session[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/Network-Protocol.html#leaving-a-session "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------- When a client leaves the session the server sends a `RemoveClient` message out to all clients. This simply contains the ID of the client which is leaving the session. --- # PlayerChannel - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html#playerchannel) PlayerChannel[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html#playerchannel "Permanent link") ======================================================================================================================================== This object represents a single speech channel directly to another player opened with the [PlayerChannels](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannels.html) API. The other player will receive the local voice without having to take any action. ### Dispose()[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html#dispose "Permanent link") Closes this channel. ### SubscriptionId : ushort[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html#subscriptionid-ushort "Permanent link") Get the unique ID of this channel. This is only unique among the set of open channels - once this channel is closed the ID may be re-used by another channel. ### TargetId : string[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html#targetid-string "Permanent link") Get the name of the player this channel is sending voice to. ### IsOpen : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html#isopen-bool "Permanent link") Get a value indicating if this channel is currently open. Once a channel is closed you should release the channel struct - it is useless (re-opening the channel will create a new PlayerChannel struct). Once IsOpen becomes false then accessing most other properties will immediately throw an exception. ### Positional : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html#positional-bool "Permanent link") Get or set whether audio sent through this channel should use positional playback. If there are multiple channels open sending the same voice then playback will only be positional if _all_ channels are set to use positional playback. ### Priority : ChannelPriority[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html#priority-channelpriority "Permanent link") Get or set the priority of voice sent with this channel. If priority is set to `None` then it will fall back to using the priority set on the local DissonanceComms component in the `PlayerPriority` property. If there are multiple channels open sending the same voice data then playback will use the highest priority. ### Volume : float[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html#volume-float "Permanent link") Get or set the volume to play back the voice sent through this channel. Volume is a direct multiplier on the audio data and should be between 0 and 1. If there are multiple channels open sending the same voice then playback will use the loudest volume. --- # PlayerChannels - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannels.html#playerchannels) PlayerChannels[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannels.html#playerchannels "Permanent link") =========================================================================================================================================== This object exposes properties and methods to do with players that the local player is _speaking_ to. ### Count : int[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannels.html#count-int "Permanent link") The number of players which the local player is a speaking to. ### Contains(PlayerChannel) : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannels.html#containsplayerchannel-bool "Permanent link") Returns a boolean value indicating if the local player is speaking to the given channel. ### Open(string, \[bool\], \[ChannelPriority\], \[float\]) : PlayerChannel[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannels.html#openstring-bool-channelpriority-float-playerchannel "Permanent link") Opens a channel to begin speaking to the given player and returns a [PlayerChannel](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannel.html) object which represents this open channel (and can be used to close it). Takes three optional parameters. 1. A boolean value indicating if this channel should use positional playback 2. A ChannelPriority which indicates the priority of this channel 3. A float which indicates the volume to play back this channel with ### Close(PlayerChannel) : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannels.html#closeplayerchannel-bool "Permanent link") Closes the given channel and returns a boolean indicating if the channel was open in the first place. --- # RemoteChannel - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RemoteChannel.html#remotechannel) RemoteChannel[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RemoteChannel.html#remotechannel "Permanent link") ======================================================================================================================================== A `RemoteChannel` struct represents a snapshot of information about a channel which a player is speaking through. Read Only Properties[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RemoteChannel.html#read-only-properties "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------ ### Type : ChannelType[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RemoteChannel.html#type-channeltype "Permanent link") Get the type of this channel. A channel is either to a Room (in which case the local player will only hear voices if they are subscribed to the Room) or to a player (in which case the appropriate player will hear the voice without needing to subscribe to it). ### Options : PlaybackOptions[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RemoteChannel.html#options-playbackoptions "Permanent link") Get the `PlaybackOptions` which have been set for this channel. The actual playback options used are an aggregation of the options set on all the channels the local player is receiving voice from the given player through. #### Options.IsPositional : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RemoteChannel.html#optionsispositional-bool "Permanent link") Get whether this channel should be played with positional audio. Actual audio playback will be positional only if _all_ channels from the given player are set to positional playback. #### Options.AmplitudeMultiplier : float[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RemoteChannel.html#optionsamplitudemultiplier-float "Permanent link") Get the amplitude multiplier to apply to audio through this channel. The _maximum_ multiplier from all channels from the given player will be used. #### Options.Priority : ChannelPriority[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RemoteChannel.html#optionspriority-channelpriority "Permanent link") Get the priority of audio through this channel. The _maximum_ priority from all channels from the given player will be used. ### TargetName : string[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RemoteChannel.html#targetname-string "Permanent link") Get the name of the target of this channel. This is either a room name or a player name, depending upon the `Type` property. --- # RoomChannel - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html#roomchannel) RoomChannel[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html#roomchannel "Permanent link") ================================================================================================================================== This object represents a single speech channel to a room opened with the [PlayerChannels](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/PlayerChannels.html) API. Other players will only receive the voice if they have joined the room. ### Dispose()[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html#dispose "Permanent link") Closes this channel. ### SubscriptionId : ushort[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html#subscriptionid-ushort "Permanent link") Get the unique ID of this channel. This is only unique among the set of open channels - once this channel is closed the ID may be re-used by another channel. ### TargetId : string[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html#targetid-string "Permanent link") Get the name of the room this channel is sending voice to. ### IsOpen : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html#isopen-bool "Permanent link") Get a value indicating if this channel is currently open. Once a channel is closed you should release the channel struct - it is useless (re-opening the channel will create a new PlayerChannel struct). Once IsOpen becomes false then accessing most other properties will immediately throw an exception. ### Positional : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html#positional-bool "Permanent link") Get or set whether audio sent through this channel should use positional playback. If there are multiple channels open sending the same voice then playback will only be positional if _all_ channels are set to use positional playback. ### Priority : ChannelPriority[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html#priority-channelpriority "Permanent link") Get or set the priority of voice sent with this channel. If priority is set to `None` then it will fall back to using the priority set on the local DissonanceComms component in the `PlayerPriority` property. If there are multiple channels open sending the same voice data then playback will use the highest priority. ### Volume : float[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html#volume-float "Permanent link") Get or set the volume to play back the voice sent through this channel. Volume is a direct multiplier on the audio data and should be between 0 and 1. If there are multiple channels open sending the same voice then playback will use the loudest volume. --- # RoomChannels - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannels.html#roomchannels) RoomChannels[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannels.html#roomchannels "Permanent link") ===================================================================================================================================== This object exposes properties and method to do with rooms that the local player is _speaking_ to. For rooms the player is listening to see [this documentation](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/Rooms.html) intead. ### Count : int[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannels.html#count-int "Permanent link") The number of rooms which the local player is a speaking to. ### Contains(RoomChannel) : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannels.html#containsroomchannel-bool "Permanent link") Returns a boolean value indicating if the local player is speaking to the given channel. ### Open(string, \[bool\], \[ChannelPriority\], \[float\]) : RoomChannel[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannels.html#openstring-bool-channelpriority-float-roomchannel "Permanent link") Opens a channel to begin speaking to the given room and returns a [RoomChannel](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannel.html) which represents this open channel (and can be used to close it). Takes three optional parameters. 1. A boolean value indicating if this channel should use positional playback 2. A ChannelPriority which indicates the priority of this channel 3. A float which indicates the volume to play back this channel with ### Close(RoomChannel) : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannels.html#closeroomchannel-bool "Permanent link") Closes the given channel and returns a boolean indicating if the channel was open in the first place. --- # Rooms - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/Rooms.html#rooms) Rooms[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/Rooms.html#rooms "Permanent link") ================================================================================================================ This object exposes properties and method to do with rooms that the local player is _listening_ to. For rooms the player is speaking to see [this documentation](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/RoomChannels.html) intead. ### Count : int[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/Rooms.html#count-int "Permanent link") The number of rooms which the local player is a listening to. ### Contains(string) : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/Rooms.html#containsstring-bool "Permanent link") Returns a boolean value indicating if the local player is listening to a room with the given name. ### Join(string) : RoomMembership[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/Rooms.html#joinstring-roommembership "Permanent link") Begin listening to the room with the given name. Returns a "RoomMembership" object which can be used to stop listening to the room. ### Leave(RoomMembership) : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/Rooms.html#leaveroommembership-bool "Permanent link") Stop listening to the room represented by the given RoomMembership. --- # TextChat - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/TextChat.html#textchat) TextChat[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/TextChat.html#textchat "Permanent link") ========================================================================================================================= This object exposes properties and method to do with text chat within a Dissonance session. ### Send(string, string)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/TextChat.html#sendstring-string "Permanent link") Send a message to the given room. ### Whisper(string, string)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/TextChat.html#whisperstring-string "Permanent link") Send a message to the given player. ### MessageReceived : event Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/TextChat.html#messagereceived-event-action "Permanent link") An event which indicates a text message was received from another player. The `TextMessage` object contains information about who send the message, how they sent it and what the message is. --- # VoicePlayerState - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#voiceplayerstate) VoicePlayerState[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#voiceplayerstate "Permanent link") ================================================================================================================================================= This object exposes properties to do with other players in a Dissonance session. There is one of these objects per player (including the local player) in the `Players` property on the DissonanceComms component. You can also get one of these objects for a specific player with the `FindPlayer` method on the DissonanceComms component. `//Get your comms component DissonanceComms comms; //Get a specific player VoicePlayerState player = comms.FindPlayer("Player ID"); //Enumerate all players in the session for (var i = 0; i < comms.Players.Count; i++) { VoicePlayerState player = comms.Players[i]; }` Events[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#events "Permanent link") ----------------------------------------------------------------------------------------------------------------------------- ### OnStartedSpeaking : Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#onstartedspeaking-actionvoiceplayerstate "Permanent link") This event is raised every time this player starts speaking. It is passed the state object for this player. `VoicePlayerState.OnStartedSpeaking += player => { Debug.Log("Player " + player.Name + " Started Speaking"); }` ### OnStoppedSpeaking : Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#onstoppedspeaking-actionvoiceplayerstate "Permanent link") This event is raised every time this player stops speaking. It is passed the state object for this player. `VoicePlayerState.OnStoppedSpeaking += player => { Debug.Log("Player " + player.Name + " Stopped Speaking"); }` ### OnEnteredRoom : Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#onenteredroom-actionvoiceplayerstate-string "Permanent link") This event is raised every time this player begins listening to a new room. It is passed the state object for this player and the name of the room. `VoicePlayerState.OnEnteredRoom += (player, room) => { Debug.Log("Player " + player.Name + " began listening to room " + room); }` ### OnExitedRoom : Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#onexitedroom-actionvoiceplayerstate-string "Permanent link") This event is raised every time this player stops listening to a room. It is passed the state object for this player and the name of the room. `VoicePlayerState.OnExitedRoom += (player, room) => { Debug.Log("Player " + player.Name + " stopped listening to room " + room); }` ### OnLeftSession : Action[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#onleftsession-actionvoiceplayerstate "Permanent link") This event is raised when the player leaves the session. After this the session object will never be used again. Even if the same player re-joins with the same name, they will be assigned a new state object. `VoicePlayerState.OnLeftSession += player => { Debug.Log("Player " + player.Name + " Left Session"); }` Read Only Properties[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#read-only-properties "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------- ### Name : String[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#name-string "Permanent link") The name of this player. This is the value in the `DissonanceComms:LocalPlayerName` property for that player. `DissonanceComms comms; VoicePlayerState aPlayer; if (aPlayer.Name == comms.LocalPlayerName) { Debug.Log(aPlayer.Name + " is the local player"); }` ### IsConnected : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#isconnected-bool "Permanent link") Get a value indicating if this player is currently in the session. ### IsSpeaking : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#isspeaking-bool "Permanent link") Get a value indicating if this player is currently speaking ### Amplitude : float[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#amplitude-float "Permanent link") Get the current amplitude of the speech from this player. Value is in the range of 0 to 1. When using this value remember that 1 is the loudest value that can possibly be produced by the audio system - in most circumstances a speech signal will be _very_ quiet (0 to 0.05 or less). ### SpeakerPriority : ChannelPriority?[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#speakerpriority-channelpriority "Permanent link") Get the current priority of speech from this speaker. Null if the player is not speaking. ### Rooms : ReadOnlyCollection[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#rooms-readonlycollectionstring "Permanent link") Get the list of rooms this player is currently listening to. ### PacketLoss : float?[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#packetloss-float "Permanent link") Get the estimated packet loss (0 to 1) to/from this player. May be null if the player has disconnected or packet loss has not yet been measured. ### Playback : VoicePlayback[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#playback-voiceplayback "Permanent link") Get the `VoicePlayback` component associated with this player. May be null if Dissonance is still setting up playback for this player, or the player has left the session. ### Tracker : IDissonancePlayer[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#tracker-idissonanceplayer "Permanent link") Get the `IDissonancePlayer` component associated with this player. May be null if Dissonance is still setting up tracking for this player, this player does not have a `IDissonancePlayer` component, or the player has left the session. Properties[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#properties "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------- ### Volume : float[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#volume-float "Permanent link") Get or set the Volume which speech from the player should be played at. The value is a direct multiplier applied to the audio and should be in the range 0 to 1. ### IsLocallyMuted : bool[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#islocallymuted-bool "Permanent link") Get or set if this player is locally muted and will not produce any audio on the local machine. Methods[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#methods "Permanent link") ------------------------------------------------------------------------------------------------------------------------------- ### GetSpeakingChannels(channels: List)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html#getspeakingchannelschannels-listremotechannel "Permanent link") Get a snapshot of the channels you are hearing this speaker through. If they are not speaking to you then this will return no results. The `channels` parameter passed in must not be null, the list will be cleared and then filled with the current snapshot. --- # Voice Settings - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#persistence) Voice Settings ============== Various Dissonance audio settings can be tweaked through the VoiceSettings asset. This asset can be quickly accessed through `Window > Dissonance > Quality Settings`. Warning The default settings are usually the best option. Don't change these options without understanding exactly what the trade-off is. Persistence[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#persistence "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------ All of these settings can be accessed at runtime from a script through `Dissonance.Config.VoiceSettings.Instance`. Any settings which are changed by script are automatically saved into `PlayerPrefs` and override the default settings (stored in the asset). This means you can configure these settings in your menus and they will persist when your application is closed and re-opened. ![Voice Settings](https://placeholder-software.co.uk/dissonance/docs/images/VoiceSettings2.webp) Frame Size[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#frame-size "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------- Controls how much audio is packed into a single network packet. Smaller frames reduce recording latency but send more packets over the network per second, which consumes more network data and slightly more CPU power. Warning The smallest option (`Tiny`) is not suitable for use over the internet or over a wireless network. This option should only be used in very special cases where all clients will be connected to the same wired local area network. The exact frame size at each setting is: * Tiny: 10ms (100 packets/s) * Small: 20ms (50 packets/s) * Medium: 40ms (25 packets/s) * Large: 60ms (16.6 packets/second) Audio Quality[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#audio-quality "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------- Controls how many bits-per-second (on average) the audio codec will use to encode audio. Higher bitrates sound better but use more network data and slightly more CPU power. The data rate used by each quality setting is: * Low: 1.25 KB/s * Medium: 2.125 KB/s * High: 3 KB/s Forward Error Correction[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#forward-error-correction "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------- Controls if the codec is using `Forward Error Correction` which improves audio quality when packets are lost. When network conditions are good this makes no difference to network data used. When network conditions are bad this slightly increases the total data used (by about 10%) and massively improves audio quality (it can almost completely mask ~5% packet loss). Warning It is very highly recommended to keep FEC enabled. It is a huge quality increase for a very small increase in network data usage. Noise Suppression[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#noise-suppression "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ Controls how much the audio pre-processor removes noise from the signal. Higher values will remove more noise but may also make speech quieter. Info Sounds such as people talking in the background are not noise and will not be removed by the noise suppressor. This system removes non-voice sounds such as fans hum, keyboard clatter, or fuzz from a poor quality microphone. Background Sound Removal[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#background-sound-removal "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------- Enables [RNNoise](https://jmvalin.ca/demo/rnnoise/) , an ML based background sound removal system. When there is a lot of background sound (e.g. people talking, dogs barking, keyboard clatter, fan noise, loud breathing) this system will remove it, but will distort speech much more than the basic `Noise Suppression` system. Dissonance can run both noise removal systems at once, which reduces the amount of distortion present even in very noisy environments. The intensity slider limits the amount of background sound that can be removed and _also_ limits the maximum amount of distortion even in the worst case. Set it higher to cancel more noise. It is recommended to enable this system if you are building an application where there is likely to be a lot of environmental noise (e.g. a mobile app, where the user is expected to be on-the-move while talking) or an intense VR game (where the user may be breathing heavily while talking). Voice Detector Sensitivity[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#voice-detector-sensitivity "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ The voice detector detects speech and activates [Voice Broadcast Trigger](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html) components configured with `Activation Mode: Voice Activation`. This settings controls a _tradeoff_ between accuracy (not activating when no one is speaking) and sensitivity (always activating when someone is speaking). A low sensitivity voice detector will not activate when there is non-speech audio (e.g. keyboard clatter), but it sometimes may not activate when there is speech (e.g. quiet speech). A high sensitivity voice detector will activate when there is speech, but it may also activate when there is non-speech audio. Echo Cancellation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#echo-cancellation "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ Info Acoustic Echo Cancellation requires some extra setup before it can be used. See [this tutorial](https://placeholder-software.co.uk/dissonance/Tutorials/Acoustic-Echo-Cancellation.html) . Controls how much echo (feedback) the acoustic cancellation system attempts to remove from recorded audio. Higher values will remove more echo but may also severely distort recorded speech. Dissonance includes two completely different AEC algorithms which are used on Mobile and Desktop platforms. For Mobile Echo Cancellation the configuration value should approximately match the setup of the platform it is used on. Audio Duck Attenuation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#audio-duck-attenuation "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------- Controls how much received Dissonance audio will be attenuated by when any VoiceBroadcastTrigger is activated (i.e. speech is being transmitted). This can help prevent feedback of recorded audio into the microphone. The AEC system is not perfect - even if you have AEC setup and working it is still worth using audio ducking. The default value configured in Dissonance is a _very_ mild (almost imperceptible) level of audio ducking. Much smaller values can reasonably be used, particularly on mobile platforms or VR headsets where feedback (due to speakers and microphones in close proximity) is a much more common problem. --- # Access Tokens - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html#defining-required-tokens) Access Tokens ============= Video See [this video](https://youtu.be/HXMYDbuLwVI?t=250) about access tokens. Access control tokens can be added to both [Broadcast Triggers](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html) and [Receipt Triggers](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Receipt-Trigger.html) . The trigger will not function unless the local player has _one of_ the required tokens. Defining Required Tokens[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html#defining-required-tokens "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Tokens can be added and removed through the inspector: ![Receipt Trigger](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_Tokens.png) This receipt trigger will not function unless the local player has one of the two access tokens - 'TopSecretPassword' or 'mysocratesnote'. Tokens can also be managed with scripts: `var receiver = FindObjectOfType(); receiver.AddToken("correcthorsebatterystaple"); // Add if (receiver.ContainsToken("correcthorsebatterystaple")) // Query receiver.RemoveToken("correcthorsebatterystaple"); // Remove` Defining Available Tokens[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Access-Control-Tokens.html#defining-available-tokens "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Once triggers have been configured to require tokens you will need to add some tokens to the local player. This can be done in the inspector in the same way as for triggers. Tokens added in the inspector will apply to _all_ players so they can only be used as the default tokens everyone starts with. ![Receipt Trigger](https://placeholder-software.co.uk/dissonance/docs/images/DissonanceComms_Tokens.png) You are more likely to want to manage tokens through scripts. When you create a player and do something which requires restricting their access to channels (e.g. joining a team) you should add the appropriate tokens to the local player: `var local = FindObjectOfType(); local.AddToken("Green Team");` Assuming you have transmitters and receivers set up for every team, each one with a different token, this gives you a simple way to ensure that the player is speaking and listening to the right team channels. --- # Audio Mixing For Voice - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Audio-Mixing.html#general-principles) Audio Mixing For Voice ====================== Video See [this video](https://youtu.be/HXMYDbuLwVI?t=1516) about audio mixing. Dissonance does not have any special support built in for audio mixing, because unity already has a powerful mixing system built in which dissonance audio is routed through. You can find out more about the unity audio mixing system [here](http://blogs.unity3d.com/2014/07/24/mixing-sweet-beats-in-unity-5-0/) . This tutorial offers advice about the best way to use the unity audio pipeline for VoIP. ### General Principles[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Audio-Mixing.html#general-principles "Permanent link") It can be tempting to mix voice signals in the same way as any other audio signal in your game and to add various sound effects to the voice for realism/immersion. Things such as drowning out teammates with loud gunfire, deafening players when they're hit by a flashbang or adding extreme radio fuzz when the enemy team use jammers might all sound immersive but in reality will just force people not to use the in game VoIP. Generally any audio mixing done to the voice signal should be done to improve the voice quality. Volume Ducking[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Audio-Mixing.html#volume-ducking "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------- Games frequently have very loud sound effects such as explosions and gunfire which can drown out other sounds in the game. However, it would interrupt conversations if these noises also drowned out the voice signal. A naïve solution would be to increase the volume of the voice signal far above the game sounds but doing this would cause clipping and sound terrible. An alternative solution would be to reduce the volume of the game audio far below the voice signal, but doing this would cause the game sounds to lack impact even when no one is talking. The best solution is to play game sounds at full volume when no one is talking but then when someone starts talking simply "duck" the volume so the voice can be clearly heard over the game sounds. ![Example of audio mixer with ducking](https://placeholder-software.co.uk/dissonance/docs/images/AudioMixing_Ducking.png "Example of audio mixer with ducking") Above is an example audio mixer for a game. Highlighted in red are all the groups of non voice data, highlighted in blue is a groups of NPC voice audio and highlighted in green is a groups of human voice data. If you do not have any groups like this then all you need to add is a single groups of "non-voice" and make sure all the game sounds play to this group. To make dissonance play to the "Human Voice" group you need to modify your playback prefab, simply drag the "Human Voice" group into the AudioSource of the prefab and all voice will play to that group. The yellow arrows indicate "sends", a send sends audio from one signal processor to another. At the receiving end of the sends is a "Duck Volume" effect, this reduces the volume of the group relative to the volume of the signal it receives via a send. The setup shown above has _two_ volume ducks and _three_ sends. The human voice sends to "Non-Voice" and "NPC Voice", this means than when a human speaks both NPC voices and other sounds get quieter. The "NPC Voice" has a single send to the "Non-Voice" group, this means that when an NPC speaks other sounds get quieter. Sound Effects[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Audio-Mixing.html#sound-effects "Permanent link") --------------------------------------------------------------------------------------------------------------------------------- As mentioned above you should be very cautious about applying any sound effects to the voice signal which are not for the purpose of enhancing the voice quality. However there are some situations where applying sound effects to voices could sound good, for example keeping allied communications clean, but adding a subtle radio distortion effect to enemy communications. Applying an effect is very simple, simply click add on the audio group and select the effect you want. ![Example of audio mixer with distortion](https://placeholder-software.co.uk/dissonance/docs/images/AudioMixing_Distortion.png "Example of audio mixer with distortion") Above is an example of an audio group with a [distortion](https://docs.unity3d.com/Manual/class-AudioDistortionEffect.html) effect applied. --- # Channel Volume - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Channel-Volume.html#broadcast-trigger-component) Channel Volume ============== The playback volume can be set by the speaker per broadcast channel. This can be used to individually reduce the volume of a speaker. For example fading off voice over a small period of time when someone stops speaking. Broadcast Trigger Component[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Channel-Volume.html#broadcast-trigger-component "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------------- The broadcaster trigger component exposes 2 amplitude settings in the inspector; activation fade and trigger fade. ![Amplitude Fader Controls](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger-AmplitudeFaders.png) `Activation Fade` applies a fade in/out _every time_ speech is started or stopped. For example every time push-to-talk is pressed/released. This setting should be used with care; applying _any_ fade-in is inadvisable as it will almost certainly cause the start of what is being said to be cut off. `Volume Trigger Fade` applies only to broadcast triggers which are using physics based volume triggers. This fade will be applied every time the player enters or exits the trigger area. Both faders have the same three controls: The `Channel Volume` slider controls the amplitude which will be reached after the fade in time has passed. This is a direct multiplier applied to the audio, values between 0 to 1 will reduce playback amplitude, values between 1 to 2 will increase playback amplitude. If both faders are in use the values will be _multiplied_ together. The `Fade In Time` slider controls how long it takes the playback amplitude to increase from zero (silent) to the `Channel Volume` slider value. The `Fade Out Time` slider controls how long it takes the playback amplitude to decrease from the `Channel Volume` slider value to zero (silent). Script Controlled Volume[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Channel-Volume.html#script-controlled-volume "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------------- If you are [controlling channels directly](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Script-Controlled-Speech.html) from your own scripts you can control volume on the channel object. `var comms = GetComponent(); //Create a channel with explicit amplitude var channel = comms.RoomsChannels.Open("Room Name", amplitudeMultiplier: 0.5f); //At any time while the channel is open change the amplitude channel.AmplitudeMultiplier = 1.0f; //Close the channel channel.Dispose();` --- # Magic Leap - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Platforms/Magic%20Leap.html#magic-leap) Magic Leap[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/Magic%20Leap.html#magic-leap "Permanent link") =========================================================================================================================== Dissonance includes support for LuminOS on Magic leap devices. To enable this you must change the import settings of `Assets\Plugins\Dissonance\Plugins\Magic Leap\libAudioPluginDissonance.so` and `Assets\Plugins\Dissonance\Plugins\Android\libs\ARM64\libopus.so` to be included in Magic Leap builds. _Acoustic Echo Cancellation_ (AEC) and _Noise Suppression_ (NS) are built into the magic leap device. To prevent interference the Dissonance AEC and NS systems are disabled when deployed to a Magic Leap headset, any configuration settings in Dissonance for these two systems will be ignored. --- # Oculus OVR - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Platforms/Oculus%20OVR.html#oculus-ovr) Oculus OVR[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/Oculus%20OVR.html#oculus-ovr "Permanent link") =========================================================================================================================== If you are using the [Oculus OVR SDK](https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022) you must disable the `Ovr Avatar` component from taking exclusive control of the microphone (which prevents Dissonance from using it). ![OVR Local Avatar](https://placeholder-software.co.uk/dissonance/docs/images/OVR%20Local%20Avatar.png "OVR Local Avatar") 1. Locate the `LocalAvatar` GameObject 2. Unchecked `Can Own Microphone` in the inspector for the `Ovr Avatar` component --- # Channel Priority - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Channel-Priority.html#priority-levels) Channel Priority ================ Channel priority can be used to automatically mute low priority channels while high priority channels are speaking. For example muting the global voice chat room whilst someone in the team chat room is talking. Priority Levels[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Channel-Priority.html#priority-levels "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------- There are 4 priority levels which can be set on a channel: `1. Low 2. Default 3. Medium 4. High` If a player is receiving voice from multiple sources then the sources with the highest priority will play and all others will be muted. There is another priority option: `None`. If this used then the priority falls back to the default value for this player, which is set in `DissonanceComms.PlayerPriority`. If `None` is specified as the default player priority then `Default` is used instead. Defining Priority[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Channel-Priority.html#defining-priority "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------- The priority of a channel can be defined in a number of ways. The inspector for the Voice Broadcast Trigger allows you to set the priority for voice sent with this trigger: ![Receipt Trigger](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Priority.png) In scripts you can change the priority for a VoiceBroadcastTrigger with the `Priority` property: `var trigger = GetComponent(); trigger.Priority = ChannelPriority.High;` Alternatively if you are [directly using channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Directly-Using-Channels.html) from scripts instead of using the trigger components you can set the priority when the channel is created, and then modify it from the channel object at any time: `var comms = GetComponent(); //Create the channel with an explicit priority var channel = comms.RoomChannels.Open("Room Name", priority: ChannelPriority.High); //Change the priority channel.Priority = ChannelPriority.Medium; //Close the channel channel.Dispose();` --- # Writing A Custom Microphone Capture System - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Microphone-Capture.html#step-1-basic-setup) Writing A Custom Microphone Capture System ========================================== By default Dissonance uses the `BasicMicrophoneCapture` behaviour to record audio from a microphone using the Unity [Microphone API](https://docs.unity3d.com/ScriptReference/Microphone.html) and feed it into Dissonance. However this script is not ideal for all use cases. You can replace the microphone capture system in Dissonance by creating a new behaviour which implements `IMicrophoneCapture` and adding the script to the same gameObject as the `DissonanceComms` behaviour. This tutorial will explain how to build a replacement capture system which streams audio from a file. before following the tutorial make sure you've read the [reference docs](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneCapture.html) so you understand what the `IMicrophoneCapture` interface means. Step 1 : Basic Setup[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Microphone-Capture.html#step-1-basic-setup "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------- First you need to create a new script with the IMicrophoneCapture interface on it and drop it onto the same GameObject as the DissonanceComms component. [Here is an example script](https://gist.github.com/martindevans/266553f7405c393e5a41d4729b67fa1e) . If you run the scene with this you should see a single exception printed to the console coming from the `StartCapture` method. Step 2 : Start And Stop[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Microphone-Capture.html#step-2-start-and-stop "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you need to properly start and stop the script without throwing exceptions. `StartCapture` should return the format of the audio you will be providing. This **must** be mono (i.e. 1 channel) and any sample rate is acceptable (just use whatever is most convenient for you). If your capture system is not ready you can return null to prevent start-up. If you return a non-null value you **must** set `IsRecording` to `true` and you **should** set `Latency` to an appropriate value. The `Latency` value indicates an estimate of the time between sound physically hitting the microphone to submitting the audio to Dissonance, if you don't know this value leave it set to zero. `StopCapture` should do whatever you need to stop the underlying capture system. Once this is done you **must** set `IsRecording` to `false`. `Subscribe` and `Unsubscribe` should simply keep a list of subscribers. You can implement this as a `List` where `Subscribe` just calls `Add` and `Unsubscribe` just calls `Remove` and returns the value. [here is an example script](https://gist.github.com/martindevans/47127ccde8e5b7abeaa4cc0b49d60759) . If you run the scene with this you should see exceptions printed to the console every frame coming from the `UpdateSubscribers` method. Step 3 : Streaming Silence[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Microphone-Capture.html#step-3-streaming-silence "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now you need to stream some audio to Dissonance to stop the script throwing exceptions every frame. When `IsRecording` is `true` (i.e. after `StartCapture` has been called and before `StopCapture` has been called) your capture script **must** provide audio at approximately a realtime rate. Dissonance will try to handle slight "bumps" (e.g. audio arriving slightly early or late) but overall you must supply audio at the correct rate. For example the `BasicMicrophoneCapture` script assumes that the microphone supplies audio at the correct rate, if you're reading from some kind of recording hardware this is probably a good assumption to make. The basic process for the microphone capture (which you may be able to replicate in your custom system) is: 1. Drain all data from the recording hardware into a buffer 2. Copy as much data out of the buffer into a preallocated array as possible 3. Submit preallocated array to subscribers 4. if there is data left in the buffer, goto 2 For this step we won't interact with any hardware, instead we'll just submit _silence_ to Dissonance at the correct rate. [here is an example script](https://gist.github.com/martindevans/2ab034c885cf0c038db8fda471336596) which implements UpdateSubscribers by simply submitting _silence_ at the correct rate. If you run this everything should work as expected in Dissonance (no exceptions), but of course you will not hear anything. This works by preallocating an array of 960 `float`, which represents 20ms of audio at 48kHz sample rate. Every time 20ms have elapsed, the buffer is submitted to Dissonance. Note that time is measured using `unscaledDeltaTime`, since audio needs to run at _real_ time rate. Step 4 : File Streaming[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Microphone-Capture.html#step-4-file-streaming "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Finally we'll add a basic file streaming system, this will read an audio file and play it into Dissonance. For simplicity this will _not_ handle decoding of the audio from any well know format, instead you should transcode the audio into raw samples. You can do this with [ffmpeg](https://ffmpeg.org/) : > ffmpeg.exe -re -i AudioFile.wav -f f32le -ar 48000 -ac 1 output.raw [here is an example script](https://gist.github.com/martindevans/ad4df4d1f771538bb7f474756cbb3711) which implements this. The basic process is the same as the silence system: 1. Count time passed using `unscaledDeltaTime` 2. When 20ms have passed, read up to 20ms of audio from the file (as bytes) 3. Copy bytes into float buffer 4. Submit to all subscribers --- # Collider Chat Rooms - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html#step-1-define-our-room-volume) Collider Chat Rooms =================== Video See [this video](https://youtu.be/HXMYDbuLwVI?t=323) about collider chat rooms. This tutorial will introduce volume triggers for transmission and receipt triggers, and how they can be used to implement localised chat rooms which allow users standing within the same area in your game world to chat with each other. This tutorial builds upon the setup in the [Position tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) guide. > [Position Tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) > must be set up to allow Dissonance to track player positions for collider chat rooms to function. A demo scene for this tutorial can be found in `Dissonance/Demos`. Step 1: Define our room volume[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html#step-1-define-our-room-volume "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Imagine your game has multiple physical lobby rooms all connected to a central corridor. You decide that we want players to be able to speak to and hear the other players in whatever room they are in, and for this to dynamically update as they move from room to room. The first thing you will need to do is define the volume which represents your lobby room using a Unity [trigger volume](https://unity3d.com/learn/tutorials/topics/physics/colliders-triggers) . Create a new game object called "LobbyChatRoom". Add a "Box Collider" to the game object, set it's size to the size of your lobby room and check "Is Trigger". ![Box Collider](https://placeholder-software.co.uk/dissonance/docs/images/BoxCollider.png) Step 2: Add a Receipt Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html#step-2-add-a-receipt-trigger "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- To allow you to hear the users talking in the lobby chat room you will need to add a "Voice Receipt Trigger" to the game object. Unlike the "Global" chat channel in the quick start guide, here you will add this to the same game object as the "Box Collider". Enable "Trigger Activation" on the "Voice Receipt Trigger" to tell the script to only listen to the room when the player is within the collider attached to the game object. Step 3: Define a new Chat Rooms[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html#step-3-define-a-new-chat-rooms "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Right now, the receipt trigger is listening to the "Global" chat room, not the chat room for the lobby. On the inspector for the "Voice Receipt Trigger" click "Config Rooms" to go to Dissonance's room configuration. By default, Dissonance creates three chat rooms; "Global", "Red Team" and "Blue Team". Click "Add Room", and rename the new room to "Lobby". ![Room Configuration with Lobby](https://placeholder-software.co.uk/dissonance/docs/images/RoomConfiguration_Lobby.png) Now, go back to the receipt trigger, and change the selection in the "Chat Room" drop down to the new "Lobby" room. ![ReceiptTrigger with Lobby room available](https://placeholder-software.co.uk/dissonance/docs/images/VoiceReceiptTrigger_LobbyRoom.png) > Chat rooms can be named dynamically when configuring the triggers programmatically. Step 4: Add a Broadcast Trigger[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html#step-4-add-a-broadcast-trigger "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- You now have a receiver configured to hear other people talking in the lobby room, but no one is saying anything! You need to add a broadcast trigger to the room. Add a "Voice Broadcast Trigger" script to the game object. Use a Channel Type of "Room", and choose the "Lobby" room. ![BroadcastTrigger with Lobby room available](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_LobbyRoom.png) Finished[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html#finished "Permanent link") ----------------------------------------------------------------------------------------------------------------------------- You now have a trigger box set up as a chat room. Players standing within the collider can talk to each other in the "Lobby" chat room, players who walk out of the volume will not be able to speak to or hear from the lobby room. --- # Writing A Custom Network Integration - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#getting-started) Writing A Custom Network Integration ==================================== Dissonance is built to be completely decoupled from the underlying networking system, this allows Dissonance to run on top of various different Unity networking assets (e.g. UNet, Forge, Photon etc) just by swapping which Dissonance network component is used. If none of the [existing integrations](https://placeholder-software.co.uk/dissonance/docs/Basics/Choosing-A-Network.html) work for your application then you may need to build a custom network integration. ### Getting Started[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#getting-started "Permanent link") Dissonance includes a set of base classes which implement most of the networking logic for you: * `BaseCommsNetwork` - This is the main comms network component which you place into your scene. It manages the networking, starting and stopping Dissonance networking in response to network events. * `BaseServer` - This is a class created by the comms network component on one of the peers in the session. It manages the session as other peers join and leave. You will extend this class to implement your server logic. * `BaseClient` - This is a class created by the comms network component on all the peers in the session. It manages sending and receiving voice. You will extend this class to implement your client logic. Create the `CustomCommsNetwork` class which extends `BaseCommsNetwork`: `public class CustomCommsNetwork : BaseCommsNetwork< CustomServer, // A class which implements BaseServer CustomClient, // A class which implements BaseClient CustomPeer, // A struct which represents a network connection Unit, // Nothing Unit // Nothing > { }` As you can see `BaseCommsNetwork` requires 5 type parameters, which specify all the parts of your custom network integration: * `CustomServer` - This is a class you will create which extends `BaseServer` * `CustomClient` - This is a class you will create which extends `BaseClient` * `CustomPeer` - This is a struct you will create which represents another peer in the network session. * `CustomClientParam` - This is a struct you will create which contains the data necessary create a network connection (e.g. an IP address). If your network does not need this (e.g. it is already running before Dissonance is started) then just pass `Unit`. * `CustomServerParam` - This is a struct you will create which contains the data necessary host a network session (e.g. a port number). If your network does not need this (e.g. it is already running before Dissonance is started) then just pass `Unit`. To create all these types define two new classes: * `class CustomCommsNetwork : BaseCommsNetwork {}` * `class CustomClient : BaseClient {}` * `class CustomServer : BaseServer {}` And three new structs: * `struct CustomPeer : IEquatable {}` * `struct CustomServerParam {}` * `struct CustomClientParam {}` Once you have done this you will have a large number of build errors like "abstract member \[...\] not implemented" - these are the things you must implement before the network integration can work. `CustomCommsNetwork : BaseCommsNetwork`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#customcommsnetwork-basecommsnetwork "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- In your custom comms network class you will need to create your custom client and custom server objects. Dissonance will call these methods when a server or client needs to be created. You shouldn't connect to the network in this method, simply create the objects. `protected override CustomServer CreateServer(CustomServerParam details) { return new CustomServer(this, details); } protected override CustomClient CreateClient(CustomClientParam details) { return new CustomClient(this, details); }` If you need to do any other setup work for your network system you can override the `Initialize` method. `protected override void Initialize() { Network.DoSomethingImportant(); // Don't forget to call base.Initialize! base.Initialize(); }` Finally you need to start the network and tell it to connect, there are two main techniques for this. Some integrations (e.g. Mirror/Photon) have a network system which is already connected and Dissonance can use that, other integrations (e.g. WebRTC) host a network session specifically for voice chat. If you are using the first technique then you need to monitor the external network system and make sure that Dissonance is running in the same way as the network system by calling `RunAsHost`, `RunAsDedicatedServer`, `RunAsClient` or `Stop`. Here is how this is implemented in the HLAPI network integration: `// Check every frame protected override void Update() { // Check if Dissonance is ready if (IsInitialized) { // Check if the HLAPI is ready var networkActive = NetworkManager.singleton.isNetworkActive && (NetworkServer.active || NetworkClient.active); if (networkActive) { // Check what mode the HLAPI is in var server = NetworkServer.active; var client = NetworkClient.active; // Check what mode Dissonance is in and if // they're different then call the correct method if (Mode.IsServerEnabled() != server || Mode.IsClientEnabled() != client) { // HLAPI is server and client, so run as a non-dedicated // host (passing in the correct parameters) if (server && client) RunAsHost(Unit.None, Unit.None); // HLAPI is just a server, so run as a dedicated host else if (server) RunAsDedicatedServer(Unit.None); // HLAPI is just a client, so run as a client else if (client) RunAsClient(Unit.None); } } else if (Mode != NetworkMode.None) { //Network is not active, make sure Dissonance is not active Stop(); } } base.Update(); }` If you are using the second technique then you will need to decide when to call `RunAsHost`, `RunAsDedicatedServer`, `RunAsClient` or `Stop` at the appropriate times. `CustomClient : BaseClient`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#customclient-baseclient "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------- This class handles all of the client side logic of Dissonance, one of these will be created on every single peer in the session (including the host). There will be two build errors to fix in this class. `Base class [...] doesn't contain a parameterless constructor`. To fix this simply add a constructor which passes a `CustomCommsNetwork` to the base class: `public CustomClient(CustomCommsNetwork network, CustomClientParam details) : base(network) { }` `abstract member [...] not implemented`. There will be four of these errors to fix: #### public override void Connect()[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#public-override-void-connect "Permanent link") This will be called when you need to connect to the session. You should start connecting to the network when this is called, once you have finished connecting (which may take a long time) you must call `base.Connected()`. In systems where there is already a network connection setup you may just immediately call `base.Connected()`. #### protected override void ReadMessages()[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#protected-override-void-readmessages "Permanent link") This will be called periodically to poll messages from the network system. Any packets you receive must be passed to `base.NetworkPacketReceived`. #### protected override void SendReliable(ArraySegment packet)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#protected-override-void-sendreliablearraysegment-packet "Permanent link") This method sends a packet to the server using a **reliable** and **in order** channel (e.g. TCP). Packets sent with this method are not latency sensitive but MUST arrive in order. If you detect that a reliable packet has been lost you should immediately stop the Dissonance network session. #### protected override void SendUnreliable(ArraySegment packet)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#protected-override-void-sendunreliablearraysegment-packet "Permanent link") This methods sends a packet to the server using an **unreliable** and **unordered** channel (e.g. UDP). Packets sent with this method are _extremely_ latency sensitive and must arrive as soon as possible or not at all. It is expected that some packets sent using this method may be lost or arrive out of order. `CustomServer : BaseServer`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#customserver-baseserver "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------- This class handles all the server side logic of Dissonance, one of these will be created on a single peer in the session and handles managing the session. In the basic configuration all voice data is relayed via this peer (see P2P section for details on how to avoid this). There will be five "abstract member \[...\] not implemented" errors to fix: #### `public override void Connect()`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#public-override-void-connect_1 "Permanent link") This will be called when you need to host a new network session (e.g. open a socket). #### `public override void Disconnect()`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#public-override-void-disconnect "Permanent link") This will be called when you need to stop hosting a session (e.g. close the socket). #### `protected override void ReadMessages()`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#protected-override-void-readmessages_1 "Permanent link") This will be called periodically to poll messages from the network system. Any packets you receive should be to `base.NetworkPacketReceived`. The `base.NetworkPacketReceived` method on the server requires an instance of your `CustomPeer` type which indicates who sent the message. #### `protected override void SendReliable(CustomPeer destination, ArraySegment packet)`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#protected-override-void-sendreliablecustompeer-destination-arraysegmentbyte-packet "Permanent link") This method sends a reliable packet to another peer using a **reliable** and **in order** channel (e.g. TCP). Packets sent with this method are not latency sensitive but MUST arrive in order. If you detect that a reliable packet has been lost you should immediately stop the Dissonance network session. If you need some extra information about who the packet is being sent to, you should add it to the `CustomPeer` struct. Remember to go to the `ReadMessages` method and add that information to the `CustomPeer` struct you passed in to `NetworkPacketReceived`. #### `protected override void SendUnreliable(CustomPeer destination, ArraySegment packet)`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#protected-override-void-sendunreliablecustompeer-destination-arraysegmentbyte-packet "Permanent link") This methods sends a packet to the server using an **unreliable** and **unordered** channel (e.g. UDP). Packets sent with this method are _extremely_ latency sensitive and must arrive as soon as possible or not at all. It is expected that some packets sent using this method may be lost or arrive out of order. #### `ClientDisconnected`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#clientdisconnected "Permanent link") When a peer disconnects from the server you must call `ClientDisconnected` to notify the server. Editor Inspector[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#editor-inspector "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------- Finally you should create an inspector for your CustomCommsNetwork. Doing this is very simple, extend the `BaseDissonanceCommsNetworkEditor` class and pass the same 5 generic types you defined above. Attach the `CustomEditor` attribute to the class. `[CustomEditor(typeof(CustomCommsNetwork))] public class CustomCommsNetworkEditor : BaseDissonnanceCommsNetworkEditor< CustomCommsNetwork, CustomServer, CustomClient, CustomConn, CustomClientParam, CustomServerParam > { }` This will set up a basic inspector for you. Testing[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#testing "Permanent link") -------------------------------------------------------------------------------------------------------------------------- At this point you should have a basic voice chat system functioning with your custom network. You should set up a test scene to test it. While the test scene is running check these things: * Look at the inspector for your `CustomCommsNetwork` component. * Once the network session is started the `Mode` should shows "Server & Client", "Client" or "Server" depending on the mode this peer is running in. * Once the network session has connected the `Connection Status` should show "Connected" * Try sending a [text chat](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html) message. * Create a [broadcast and receipt](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Global-Chat-Room.html) trigger and speak. * Look at the inspector for the `DissonanceComms` component. It shows a list of client in the session, disconnect a client and make sure they disappear. Extensions: Loopback[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#extensions-loopback "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------------- The Dissonance networking system create a `CustomClient` _and_ a `CustomServer` on the host machine (unless running a dedicated server). The server must be able to send and receive message to this local peer the same as any other peer. This can cause complications with some network systems which do not handle this kind of "loopback" correctly. You must also be careful to make sure you can distinguish messages from other peers to the host - make sure that they don't get processed by the host client object. To handle this many of the Dissonance integrations have a special check for loopback. For example in the HLAPI integration there is a `HlapiCommsNetwork:PreprocessPacketToClient` method which is given all packets sent from the server to the client, it checks if the packet is a loopback packet and if so it passes it directly to the client and HLAPI itself never has to deal with this packet. `internal bool PreprocessPacketToClient(ArraySegment packet, HlapiConn destination) { // No client means this can't be loopback if (Client == null) return false; // HLAPI way to check if this is loopback. if (NetworkManager.singleton.client.connection != destination.Connection) return false; // This is loopback! // check that we have a valid local client, // in cases of startup or in-progress shutdowns if (Client != null) { // Don't immediately deliver the packet, add it to a queue and // deliver it next frame. This prevents the local client from // executing "within" the local server which can cause // confusing stack traces. _loopbackQueue.Add(packet.CopyTo(_loopbackBuffers.Get())); } return true; }` Extensions: Peer To Peer[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#extensions-peer-to-peer "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------- Currently the network integration you have built sends all packets to the server, which then relays them to other clients. If possible you _may_ want to implement peer to peer voice communications. However, you should consider the bandwidth of your game before implementing peer to peer as it is not always beneficial to use it. In a non P2P setup voice follows a path like: `Speaker -> Server -> Listener #1 -> Listener #2 -> Listener #3` In this case the bandwidth used by the speaker is 1 voice stream `~20 kilobits/second`. The bandwidth used by each listener is 1 voice stream `~20 kilobits/second`. The bandwidth used by the server is `(Speakers + Listeners) * Bandwidth = (1 + 3) * ~20 = ~80 kilobits/second`. In this setup the bandwidth of each client (speaker or listener) is the minimum possible. If your game uses client devices with tight bandwidth limits this may be the best setup. In a P2P setup the voice follows a different path: `Speaker -> Listener #1 -> Listener #2 -> Listener #3` The bandwidth on the server has been reduced (to zero). However, the total bandwidth for the speaker client is now `Listeners * Bandwidth = 3 * ~20 = ~60 kilobits/second`. ### Implementing P2P[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#implementing-p2p "Permanent link") If you have decided to use peer to peer you need to modify your `CustomClient` class. Wherever you call `NetworkReceivePacket` you should modify it to capture the return value of the method call, if the value is not call `ReceiveHandshakeP2P` with it and a `CustomPeer` object for the sender of the message. For example in the Photon Unity Networking (PUN) integration the receiving code is implemented like this: ``// This event is called by PUN when a packet arrives public void PacketDelivered(byte eventcode, ArraySegment data, int senderid) { // Skip events we don't care about if (eventcode != _network.EventCodeToClient) return; // Receive the packet, capture return value var id = NetworkReceivedPacket(data); // If the value is not null // pass to handshake method with the `senderid` of this packet if (id.HasValue) ReceiveHandshakeP2P(id.Value, senderid); }`` You now need to implement two more methods for sending packets: #### `SendReliableP2P(List> destinations, ArraySegment packet)`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#sendreliablep2plistclientinfotpeer-destinations-arraysegmentbyte-packet "Permanent link") #### `SendUnreliableP2P(List> destinations, ArraySegment packet)`[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Networking.html#sendunreliablep2plistclientinfotpeer-destinations-arraysegmentbyte-packet "Permanent link") These methods send a packet to a list of destinations. You should send the packet to as many of these destinations as possible and remove them from the list. Once you are done call the base method with the remaining items in the list, they will be sent via the server as usual. For example the PUN implementation of this is: `private void SendUnreliableP2P(IList> destinations, ArraySegment packet) { // Build a list of destinations we know how to send to // i.e. have a non-null Connection object var dests = new List(); foreach (var item in destinations) if (item.Connection.HasValue) dests.Add(item.Connection); // Remove all the ones we can send to from the input list destinations.RemoveAll(dests); // Send the packets to the list of destinations through PUN _network.Send(packet, dests, reliable: false); // Call base to do server relay for all the peers we don't // know how to contact base.SendUnreliableP2P(destinations, packet); }` Because there is a fall-back mechanism you can mix P2P and non-P2P packets as necessary. For example you start by sending everything via the server, establish a p2p connection between clients and if it fails (e.g. due to firewall or NAT settings) you can simply keep on sending via relay for that specific pair of clients. Alternatively you could monitor client bandwidth and send via P2P if there is spare bandwidth - falling back to server relay if the client is close to reaching it's bandwidth limit. Finally you need to start establishing p2p connections. Override the `OnServerAssignedSessionId` method, when this is called you should send a "handshake" packet to every peer you know how to contact directly. This will tell those peers that you are available for p2p communication. For example in the PUN integration this is implemented as: `protected override void OnServerAssignedSessionId(uint session, ushort id) { base.OnServerAssignedSessionId(session, id); // Create the handshake packet to send var packet = new ArraySegment(WriteHandshakeP2P(session, id)); // Send this to everyone else in the session through PUN _network.Send(packet, _network.EventCodeToClient, new RaiseEventOptions { Receivers = ReceiverGroup.Others, }, true); }` --- # Windows (Desktop) - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Platforms/Windows%20Desktop.html#windows-desktop) Windows (Desktop)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/Windows%20Desktop.html#windows-desktop "Permanent link") ============================================================================================================================================ To run Dissonance on a Windows PC requires [Visual Studio **Redistributable**](https://aka.ms/vs/17/release/vc_redist.x64.exe) . On systems older than Windows 10, users must also install [this](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c) Windows Update. Steam[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/Windows%20Desktop.html#steam "Permanent link") ---------------------------------------------------------------------------------------------------------------------- If you are distributing your application through [Steam](https://store.steampowered.com/) you can set the redistributable as a dependency. It will be installed when the application is installed. This can be done through the [app panel](https://placeholder-software.co.uk/dissonance/docs/Platforms/partner.steamgames.com) : `App Panel > Installation > Redistributables > Visual C++ Redist 2019`. --- # Windows (UWP/Hololens) - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Platforms/Windows%20UWP%20%26%20Hololens.html#windows-uwphololens) Windows (UWP/Hololens)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Platforms/Windows%20UWP%20%26%20Hololens.html#windows-uwphololens "Permanent link") ================================================================================================================================================================== To run Dissonance on a Windows PC within a UWP application requires [Visual Studio 2017 v141 Redist](https://www.visualstudio.com/downloads/#title-90c66ddff7b7862f11eca8ffc80762c5) . It's recommended that you package this with your application and install it as part of your install process. --- # Server Scripting API - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Server-Admin-API.html#server-scripting) Server Scripting API ==================== Server Scripting[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Server-Admin-API.html#server-scripting "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------- Dissonance is primarily client authoritative. For example the client controls where audio is being sent to ([VoiceBroadcastTrigger](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html) /[Channels](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Directly-Using-Channels.html) ) and received from ([VoiceReceiptTrigger](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Receipt-Trigger.html) /[Rooms](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/Rooms.html) ). Dissonance has a server side API which allows server side control & monitoring of clients from the server. ### Access[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Server-Admin-API.html#access "Permanent link") The server side API can be accessed from `ServerAdmin` property on the comms network component which is next to the `DissonanceComms` component in your scene. Accessing this property will return `null` on clients. `// Get the DissonanceComms object in the scene var comms = DissonanceComms.GetSingleton(); // Get the network component which is next to it. // This must be cast to the correct type for whichever network integration you are using! var network = (MirrorCommsNetwork)comms.GetComponent(); // This will return null on clients var admin = network.ServerAdmin;` ### Channel Monitoring[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Server-Admin-API.html#channel-monitoring "Permanent link") Some features of the admin API require that "channel monitoring" is enabled, this makes the server partially decode packets to extract the channel data from them. By default this is **disabled** and all features which require it will return default values (null, or otherwise "empty" responses). To enable channel monitoring, set the property to `true` during initialisation: `admin.EnableChannelMonitoring = true;` ### Packet Spoofing[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Server-Admin-API.html#packet-spoofing "Permanent link") Detecting packet spoofing requires `EnableChannelMonitoring = true` Dissonance voice packets include a header which indicates who sent the packet (i.e. who is speaking). A malicious client could change this field to send packets as if they're coming from another player. Since packets may be relayed via the server clients cannot reliably detect this. If the server ever detects this it will invoke the `VoicePacketSpoofed` event. You can subscribe to this and handle it (e.g. kick the malicious client): `admin.VoicePacketSpoofed += (IServerClientState actualSender, IServerClientState? victim) => { Debug.LogWarning($"{actualSender.Name} spoofed a packet from {(victim?.Name ?? "nobody")}."); };` ### Per-Client Info[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Server-Admin-API.html#per-client-info "Permanent link") Per-client information is exposed as an `IServerClientState` object for each client. See the [`IServerClientState` reference docs](https://placeholder-software.co.uk/dissonance/docs/Reference/Networking/IServerClientState.html) for more information on the properties available. ``// Events admin.ClientJoined += state => Debug.Log($"{state.Name} joined Dissonance session")`; admin.ClientLeft += state => Debug.Log($"{state.Name} left Dissonance session")`; // Collection foreach (var state in admin.Clients) Debug.Log(state.Name);`` --- # Script Controlled Speech - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Script-Controlled-Speech.html#muting-the-local-player) Script Controlled Speech ======================== There are several options for controlling speech from scripts, depending on what you want to achieve. ### Muting The Local Player[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Script-Controlled-Speech.html#muting-the-local-player "Permanent link") If you want to completely prevent a player from speaking you can set the `IsMuted` property on the `DissonanceComms` component to true. `DissonanceComms comms; comms.IsMuted = true; // User cannot speak comms.IsMuted = false; // User can speak` ### Deafening The Local Player[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Script-Controlled-Speech.html#deafening-the-local-player "Permanent link") If you want to completely prevent the local player from hearing any speech you can set the `IsDeafened` property on the `DissonanceComms` component to true. `DissonanceComms comms; comms.IsDeafened = true; // User cannot hear comms.IsDeafened = false; //User can hear` ### Muting Remote Players[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Script-Controlled-Speech.html#muting-remote-players "Permanent link") If you want to _locally_ mute a remote player (prevent yourself from hearing them talk) you can set the `IsLocallyMuted` property on their player object. `DissonanceComms comms; var player = comms.FindPlayer(player_id); player.IsLocallyMuted = true; // You will not hear user when they speak player.IsLocallyMuted = false; // You will hear user when they speak` ### Disabling Triggers[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Script-Controlled-Speech.html#disabling-triggers "Permanent link") The [`VoiceBroadcastTrigger`](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html) is the normal way to trigger voice transmission. Simply disabling this component will prevent it from triggering any voice transmissions until it is enabled again. `VoiceBroadcastTrigger trigger; trigger.enabled = false; // This trigger cannot send voice trigger.enabled = true; // This trigger can send voice` ### Opening Channels[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Script-Controlled-Speech.html#opening-channels "Permanent link") The most general way to control player voice transmission from scripts is to open and close channels, for more information about channels see [this tutorial](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Directly-Using-Channels.html) . To start talking open a channel, to stop talking dispose the channel: `DissonanceComms comms; var channel = comms.RoomChannels.Open("Room ID", true, ChannelPriority.Default); //Player speech will be transmitted to the room named "Room ID" channel.Dispose(); //Player speech will no longer be transmitted by this channel` --- # Spatialization Plugins - Dissonance Voice Chat Spatialization Plugins ====================== Since [Dissonance 7.0.2](https://placeholder-software.co.uk/dissonance/releases/7.0.2.html) Dissonance no longer supports external spatialization plugins. A change in how Unity applies spatialization has made support for this feature impossible. Unity have acknowledged this bug and we will add support back into Dissonance as soon as possible. --- # Push-To-Talk - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html#ui-button) Push-To-Talk ============ Video See [this video](https://www.youtube.com/watch?v=Kz7qM6XditI) about push to talk activation. When a broadcast trigger is in Push-To-Talk (PTT) mode voice will only be transmitted while the "talk" button is pressed. To set a broadcast trigger to use PTT simply change the "Activation Mode" to "Push To Talk" and choose which input axis must be pressed for voice to be transmitted. See the [Unity documentation](https://docs.unity3d.com/Manual/class-InputManager.html) for how to define a new input axis. ![A Voice Broadcast Trigger with Push To Talk](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_PTT.png) UI Button[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Push-to-Talk.html#ui-button "Permanent link") ------------------------------------------------------------------------------------------------------------------------- Instead of using an input axis you may want to trigger push-to-talk from a UI button. 1. Set the `Activation Mode` to `Open`. This constantly transmits voice. 2. Set `Mute` to `true`. This prevents any voice from being transmitted. 3. Configure your UI button to trigger the `ToggleMute` method. This inverts the `Mute` setting each time it is called. With this setup clicking the UI button once will unmute the trigger and speech will be transmitted, clicking the button again will mute the trigger and stop speech from being transmitted. --- # Text Chat - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html#send-a-text-message-to-a-chat-room) Text Chat ========= Dissonance allows text chat messages to be routed through the network to the same players and chat rooms used by voice. This tutorial will demonstrate the APIs provided to send and receive text chat messages with Dissonance. Send a text message to a Chat Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html#send-a-text-message-to-a-chat-room "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ `// get the DissonanceComms script from the Dissonance game object var dissonance = GetComponent(); // send a text message to the Party chat channel dissonance.Text.Send("Party", "Who just pulled the boss?")` Send a text message to a player[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html#send-a-text-message-to-a-player "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ `// get the DissonanceComms script from the Dissonance game object var dissonance = GetComponent(); // send a text message to a specific player dissonance.Text.Whisper("hunter", "Did you just pull the boss?")` Receive a text message[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Text-Chat.html#receive-a-text-message "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------ Dissonance will only send you text messages if they are directly addressed to you or to a room which you are listening to. To listen to a room you can use a voice receipt trigger [voice receipt trigger](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Receipt-Trigger.html) , or directly use the Dissonance API from scripts to enter the room. `// get the DissonanceComms script from the Dissonance game object var dissonance = GetComponent(); //If necessary, enter a room using the scripting API dissonance.Rooms.Join("Room Name"); dissonance.Text.MessageRecieved += message => { //This code will run every time you receive a text message var format = "[{0}] {1}: {2}"; if (message.RecipientType == ChannelType.Player) format = "{1} whispers: {2}"; chatLog.Write(string.Format(format, message.Recipient, message.Sender, message.Message)); };` --- # Other Integrations - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Basics/Other-Integrations#salsa-lip-sync) Other Integrations ================== Dissonance has optional integrations with some non-networking assets to add/improve certain features. SALSA Lip Sync[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Other-Integrations#salsa-lip-sync "Permanent link") --------------------------------------------------------------------------------------------------------------------------------- [SALSA Lip Sync](https://assetstore.unity.com/packages/tools/animation/salsa-lipsync-suite-148442?aid=1100lJDF) provides real-time lip synchronisation. The `SalsaDissonanceLink` integration connects the Dissonance audio system to the lip sync system to provide real-time lip synchronisation for other speakers in the VoIP session. For a download link and more information, see the [full documentation](https://crazyminnowstudio.com/docs/salsa-lip-sync/addons/using-with-dissonance/) on the SALSA docs. [FMOD Playback](https://assetstore.unity.com/packages/slug/213415?aid=1100lJDF) [⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Other-Integrations#fmod-playback "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [FMOD](https://assetstore.unity.com/packages/tools/audio/fmod-for-unity-161631?aid=1100lJDF) is a powerful alternative audio system for Unity. The [FMOD Playback](https://assetstore.unity.com/packages/slug/213415?aid=1100lJDF) integration package outputs Dissonance audio into the FMOD audio system. This allows you to mix Dissonance audio in the FMOD mixer and to completely disable the Unity audio system. If you completely disable the Unity audio system you **must** also use the FMOD Recording package. [FMOD Recording](https://assetstore.unity.com/packages/slug/213412?aid=1100lJDF) [⚓︎](https://placeholder-software.co.uk/dissonance/docs/Basics/Other-Integrations#fmod-recording "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [FMOD](https://assetstore.unity.com/packages/tools/audio/fmod-for-unity-161631?aid=1100lJDF) is a powerful alternative audio system for Unity. The [FMOD Recording](https://assetstore.unity.com/packages/slug/213412?aid=1100lJDF) integration package provides higher quality and lower latency audio to Dissonance through FMOD. Using this integration does **not** require that you are using FMOD for audio playback. You can install FMOD just for the higher quality audio recording and continue to use the normal Unity audio systems. --- # Team Chat Rooms - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html#additional-global-chat-room) Team Chat Rooms =============== A team chat room is a set of rooms where all users _on the same team_ talk to and listen to the same room. To create a setup like this requires a small amount of scripting as it depends on how your game defines what a "team" actually is! To create a team chat setup first create multiple pairs of broadcasters and receivers, one for each team. ![Example of team chat configuration](https://placeholder-software.co.uk/dissonance/docs/images/TeamChat_Inspector.png) With the setup as shown here every player will speak and and listen to every team channel. To fix this add a unique token to each pair of triggers (e.g. the team name), once you have done this none of the triggers will activate and no one will speak or listen to any of the team rooms. Finally, when you create a player and assign them to a team run a script which adds the appropriate token to the local player. Exactly how this code works depends a lot on exactly how your game defines what a team is, feel free to [ask for help](https://www.reddit.com/r/dissonance_voip/) . Here is some example code: `void OnAssignPlayerToTeam(string teamName) { //Find local comms object var comms = FindObjectOfType(); //Sanity check that we found what we're looking for if (comms == null) { Debug.Log("Cannot find voice components for team '{0}'", teamName); return; } //Add the token for the team comms.AddToken(teamName); }` Additional Global Chat Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Team-Chat-Rooms.html#additional-global-chat-room "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- If you want to still have a global voice chat room _and_ have per team chat rooms this can be achieved by simply having the normal [global chat room](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Global-Chat-Room.html) configuration with a different activation mode (e.g. a different push-to-talk input axis, such as 'v' to team chat and 'b' to global chat). ![Example of two different PTT axes](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_DifferentPTT.png "Example of two different PTT axes") --- # Transmit to Player - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html#set-the-player-name) Transmit to Player ================== Video See [this video](https://youtu.be/HXMYDbuLwVI?t=1064) about direct player messaging. This tutorial will explain how to broadcast a voice message directly to a specific player, rather than to all players in a room. There are two ways to achieve this. Set The Player Name[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html#set-the-player-name "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------- To transmit to a specific player, change the Channel Type option on the `VoiceBroadcastTrigger` to "Player", then give the player name for Recipient Player Name. ![Broadcast Trigger configured for player messaging](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Player.png) To change the targetted player at run time modify the `PlayerId` field of the `VoiceBroadcastTrigger` behaviour. `GetComponent().PlayerId = "TheNewRemotePlayerName";` Target A Player Behaviour[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html#target-a-player-behaviour "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- If you have set up Dissonance [position tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) in your game then the game objects which represent your players will all have a behaviour on them which implements the `IDissonancePlayer` interface. For example if you are using the Forge Networking integration this is the `ForgePlayer` component. To transmit to this player change the Channel Type option on a `VoiceBroadcastTrigger` attached to the same game object to "Self". ![Broadcast Trigger configured for alternative player messaging](https://placeholder-software.co.uk/dissonance/docs/images/BroadcastToSelf_Inspector.png) --- # Direct Access To Recorded Audio - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/UsingIMicrophoneSubscriber.html#direct-access-to-recorded-audio) Direct Access To Recorded Audio =============================== Direct Access To Recorded Audio[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/UsingIMicrophoneSubscriber.html#direct-access-to-recorded-audio "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Dissonance includes a mechanism for directly accessing the stream of recorded audio, this can be used to drive features such as recording the mic input to file or passing it through a Speech-To-Text system. There are two ways to implement this, direct low-level access through [IMicrophoneSubscriber](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/IMicrophoneSubscriber.html) and easier access through [BaseMicrophoneSubscriber](https://placeholder-software.co.uk/dissonance/docs/Reference/Audio/BaseMicrophoneSubscriber.html) . Once you have created a script which uses either of these systems you must register it to receive data from Dissonance by calling `FindObjectOfType().SubscribeToRecordedAudio(your_script)` and passing in your script as `your_script`. ### BaseMicrophoneSubscriber[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/UsingIMicrophoneSubscriber.html#basemicrophonesubscriber "Permanent link") This provides easy access to the microphone audio stream. This script handles capturing and buffering the data, it is delivered in batches on the main thread. ### IMicrophoneSubscriber[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/UsingIMicrophoneSubscriber.html#imicrophonesubscriber "Permanent link") This provides direct access to the microphone audio stream as directly as possible. Audio is delivered to the `ReceiveMicrophoneData` method on the background audio processing thread **not** the main thread. Only use this if `BaseMicrophoneProvider` does not meet your use case! --- # Writing A Custom IDissonancePlayer - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Position-Tracking.html#how-dissonance-tracks-players) Writing A Custom IDissonancePlayer ================================== This tutorial will explain how to write a scripts necessary to extend the Dissonance position tracking system to more advanced scenarios. The basics of position tracking are explained in [this tutorial](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) . How Dissonance Tracks Players[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Position-Tracking.html#how-dissonance-tracks-players "Permanent link") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Dissonance tracks the position of players through a behaviour which implements the IDissonancePlayer interface. This interface exposes the necessary information for Dissonance to play back voices in the correct locations. `public interface IDissonancePlayer { string PlayerId { get; } Vector3 Position { get; } Quaternion Rotation { get; } NetworkPlayerType Type { get; } bool IsTracking { get; } }` Once you have implemented these five properties on your tracker you must register it with Dissonance, To do this simply call `DissonanceComms.GetSingleton().TrackPlayerPosition(this);` after tracking has started. Once this tracker is no longer in use you must unregister your tracker from Dissonance, to do this simply call `DissonanceComms.GetSingleton().StopTracking(this);`. #### PlayerId[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Position-Tracking.html#playerid "Permanent link") This is the ID of the player which this object represents. For the local player this is the value in the `LocalPlayerName` property on your `DissonanceComms` object. Trackers attached to remote player objects must discover the ID for the players it represents. Usually this discovery is done by sending the ID across the network, exactly how this works depends on your networking system. Most implementations follow a similar flow: 1. Discover that this instance represents the local player (e.g. `OnStartClient`, `OnStartAuthority` callback) 2. Get `DissonanceComms.GetSingleton().LocalPlayerName` and send it to the server (e.g. `ServerRPC`) 3. Server sends the `LocalPlayerName` to all instances (e.g. `SyncVar`, or `Command`) 4. Instances receive this message and then: a. set `PlayerId = ID` b. set `Type = Remote` c. set `IsTracking = true` d. call `DissonanceComms.GetSingleton().TrackPlayerPosition(this);` Care must be taken to ensure that late-joining players receive the message in step #3 correctly. For example using a `buffered RPC` or a `SyncVar`. #### Position And Rotation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Position-Tracking.html#position-and-rotation "Permanent link") These properties supply the location information which is used by Dissonance to properly play positional audio. If the behaviour is attached to the object which represents the player position then implementing this is trivial: `public Vector3 Position { get { return transform.position; } } public Quaternion Rotation { get { return transform.rotation; } }` If you want to represent a slightly different location (e.g. your player is made of multiple objects, one of which represents the head) then you would need to change the implementation of the properties slightly: `private MonoBehaviour _head; public Vector3 Position { get { return _head.transform.position; } } public Quaternion Rotation { get { return _head.transform.rotation; } } public void OnEnable() { _head = GetHeadTransform(); }` #### Type[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Position-Tracking.html#type "Permanent link") This indicates to Dissonance if this object represents the (singular) local player or one of the (multiple) remote players. How you implement this property depends upon your network system. For example: `public NetworkPlayerType Type { get { return isLocalPlayer ? NetworkPlayerType.Local : NetworkPlayerType.Remote; } }` --- # Global Chat Room - Dissonance Voice Chat Global Chat Room ================ A global chat room is just a single room which all users talk to and listen to. This is a very simple system to create using Dissonance. ![Example of inspector for a single global chat room](https://placeholder-software.co.uk/dissonance/docs/images/GlobalChatRoom_Inspector.png "Example of inspector for a single global chat room") 1. Create a Voice Broadcast Trigger and a Voice Receipt Trigger on the root Dissonance game object 2. Set the room for both of them to "Global". Both components will activate when the scene loads (on each different computer in the network session) and all players will be in the room. Find out more about the [broadcast trigger](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Broadcast-Trigger.html) and the [receipt trigger](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Voice-Receipt-Trigger.html) . --- # Position Tracking For BOLT - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking-For-Bolt.html#bolt-state-synchronisation) Position Tracking For BOLT ========================== Video See [this video](https://youtu.be/HXMYDbuLwVI?t=1179) about position tracking. This tutorial will explain how to configure your project to track the position of players. This is required for 3D positional audio playback of remote player voice chat and collider trigger support for `VoiceBroadcastTrigger` and `VoiceReceiptTrigger`. There are some additional steps required for this to work with Photon BOLT, if you are not using that network integration instead see the more general [position tracking tutorial](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) . BOLT State Synchronisation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking-For-Bolt.html#bolt-state-synchronisation "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- First you need to modify the bolt state which you use for your player; add a new string property called `DissonancePlayerId`. ![Bolt State](https://placeholder-software.co.uk/dissonance/docs/images/Bolt-State.png) Now you need to create a new script which will use this state. Dissonance includes a base class which does most of the work for you. `using Dissonance.Integrations.PhotonBolt; public class DissonancePlayerTracking : BoltPlayer< ??? > // <-- See below { public DissonancePlayerTracking() : base("DissonancePlayerId", state => state.DissonancePlayerId, (state, id) => state.DissonancePlayerId = id) { } }` The `???` in the example needs to be replaced with the state which bolt has generated for your player. Setup Tracking[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking-For-Bolt.html#setup-tracking "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------- To setup position tracking you simply need to attach the DissonancePlayerTracking component to the game object which represents each player. Ensure that this component is attached to _all_ entities in the scene which represent a player (both the local player and all remote players). If you have a prefab which is used to construct your players you can simply attach the behaviour to this prefab. ![A Player Prefab with position tracking behaviour added](https://placeholder-software.co.uk/dissonance/docs/images/PlayerPrefab_PositionalAudio.png) Using Position Tracking[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking-For-Bolt.html#using-position-tracking "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Positional Audio[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking-For-Bolt.html#positional-audio "Permanent link") When positional audio is enabled the voice from remote players will sound like it is coming from the correct position. To enable this simply tick the "use positional data" checkbox on the voice broadcast trigger. ![A broadcast trigger with positional audio enabled](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Positional.png) ### Collider Chat Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking-For-Bolt.html#collider-chat-room "Permanent link") Voice broadcaster triggers and voice receipt triggers can be configured to only send/receive audio when the local player is inside a certain volume. See [this](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) tutorial for how to achieve this. ### Direct Transmit To Player[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking-For-Bolt.html#direct-transmit-to-player "Permanent link") When position tracking is enable transmitting to a specific player is simplified. If a `Voice Broadcast Trigger` is attached to a player entity it can be configured to transmit to the player represented by the game object. See [this](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) tutorial for details. --- # Using Channels - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Directly-Using-Channels.html#player-channels) Using Channels ============== This tutorial will explain how to use the channel API for fine grained control over when and where voice is sent. Channels are the system which are used internally by the transmit triggers which come with Dissonance. Direct use of channels requires writing scripts. Using a channel is quite simple - when a channel is open voice will be sent to whoever is appropriate. A single client may have _multiple_ channels open at once, potentially all sending to the same remote player. The remote playback system will correctly handle this situation and will only play the voice back once. There are two kinds of channels, which correspond to two different types of receivers. ### Player Channels[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Directly-Using-Channels.html#player-channels "Permanent link") When a player channel is opened the local voice is sent to the player associated with that channel. The receiving player does not need to take any action to receive the voice. This is accessed through the `PlayerChannels` property on the DissonanceComms object. `DissonanceComms comms; PlayerChannel channel = comms.PlayerChannels.Open(string playerId, bool positional, ChannelPriority priority);` ### Room Channels[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Directly-Using-Channels.html#room-channels "Permanent link") When a room channel is opened no voice is sent anywhere by default. Receiving players must take an action to indicate that they wish to receive the voice (i.e. join the room). This is accessed through the `RoomChannels` property on the DissonanceComms object (to open a sending channel) and the `Rooms` property (to control receipt). `DissonanceComms comms; RoomChannel channel = comms.RoomChannels.Open(string roomId, bool positional, ChannelPriority priority);` `DissonanceComms comms; comms.Rooms.Join(string roomId);` ### Managing An Open Channel[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Directly-Using-Channels.html#managing-an-open-channel "Permanent link") When you open a channel you receive back an object which represents that channel. This object allows you to control the channel while it is still open. `bool IsOpen { get; }` This property indicates if the channel is open. A channel will remain open until you explicitly close it. `bool Positional { get; set; }` This property indicates if this channel should be played back with positional data. You may change this value at any time. When a channel is using positional audio the remote playeback system will position the playback in space so that it sounds like the player voice is coming from the correct direction. If a channel is _not_ using positional audio the voice will be non-directional. `ChannelPriority Priority { get; set; }` This property indicates the [priority](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Channel-Priority.html) associated with data sent over this channel. You may change this value at any time. When a receiver is receiving multiple channels simultaneously it will only play the highest priority channel(s) it is currently receiving. `Dispose()` Close the channel. --- # Acoustic Echo Cancellation - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#acoustic-echo-cancellation) Acoustic Echo Cancellation ========================== Acoustic Echo Cancellation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#acoustic-echo-cancellation "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- When playing audio from speakers and recording audio from a nearby microphone you will often encounter problems when the microphone picks up the audio from the speakers. In a voice session a single person doing this can cause annoying echoes to be transmitted and multiple people doing this simultaneously can cause painful feedback which persists until everyone stops transmitting. This can be particularly problematic when using Voice Activation Detection (VAD) because the VAD automatically transmits back all speech it detects, causing constant echoes of everything other people say. It can also be very bad on platforms where the mic and the speaker are very close together such as VR headsets and mobile phones. Acoustic Echo Cancellation (AEC) is a system to automatically remove these echoes from the transmitted voice signal. How Does AEC Work?[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#how-does-aec-work "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------------------- Echo is caused by sound which leaves the speaker, bounces off some of the nearby environment and re-enters the mic. The AEC filter is attached the the audio mixer on the output, this filter knows what sounds are leaving the speakers and this knowledge can be used to detect and remove that echo in the microphone preprocessor: `Audio Output -> **Audio Postprocessor** -> Speakers -> Echo -> Microphone -> Audio Preprocessor` The most complex part of this system is working out what the delay is between the `Audio Postprocessor` and the `Audio Preprocessor`. This is achieved automatically but it is important to understand that the AEC system can take several seconds to work out the correct delay value - until it has done this no echo will be cancelled. The AEC cannot be calculating the delay value while there is no sound being played and it will slowly "forget" the delay value during long periods of silence. In most scenarios this is not a problem - game sound effects and background music will be enough to keep the AEC synchronised with a suitable delay value. However if you are encountering problems with the AEC not working you should consider adding some sound effects for the AEC to process - e.g. a short jingle when a user joins a session, or ringing sound when joining a session. AEC Setup[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#aec-setup "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------- ### 1\. Audio Postprocessor[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#1-audio-postprocessor "Permanent link") Attach the `Dissonance Echo Cancellation` audio filter to the very last [audio mixer](https://docs.unity3d.com/Manual/AudioMixer.html) in the mixing system and disable the `Auto Mixer Suspend` option for this mixer. If you were not already using audio mixers simply create a new mixer in `Window > Audio Mixer` and attach the filter to that. ![Audio Mixer With AEC Filter](https://placeholder-software.co.uk/dissonance/docs/images/AudioMixer_WithAecFilter.png) ### 2\. Route Non-Voice Audio[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#2-route-non-voice-audio "Permanent link") The filter will only process audio which passes through the mixer it is attached to - how to achieve this depends on what kind of audio mixing system you already had setup before using AEC. * If you were already using audio mixers: ensure that **all** the mixers eventually pass through the mixer with the `Dissonance Echo Cancellation` filter attached. * **If you were not already using mixers** then set **all** `AudioSource` components to output to the new mixer you created in the previous step. You can check that you have done this correctly by running the game and watching the audio mixer window. The dB meter on the mixer should move when non-voice audio is playing. ![Audio Source With Output Highlighted](https://placeholder-software.co.uk/dissonance/docs/images/AudioSource_OutputHighlighted.png) ### 3\. Route Voice Audio[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#3-route-voice-audio "Permanent link") Voice audio also needs to be re-routed to pass through the mixer with the filter attached. To change where voice audio is sent you need to create a custom [playback prefab](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Playback-Prefab.html) . Create a prefab with a `VoicePlayback` component and an `AudioSource` component. Set the output of the AudioSource to the correct mixer. Finally drop the prefab into the `Playback Prefab` field of the `Dissonance Comms` component. ![Playback Prefab With Output Highlighted](https://placeholder-software.co.uk/dissonance/docs/images/PlaybackPrefab_OutputHighlighted.png) If you were already using audio mixers then you may want to consider creating a mixer specifically for voice and outputting this mixer to the root mixer. This will allow you to attach sound effects specifically to voices. If you were not using audio mixers then you should just send the voice data to the mixer you created in step 1. ### 4\. AEC Configuration[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#4-aec-configuration "Permanent link") Now that all the audio is routed to pass through the filter AEC can run. Open the Dissonance quality settings menu `Window > Dissonance > Quality Settings` to set the amount of echo suppression applied. Desktop platforms and mobile platforms use different AEC systems internally and are configured separately. Dissonance will automatically switch to using the mobile AEC (AECM) when a mobile platform is detected. ![AEC Settings Inspector](https://placeholder-software.co.uk/dissonance/docs/images/AecSettings.png) These settings can be set in the editor - they will be saved into an asset and used as the default values at runtime. They can be changed at runtime by accessing the `VoiceSettings` class: `//Change amount of AEC applied on Desktop VoiceSettings.Instance.AecSuppressionAmount = AecSuppressionLevels.Moderate; //Change amount of AEC applied on Mobile VoiceSettings.Instance.AecmRoutingMode = AecmRoutingMode.Speakerphone;` Only the two settings shown above can be changed while Dissonance is running, doing so will trigger a reset of the audio input system (causing a small hitch in transmitted audio). Changes to any other AEC related settings will be ignored until the next time the audio input system is reset (e.g. by changing the settings above). You should start with low AEC settings and ask the user to increase them if echo becomes a problem - excessive levels of AEC can very badly distort voices. ### 5\. Testing AEC[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#5-testing-aec "Permanent link") Once you have set all of this up you may want to test that AEC is working as intended. To do so simply add an `AudioSource` component to your scene playing some loud music - make sure it's routed through the correct mixer! Now run the scene in the editor and select the filter attached to the audio mixer, this will show a status screen for the AEC: ![AEC Status Inspector](https://placeholder-software.co.uk/dissonance/docs/images/AecStatus.png) When the filter first starts all of the stats will be labelled as "initialising...", this indicates that the filter has not yet converged and will not yet be removing any echo. Once the AEC is running and has converged remote speakers in the session should not be able to hear the music you are playing. In our own tests we have had music playing loudly enough to drown out voices but even that was still cancelled! ### 6\. Other Improvements[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#6-other-improvements "Permanent link") AEC is **not** a perfect system and there will usually be some echo which is not cancelled out. Certain conditions such a high background noise or a very large delay (e.g. Bluetooth headphones/microphones) can make this much worse or even not work at all. Therefore it's important to have other mitigations to reduce the impact of bad echo. [Voice Ducking](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings#audio-duck-attenuation) automatically reduces the volume of received voices when voice is being transmitted. This reduces the chance of feedback occurring since incoming voices are quieter and less likely to be picked up by the mic. [Audio Ducking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Audio-Mixing#volume-ducking) can be set up in the Unity mixer to reduce the volume of all non-voice sounds when any voice audio is being received. Because the other sound effects are quieter this allows you to reduce the volume of all voices, reducing the chance of the mic recording them. [Background Sound Removal](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings#background-sound-removal) automatically removes non-voice sounds from the microphone signal. This cannot fix echoed voices, but it can improve other non-voice sounds that are recorded by the microphone. A [Low Pass Filter](https://docs.unity3d.com/Manual/class-AudioLowPassFilter.html) can be set up in the Unity mixer on the received voices, with a `Cutoff Frequency` of around 6000Hz. This is above the range of normal human speech. If the worst kind of feedback happens (very high pitched squealing) this will reduce the volume and prevent it from getting any worse. Fixing `Audio effect Dissonance Echo Cancellation could not be found.` Error (iOS)[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Acoustic-Echo-Cancellation.html#fixing-audio-effect-dissonance-echo-cancellation-could-not-be-found-error-ios "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ To fix this problem on iOS you must manually register the audio effect with the Unity audio pipeline. 1. Download `AudioPluginInterface.h` from [the Unity native audio plugin SDK](https://github.com/Unity-Technologies/NativeAudioPlugins) and add it to your XCode project. 2. add `#import "AudioPluginInterface.h";` to `UnityAppController.mm` in XCode. 3. Find the `preStartUnity` method and add the line `UnityRegisterAudioPlugin(&UnityGetAudioEffectDefinitions);` If this does not fix the issue, please add a comment to [this issue](https://github.com/Placeholder-Software/Dissonance/issues/80) . --- # Proximity Chat - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html#grid-proximity) Grid Proximity[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html#grid-proximity "Permanent link") ===================================================================================================================================== Grid proximity creates an infinite grid of cells, each cell can be though of as unique chat room. Players are automatically placed into all cells which are within range of their position. This means that only nearby players can be heard. Setup[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html#setup "Permanent link") ------------------------------------------------------------------------------------------------------------------- 1. Set up [position tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) , this tells Dissonance where players are. 2. Add a `Voice Proximity Broadcast Trigger` to the scene. This controls when voice will be **sent to**. Do **not** attach the proximity broadcast trigger to the player prefab! ![Voice Proximity Broadcast Trigger Inspector](https://placeholder-software.co.uk/dissonance/docs/images/ProximityBroadcastTrigger_Inspector.png) 1. Choose a `Chat Room` for this trigger. e.g. `"Red Team Proximity Chat"` 2. Choose a range, all other players within this distance will hear your voice. 3. Choose an `Activation Mode` which decides when voice should be transmitted. 4. Add a `Voice Proximity Receipt Trigger` to the scene. This controls when voice will be **received**. Do **not** attach the proximity receipt trigger to the player prefab! ![Voice Proximity Receipt Trigger Inspector](https://placeholder-software.co.uk/dissonance/docs/images/ProximityReceiptTrigger_Inspector.png) 1. Set the `Chat Room` to the same value as the broadcast trigger. 2. Set the range to **exactly the same value** as the broadcast trigger. Distance Attenuation[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html#distance-attenuation "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------- At the moment voices will cut off the moment they go out of range, with no fading in volume. A [Custom Playback Prefab](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Playback-Prefab.html) gives you control over the [`AudioSource`](https://docs.unity3d.com/6000.1/Documentation/Manual/AudioSource-reference.html) Dissonance uses for audio playback, including the Distance/Attenuation curve. Set the curve to fade to near zero volume at the same range as the proximity broadcast trigger. Debugging Common Errors[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Proximity-Chat.html#debugging-common-errors "Permanent link") ------------------------------------------------------------------------------------------------------------------------------------------------------- If proximity chat is not working, check through these quick debugging steps: * First, check that a normal (non-proximity) voice chat channel works to ensure that this is a problem with proximity chat! * Proximity chat relies on [position tracking](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html) being correctly set up. While the game is running with at least 2 players connected: * Check the tracking script, attached to your player is initialised * In the `DissonanceComms` inspector expand the player list. **Every** player should have `(Positional)` next to their name. * In the `DissonanceComms` inspector expand the player list, and expand the channels list for the local player. When transmitting locally, you should see some channels appear here (with the name you set for your proximity broadcast trigger). * Select the `Proximity Broadcast Trigger`, you should see a grid of rooms (drawn as gizmos, ensure gizmos are not hidden) with the rooms near the player highlighted as you move around. --- # Custom AudioSource Settings - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Playback-Prefab.html#prefab-components) Custom AudioSource Settings =========================== The playback prefab is how Dissonance plays the audio signal from each player. A copy of the prefab is instantiated for each player and then moved into the correct position for positional audio to work. Creating your own playback prefab allows you to customise the AudioSource settings used for voice or attach your own script to the prefab. To use a custom prefab drag the prefab into the `Playback Prefab` field on the [Dissonance Comms](https://placeholder-software.co.uk/dissonance/docs/Reference/Components/Dissonance-Comms.html) component inspector. If no prefab is set Dissonance will automatically use a default prefab. Prefab Components[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Playback-Prefab.html#prefab-components "Permanent link") -------------------------------------------------------------------------------------------------------------------------------------------- The playback prefab _must_ include a `VoicePlayback` component (part of Dissonance). You may also attach a Unity `AudioSource` component, in which case you can adjust some of the settings to change how voice will be played back. However, the following settings will be overwritten by Dissonance: * Loop * Pitch * Clip * Play On Awake * Mute Lifetime[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Playback-Prefab.html#lifetime "Permanent link") -------------------------------------------------------------------------------------------------------------------------- When writing your own scripts to attach to the playback prefab it is important to remember that the lifetime is managed entirely by Dissonance. Prefab instances are recycled to reduce the amount of garbage created. This means that your custom script attached to the prefab must be able to handle being re-assigned from one player to another. When there are no instances available to use, a new one is created: 1. Prefab instantiated 2. Default components added 3. Activated When the player for an instance leaves the prefab is recycled: 1. Deactivated 2. Stored in a pool of inactive instances When another player joins an instance is retrieved and re-used: 1. Retrieved from pool 2. Activated To handle this in your script simply use the normal [Unity lifecycle events](https://docs.unity3d.com/Manual/ExecutionOrder.html) : `void Awake() { // This only runs once. Use this to perform one-time setup. // e.g. Find some Dissonance components _playbackComponent = GetComponent(); _dissonanceComms = FindObjectOfType(); } void OnEnable() { // This runs every time the script is activated. Use this to perform per-player setup // e.g. find information about this player _playerState = _dissonanceComms.FindPlayer(_playbackComponent.PlayerName); } void Update() { // This will run every frame while the script is active } void OnDisable() { // This runs every time the script is deactivated. Use this to perform per-player cleanup // e.g. Remove the things which were initialised in OnEnable _playerState = null; }` --- # Finding Players - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Player-State.html#discovering-players) Finding Players =============== Dissonance offers an easy to use API for finding out information about other players in the session. Discovering Players[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Player-State.html#discovering-players "Permanent link") --------------------------------------------------------------------------------------------------------------------------------------------- There are two ways to discover who is in the Dissonance session - events and polling. To get a list of players currently in the session, you can access the `Players` property on the DissonanceComms object: `var comms = FindObjectOfType(); foreach (var player in comms.Players) { Debug.Log("Player " + player.Name + " is in the game"); }` This will give you a set of [VoicePlayerState](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html) objects (including one for the local player). These objects will stay valid forever and will be updated with new information as necessary. Dissonance also exposes some events which will get invoked when certain things happen, for example a new player joining the session. `var comms = FindObjectOfType(); comms.OnPlayerJoinedSession += player => { Debug.Log("Player " + player.Name + " Joined session"); } comms.OnPlayerLeftSession += player => { Debug.Log("Player " + player.Name + " Left session"); }` The `player` objects passed to the event handlers here are [VoicePlayerState](https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoicePlayerState.html) objects which expose a lot of useful data about the players such as if they are currently talking and a live readout of the amplitue. --- # Position Tracking - Dissonance Voice Chat [Skip to content](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html#setup-tracking) Position Tracking ================= Video See [this video](https://youtu.be/HXMYDbuLwVI?t=1179) about position tracking. This tutorial will explain how to configure your project to track the position of players. This is required for 3D positional audio playback of remote player voice chat and collider trigger support for `VoiceBroadcastTrigger` and `VoiceReceiptTrigger`. Setup Tracking[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html#setup-tracking "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------- To setup position tracking you need to attach a single behaviour to all your player gameObjects. The behaviour can be found in the folder for the network integration you are using, for example for HLAPI it is located at `Assets/Dissonance/Integrations/UNet_HLAPI/HlapiPlayer.cs`. Ensure that this component is attached to _all_ gameObjects in the scene which represent a player (the local player and all remote players). If you have a prefab which is used to construct your players you can simply attach the behaviour to this prefab. Some network integrations do not include player tracking scripts. In this case you will need to implement it yourself. View the documentation for custom position tracking [here](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Custom-Position-Tracking.html) . ![A Player Prefab with position tracking behaviour added](https://placeholder-software.co.uk/dissonance/docs/images/PlayerPrefab_PositionalAudio.png) ### What Does Position Tracking Cost?[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html#what-does-position-tracking-cost "Permanent link") Dissonance **does not send any extra data** across the network when position tracking is enabled - instead it relies on your game objects already being in the right place on every client and simply plays the audio from wherever they are in space. Enabling position tracking does not use any extra bandwidth. Using Position Tracking[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html#using-position-tracking "Permanent link") ---------------------------------------------------------------------------------------------------------------------------------------------------------- ### Positional Audio[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html#positional-audio "Permanent link") When positional audio is enabled the voice from remote players will sound like it is coming from the correct position. To enable this simply tick the "use positional data" checkbox on the voice broadcast trigger. ![A broadcast trigger with positional audio enabled](https://placeholder-software.co.uk/dissonance/docs/images/VoiceBroadcastTrigger_Positional.png) ### Collider Chat Room[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html#collider-chat-room "Permanent link") Voice broadcaster triggers and voice receipt triggers can be configured to only send/receive audio when the local player is inside a certain volume. See [this](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Collider-Chat-Room.html) tutorial for how to achieve this. ### Direct Transmit To Player[⚓︎](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Position-Tracking.html#direct-transmit-to-player "Permanent link") When position tracking is enable transmitting to a specific player is simplified. If a `Voice Broadcast Trigger` is attached to a player entity it can be configured to transmit to the player represented by the game object. See [this](https://placeholder-software.co.uk/dissonance/docs/Tutorials/Direct-Player-Transmit.html) tutorial for details. --- # Dissonance Voice Chat 404 - Not found =============== ---