Muting & Volume Control
This guide explains how to control the volume and mute state of an AudioInput
Volume Basics
The AudioInput0 and 2 (inclusive), or the special string 'muted':
| Value | Effect |
|---|---|
1 | Default volume (no change) |
0 – 2 | Scale capture volume (0 = silent, 2 = double) |
'muted' | Stops the underlying MediaStream entirely |
Setting the volume to 0 makes the audio silent but keeps the MediaStream active. The browser will continue to show its recording indicator (e.g. the red dot in the tab bar). Use 'muted' to fully stop the stream and dismiss the indicator.
Muting the Microphone
Simple Mute (Recommended)
The recommended way to mute is to set the volume to 'muted'. This stops the underlying MediaStream, which causes the browser to remove its recording indicator (e.g. the red dot in the tab or address bar):
This is the preferred approach for most applications. It provides clear visual feedback to the user that their microphone is no longer active.
Full Mute (Mute + Stop Encoder)
For additional resource savings, you can also remove the AudioInput Room
The order matters when unmuting: restore the volume before re-adding to the room. This ensures the encoder starts with the correct volume and the MediaStream is active when audio processing begins.
Comparison of Approaches
| Approach | Recording Indicator | Encoder Active | CPU Usage While Muted |
|---|---|---|---|
setVolume(0) | Visible | Yes | Normal |
setVolume('muted') | Hidden | Yes | Reduced |
setVolume('muted') + removeAudioInput | Hidden | No | Minimal |
Complete Example
Here's a complete toggle mute implementation using the full mute approach:
Framework Examples
React
Vue 3
Angular
Muting Remote Peers
In some scenarios you may want to locally mute a specific remote peer — for example, to let users silence someone in a crowded room. The ODIN SDK provides two complementary mechanisms for this on the RemotePeer
Setting Volume to Zero (Quick Mute)
The simplest way to mute a remote peer is to set their volume to 0. This silences their audio immediately on the client side:
setVolume accepts a number between 0 and 2, or a stereo tuple [left, right] for per-channel control. Setting the volume to 0 makes the peer inaudible but the audio server still sends their audio packets to your client.
Pausing Audio Outputs (Bandwidth-Saving Mute)
Each RemotePeer AudioOutputaudioOutputs array containing the AudioOutput has a pause() method that tells the audio server to stop sending audio packets for that stream, saving bandwidth while the peer is muted:
Calling pause() only stops the server from delivering packets to your client. The remote peer's audio is not affected for other participants in the room.
Recommended: Combining Both Approaches
For the best user experience, we recommend combining both methods. Set the volume to 0 for an instant local mute, and also pause the audio outputs to save bandwidth:
Muting All Remote Peers at Once
The Room AudioOutputsetVolume() method that works the same way but applies to all peers and their
When unmuting, make sure to both call resume() on the audio outputs and set the volume back to a non-zero value. Resuming without restoring the volume will cause the server to send packets that are still silenced locally.
Related
- Push to Talk — Implementing PTT using
volumeGatesettings - Working with Devices — Selecting and switching audio devices