Voice
constVoice:object
Defined in: client/api.d.ts:5236
Local player’s proximity voice chat settings: on/off, playback volume, hearing range and the push-to-talk binding.
Type Declaration
Section titled “Type Declaration”getActivationThreshold()
Section titled “getActivationThreshold()”getActivationThreshold():
number
Reads the voice-activation threshold.
Returns
Section titled “Returns”number
Level from 0 to 1.
getHearingRange()
Section titled “getHearingRange()”getHearingRange():
number
Reads the local hearing-range limit.
Returns
Section titled “Returns”number
Radius in world units, or 0 when the server’s range applies unreduced.
getInputDevice()
Section titled “getInputDevice()”getInputDevice():
string
Reads the chosen microphone.
Returns
Section titled “Returns”string
Its name, or an empty string for the system default.
getInputDevices()
Section titled “getInputDevices()”getInputDevices():
string[]
Lists the microphones voice can record from.
Returns
Section titled “Returns”string[]
Device names as the player would recognise them; empty when the game chooses the device itself.
getInputLevel()
Section titled “getInputLevel()”getInputLevel():
number
Reads how loud the microphone is right now, whether or not anything is being sent – the value to draw a level meter from and to tune the activation threshold against.
Returns
Section titled “Returns”number
Smoothed level from 0 to 1; 0 while no microphone is open.
getPushToTalkKey()
Section titled “getPushToTalkKey()”getPushToTalkKey():
string
Reads the push-to-talk binding.
Returns
Section titled “Returns”string
Canonical key name, e.g. “v”.
getPushToTalkReleaseDelay()
Section titled “getPushToTalkReleaseDelay()”getPushToTalkReleaseDelay():
number
Reads the push-to-talk release delay.
Returns
Section titled “Returns”number
Delay in milliseconds; 0 when transmission stops the moment the key is released.
getRange()
Section titled “getRange()”getRange():
number
Reads the server’s proximity range for talkers with no override of their own.
Returns
Section titled “Returns”number
Radius in world units.
getTier()
Section titled “getTier()”getTier():
number
Reads the voice tier this player is on.
Returns
Section titled “Returns”number
0 whisper, 1 normal, 2 shout.
getTransmitMode()
Section titled “getTransmitMode()”getTransmitMode():
"pushToTalk"|"voiceActivity"
Reads what opens the microphone.
Returns
Section titled “Returns”"pushToTalk" | "voiceActivity"
The current transmit mode.
getVolume()
Section titled “getVolume()”getVolume():
number
Reads the voice playback volume.
Returns
Section titled “Returns”number
Current gain, where 1 is unattenuated.
hasMicrophone()
Section titled “hasMicrophone()”hasMicrophone():
boolean
Checks whether a capture device opened for this session.
Returns
Section titled “Returns”boolean
False when the player has no working microphone, i.e. they are listen-only.
isEnabled()
Section titled “isEnabled()”isEnabled():
boolean
Checks whether voice chat is enabled for this player.
Returns
Section titled “Returns”boolean
True unless the player turned voice chat off.
isNoiseSuppressionEnabled()
Section titled “isNoiseSuppressionEnabled()”isNoiseSuppressionEnabled():
boolean
Checks whether noise suppression is on.
Returns
Section titled “Returns”boolean
True while background noise is being filtered.
isTalking()
Section titled “isTalking()”isTalking():
boolean
Checks whether the local player is speaking right now. The same state raises the voiceStart and voiceStop events.
Returns
Section titled “Returns”boolean
True while push-to-talk is open – held, or still inside the release delay – and the microphone is producing audio.
setActivationThreshold()
Section titled “setActivationThreshold()”setActivationThreshold(
level):void
Sets the voice-activation sensitivity: lower sends quieter speech, higher ignores more background noise. Clamped to 0..1.
Parameters
Section titled “Parameters”number
Microphone level, 0 to 1 on the scale getInputLevel reports, above which voice activation sends.
Returns
Section titled “Returns”void
setEnabled()
Section titled “setEnabled()”setEnabled(
enabled):void
Turns voice chat on or off. Off closes the microphone and playback devices and tells the server to stop relaying voice to this client.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Whether voice chat runs at all for this player.
Returns
Section titled “Returns”void
setHearingRange()
Section titled “setHearingRange()”setHearingRange(
range):void
Narrows how far this player hears others. Can only reduce the server’s range, since a talker beyond it is never relayed.
Parameters
Section titled “Parameters”number
Audibility radius in world units; 0 removes the local limit.
Returns
Section titled “Returns”void
setInputDevice()
Section titled “setInputDevice()”setInputDevice(
name):void
Chooses the microphone. A running microphone is reopened on the new device; a device that is no longer connected falls back to the default.
Parameters
Section titled “Parameters”string
A name from getInputDevices, or an empty string for the system default.
Returns
Section titled “Returns”void
setNoiseSuppression()
Section titled “setNoiseSuppression()”setNoiseSuppression(
enabled):void
Turns noise suppression on or off. It runs before the level is measured, so it also keeps steady noise from tripping voice activation.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Whether to filter background noise out of the microphone.
Returns
Section titled “Returns”void
setPushToTalkKey()
Section titled “setPushToTalkKey()”setPushToTalkKey(
key):void
Rebinds push-to-talk. Unknown key names throw.
Parameters
Section titled “Parameters”string
Case-insensitive key name, using the same names as Key.bind.
Returns
Section titled “Returns”void
setPushToTalkReleaseDelay()
Section titled “setPushToTalkReleaseDelay()”setPushToTalkReleaseDelay(
milliseconds):void
Sets how long transmission continues after push-to-talk is released, so letting go slightly early does not clip the end of a word. Muting, turning voice off and losing input focus still stop it at once.
Parameters
Section titled “Parameters”milliseconds
Section titled “milliseconds”number
How long to keep transmitting after the key goes up. Clamped to 0..2000.
Returns
Section titled “Returns”void
setTier()
Section titled “setTier()”setTier(
tier):void
Switches how far this player’s voice carries. A request: the server paces it, decides the radius, and may move the player itself.
Parameters
Section titled “Parameters”number
Voice tier: 0 whisper, 1 normal, 2 shout.
Returns
Section titled “Returns”void
setTransmitMode()
Section titled “setTransmitMode()”setTransmitMode(
mode):void
Chooses what opens the microphone. Switching closes whatever the previous mode had open. Unknown modes throw.
Parameters
Section titled “Parameters”"pushToTalk" | "voiceActivity"
pushToTalk sends while the key is held; voiceActivity sends whenever the microphone is louder than the activation threshold.
Returns
Section titled “Returns”void
setVolume()
Section titled “setVolume()”setVolume(
volume):void
Sets the playback volume of incoming voice. A game that plays voice through its own audio engine applies the same gain there.
Parameters
Section titled “Parameters”volume
Section titled “volume”number
Playback gain, where 1 is unattenuated. Clamped to 0..4.
Returns
Section titled “Returns”void