# 4. Mute, Transmission, Volume and Roster Part of [[Voice Chat with Vivox]]. Back: [[3. Group Channels and Participants]]. Next: [[5. Hooking Vivox to Lobby Sessions]]. > [!warning] Code not compiled in Unity > APIs follow the official 16.12.1 Scripting API and the official mute / audio-level Manual pages (see the hub). The roster presenter has not been run in a UI Toolkit panel. ## 4.1 Mute yourself (recommended path) Official mute guide: two ways to mute the local user's input. **Preferred, all channels:** `VivoxService.Instance.MuteInputDevice()` and `UnmuteInputDevice()`. `IsInputDeviceMuted` reports the state. This is the toggle that belongs on a settings row or a headset A-button "push to mute" ([[Menus, Pause and Settings Flow]]). There is a matching `MuteOutputDevice` / `UnmuteOutputDevice` / `IsOutputDeviceMuted` for speaker output. **When you must pick a channel:** `SetChannelTransmissionModeAsync(TransmissionMode transmissionMode, string channelName = null)`. | `TransmissionMode` | Official meaning | |---|---| | `All` | Transmit into every channel the user is in | | `Single` | Transmit into `channelName` only | | `None` | Transmit into no channel | The official mute page says `TransmissionMode.None` can unify input settings with All/Single, but **best practice for "I'm muted"** is still `MuteInputDevice`. Use transmission when a user is in *two* channels (a classroom group and a staff-only group) and should speak into one of them. The 16.12.0 changelog fixed device mute/volume operations throwing `VivoxApiException` after logout because they still addressed the signed-out account. Do not call mute APIs after `LogoutAsync`. ## 4.2 Mute someone else (local only) `VivoxParticipant.MutePlayerLocally()` and `UnmutePlayerLocally()` stop **you** hearing that participant in **that** channel. Official remarks: to mute them in every channel you are both in, iterate `ActiveChannels` and mute each matching `PlayerId`. Other people in the channel still hear them. That is a "deafen this person for me" control, not a teacher "sit down and be quiet" control. A real class-wide mute is a **Command** to each student's `MuteInputDevice` — part 6. `BlockPlayerAsync(string playerId)` is a bidirectional block, not a moderation mute. Do not use it as "teacher mute." When checking whether a participant is in audio before you offer a mute button, use `IsInAudio` (16.12.1). It may be `false` for a moment after join; wait for `ParticipantAudioStateChanged` rather than showing a spurious error. ## 4.3 Volume, official range Official in-game audio-level page: volume values are **-50 to 50** on a logarithmic scale, **0** is +0 dB (no change). The usable range is generally **-10 to 25**. They do **not** recommend letting users raise capture above **25** (over-modulation, discomfort). | API | Affects | |---|---| | `SetInputDeviceVolume(int value)` | Local microphone, all channels | | `SetOutputDeviceVolume(int value)` | Local Vivox output, all channels | | `SetChannelVolumeAsync(string channelName, int value)` | Incoming audio from one channel | | `VivoxParticipant.SetLocalVolume(int volume)` | One participant, locally, in that participant's channel (`LocalVolume` to read back) | ## 4.4 A UI Toolkit roster Bind official participant events, not a per-frame poll of `ActiveChannels` (use the dictionary only to rebuild after a missed event or a UI rebuild). ```csharp using System; using System.Collections.Generic; using Unity.Services.Vivox; using UnityEngine; using UnityEngine.UIElements; /// <summary> /// Binds a UI Toolkit ListView to VivoxParticipant add/remove/speech/mute events. /// The ListView must exist in the UIDocument; this class does not invent UXML. /// </summary> public sealed class VivoxRosterPresenter : MonoBehaviour { [SerializeField] UIDocument document; [SerializeField] string listViewName = "roster"; readonly List<VivoxParticipant> _roster = new List<VivoxParticipant>(); ListView _list; void OnEnable() { _list = document != null && document.rootVisualElement != null ? document.rootVisualElement.Q<ListView>(listViewName) : null; if (_list == null) { Debug.LogWarning("VivoxRosterPresenter: no ListView named '" + listViewName + "'."); return; } _list.itemsSource = _roster; _list.makeItem = () => new Label(); _list.bindItem = BindRow; var channel = GetComponent<VivoxGroupChannel>(); if (channel != null) { channel.ParticipantAdded += OnAdded; channel.ParticipantRemoved += OnRemoved; } } void OnDisable() { var channel = GetComponent<VivoxGroupChannel>(); if (channel != null) { channel.ParticipantAdded -= OnAdded; channel.ParticipantRemoved -= OnRemoved; } for (var i = 0; i < _roster.Count; i++) Unsubscribe(_roster[i]); _roster.Clear(); } void OnAdded(VivoxParticipant participant) { if (participant == null) return; _roster.Add(participant); participant.ParticipantMuteStateChanged += OnRowChanged; participant.ParticipantSpeechDetected += OnRowChanged; participant.ParticipantAudioStateChanged += OnRowChanged; _list?.RefreshItems(); } void OnRemoved(VivoxParticipant participant) { Unsubscribe(participant); _roster.Remove(participant); _list?.RefreshItems(); } void Unsubscribe(VivoxParticipant participant) { if (participant == null) return; participant.ParticipantMuteStateChanged -= OnRowChanged; participant.ParticipantSpeechDetected -= OnRowChanged; participant.ParticipantAudioStateChanged -= OnRowChanged; } void OnRowChanged() => _list?.RefreshItems(); void BindRow(VisualElement element, int index) { var label = (Label)element; if (index < 0 || index >= _roster.Count) { label.text = string.Empty; return; } var p = _roster[index]; var state = p.IsMuted ? "muted" : (p.SpeechDetected ? "speaking" : "quiet"); if (!p.IsInAudio) state = "connecting"; var self = p.IsSelf ? " (you)" : string.Empty; label.text = quot;{p.DisplayName}{self} — {state}"; } public void MuteSelectedLocally() { if (_list == null || _list.selectedIndex < 0 || _list.selectedIndex >= _roster.Count) return; var p = _roster[_list.selectedIndex]; if (p.IsSelf) return; if (p.IsMuted) p.UnmutePlayerLocally(); else p.MutePlayerLocally(); } } ``` The em dash in the label is display text, not a filename. Hook a "mute for me" button to `MuteSelectedLocally`. Hook a "mute my mic" button to `VivoxService.Instance.MuteInputDevice()` — different verbs, label them so a teacher does not confuse the two. Next: [[5. Hooking Vivox to Lobby Sessions]].