Voice
A game that joins a room has voice chat once its room turns voice on, with defineRoom({ voice: true }), and no other code. The room forwards each player’s microphone to every other player, or to those the game’s voice chat admits, as Who hears whom says. Every player starts every session silent: the player hears the others at once, and the room gets nothing from the player until they hold V or tap the microphone button. This page covers what the player controls, how a game shows who is speaking, and what the engine does to keep voice clear.
The microphone starts silent
Section titled “The microphone starts silent”Each session starts with the player’s microphone off, in every game and every room, as PC action games start a player on push to talk and the EU’s guidance for minors asks of a microphone. Nothing keeps a live microphone across a reload, a rejoin or a move to another game: what persists is the player’s voice mode and talk key.
- On a keyboard, the player holds V to talk, and the microphone button shows “Hold V”. The player can change the key in Settings, and open mic, the other voice mode, makes a press of the key turn the player’s microphone on and another turn it off.
- On a touch screen, a tap on the microphone button turns the player’s microphone on, and another turns it off.
- On any device, a tap or a click on the button turns it on and off, so a desktop player on push to talk can also leave it on.
The room stops the player sending when the page is hidden, and when the player leaves the room. A key held as the page loses the focus counts as let go.
A gamepad has no talk button yet. The engine has no gamepad bindings to check one against, so a button it took could also fire a game’s own use of it, and turn a microphone on by accident. It comes with the gamepad bindings the engine plans for 0.2.0.
When the microphone is asked for
Section titled “When the microphone is asked for”The engine asks the browser for the microphone at the player’s first press of the microphone button or talk key, never as the player joins. That press sends nothing: a browser that answers late never turns the player’s microphone on by itself, so the player presses again to talk. A browser that already allows the microphone for the site, as one that remembers the player’s answer does, needs no ask, and the player’s first press talks. A game with no room never asks.
A player who refuses still hears everyone else. The button shows “Mic blocked”. Once the player hears someone else, a one-line notice in the bottom-left corner says for ten seconds that the others cannot hear the player, and that Escape says how to fix it. A player alone in a room sees none, since nobody is missing the player’s voice. The Escape menu and the Microphone row in Settings say how to allow the microphone from the address bar’s site controls. When the player allows the microphone there, voice takes it with no reload, the next time the player presses.
What the player sets
Section titled “What the player sets”The Audio tab of the Settings panel holds the voice rows. The rows past Microphone show once the room opens voice.
| Row | Range | Default | What it changes |
|---|---|---|---|
| Microphone | On or off | Off | Whether the room gets the player’s voice while the player speaks, as a tap on the microphone button does. Off at the start of every session. |
| Voice mode | Push to talk, Open mic | Push to talk | What the player’s talk key does: held to talk, or pressed to turn the microphone on and off. Not shown on a touch screen. |
| Talk key | Any key the game leaves free | V | The key the player holds to talk, or under open mic presses. Not shown on a touch screen. |
| Microphone volume | 0 to 100 | 100 | The microphone’s level before it is sent. A live meter under it shows the level. |
| Noise suppression | On or off | On | The browser’s removal of steady noise, such as a fan. |
| Automatic gain | On or off | On | The browser’s leveling of the voice. It can change the system microphone level. |
| One row per player | 0% to 200%, and a mute button | 100% | How loud that player is to this player alone. Past 100% plays them louder. |
The meter under Microphone volume shows the microphone’s level while it is captured, and turns green while the room gets the player’s voice, so the player sees they are heard. Discord shows an input meter in its voice settings, and Roblox animates the microphone icon while the player speaks.
The voice mode and the talk key hold across visits and, in the player app, across games. The microphone’s on or off state does not: every session starts it off.
The two voice modes
Section titled “The two voice modes”Push to talk is the default. It sends while the player holds their talk key, and for 0.1 s after. A key that a text field or a button takes does not count, and the page does not hear a key while the browser tab is out of focus. After the player’s first press, the page keeps the microphone captured and sends nothing until the player holds the key, so the key sends at once.
Open mic makes a press of the talk key turn the player’s microphone on and another turn it off. While it is on, a gate sends the player’s voice while the player speaks and holds a quiet room back. It opens the moment the microphone’s level passes -60 dBFS, 20 ms early so the first sound goes through, and holds for 0.3 s after the last loud moment so pauses and quiet word endings go through. The threshold is fixed, and no row shows it. After the browser’s noise suppression, a pause between words measures about -79 dBFS and speech about -26 dBFS, so the gate sits well clear of both. A microphone turned on with the button runs through the same gate in either mode.
The device’s main input decides what the player sees, never the window’s size: a narrow desktop window keeps the key, and a touch screen shows neither the mode nor the key, since a tap on the button turns the microphone on and off.
A page that saved the older ungated open mic starts on push to talk like every older save, and keeps the gate’s lowest threshold, -80 dBFS, for when the player’s microphone is on; Reset audio moves it to the shipped threshold. A page saved before push to talk was the default, when every save held open mic and V, starts on push to talk and the game’s talk key; a mode or a key it saved that differs from those old defaults stays.
How the threshold was measured
Section titled “How the threshold was measured”Two players in one room, each page running the engine’s own gate on a steady tone from its microphone, the other page measuring what it plays after the room and the Opus codec. At -60 dBFS, a tone at -61 dBFS or quieter arrives as silence, 1 in 32,768, and a tone at -59 dBFS or louder arrives at its own level. A tone at -26 dBFS, speech after the browser’s gain control, arrives whole. The hosted room’s voice tests keep that check: speech passes, a quiet room at -70 dBFS does not, and the same quiet room passes at the lowest threshold.
The same -60 passed every sentence of a recorded speech test and the first 100 ms of 89 to 100% of them, where -50 cut into the quiet first sound of one sentence in five.
What the others do
Section titled “What the others do”| Product | Modes listed | Default | Where the player mutes | Notes | Source |
|---|---|---|---|---|---|
| Roblox | None: the microphone on or off | Open mic with a mute, on every device | A microphone icon in the fixed top-left controls, always on screen | A creator cannot hide or move it; SetCoreGuiEnabled covers other pieces. Green moves in the icon while the player speaks, a red slash while muted, and a speaker icon shows over others’ heads. |
Roblox help 4405807645972; the developer forum’s “Updated Experience Controls now live” |
| Fortnite | Open Mic, Push to Talk | Not published | The voice controls in the profile panel | Settings are saved to the Epic account. The proximity speaker HUD element is mandatory, and the HUD Controller device cannot hide voice. | Epic help a000084783; Epic’s HUD Controller device page |
| Valorant | Party: push to talk or voice activation. Team: push to talk only | Push to talk, U and V | Not listed | Riot support, Valorant voice chat troubleshooting | |
| Overwatch 2 | Push to Talk, Open Mic | Push to talk | The Social menu | Blizzard help 31694, behind a login: unconfirmed | |
| Apex Legends | Push to Talk (PC only), Open Mic | Push to talk on PC | Not listed | Its “Open Mic” is a threshold gate, with an Open Mic Record Threshold slider. | EA help, Apex voice chat; EA’s Apex accessibility page |
| Call of Duty | Push to Talk, Open Mic | Not listed; the PC key is V | Not listed | Open Mic Sensitivity runs 0 to 100. | Activision support, Black Ops Cold War accessibility |
| Rocket League | Open mic, with a Push to Talk checkbox | Open mic | Not listed | Epic help a202300000015902 | |
| Rec Room | Push-to-Talk, Always On | Not listed | Not listed | Rec Room’s help center: unconfirmed | |
| VRChat | Push to Talk, Toggle, Always On | Push to talk on iOS | The V key or the Quick Menu | A microphone threshold, 5% by default, and a HUD microphone icon the player can drag. | VRChat’s iOS platform FAQ; its 2025.2.1 and 2026.2.2 release notes |
| Call of Duty: Mobile | Toggle button, push to talk, always on | Muted | An always-visible HUD microphone button | Activision’s blog, October 2019 controls post | |
| Discord | Voice Activity, Push to Talk | Not listed | Not listed | Voice activity takes a slider or an automatic sensitivity, which Discord itself says cuts sentence ends. Its Social SDK defaults to -60 dB. | Discord support 211376518; Social SDK |
| Xbox and PlayStation 5 | None: an open mic with a mute | Open mic | The PS5 controller’s mute button; the Xbox headset’s button | Xbox offers a noise suppression switch. | Xbox Wire, 2022-09-07; PlayStation’s DualSense support |
| Browsers | Not a product with modes | Echo cancellation, noise suppression and automatic gain on | Not applicable | Opus sends no discontinuous transmission unless asked. | W3C mediacapture-main, on Opus DTX; RFC 7587 |
Eight products list exactly two modes, three list a mute only, and two list three; none lists an ungated open mic and a gated voice activity as separate choices. Of the gates that publish a default, Discord’s SDK sits at -60 dB and VRChat at 5%, about -29 dBFS if that share is linear, which VRChat does not document. The engine ships -60 dBFS, fixed rather than adaptive, since Discord’s automatic sensitivity cuts sentence ends.
The talk key
Section titled “The talk key”The talk key is the engine’s pushToTalk action in the game’s key table, on V, the key Valorant’s team voice and Roblox’s own push-to-talk example use:
- A game that binds V fails as its world is made, in development and in the room, with an error that names the game’s binding and the fix. The fix is to give the binding another key, move the talk key with
controls({ keys: { pushToTalk: ["KeyT"] } }), or drop it withcontrols({ keys: { pushToTalk: [] } }). That is the earliest a clash can be known, before any player presses V. The same check covers every key the game’s plugins bind, for an input, a command or a page action. - A game that drops the talk key leaves voice to the microphone button, and to a key a player chooses for themselves.
- A player’s own key replaces the game’s in Settings. The row refuses a key the game binds, naming whose it is, and keeps listening for another. A key the player chose in another game that this game binds stays the game’s here: the player talks on the game’s talk key, and the row says so.
The ability bar’s keys are its own prop, outside the key table, so the bar checks them itself as it mounts: a bar on the talk key throws in development, naming the same fixes, and logs the error in a deployed room. The player’s talk key never takes a key the bar holds, and the Talk key row refuses one.
The microphone button
Section titled “The microphone button”A game with voice shows the engine’s microphone button in the top-left corner, 44 px tall, on every device, beside the Menu button on a touch screen and before the performance overlay when it shows. The button shows what the microphone does now and how the player changes it, with their talk key named, as Valorant and VRChat name theirs. A tap or a click turns the microphone on and off, as the Microphone row does, the first asking the browser for it.
| State | Words on a keyboard | Words on a touch screen | What it means |
|---|---|---|---|
| Ready | Hold V | Not shown | Push to talk: silent until the player holds their key. |
| Talking | Talking | Not shown | The player holds their key: the room gets the player’s voice. |
| Live | Mic live, V to mute | Mic live, tap to mute | The player’s microphone is on. On push to talk the keyboard words say click. |
| Muted | Muted, V to talk | Muted, tap to talk | Off, with a red slash. A game with no talk key says click. |
| Asking | Allow the mic | Allow the mic | The browser is asking the player. |
| Blocked | Mic blocked | Mic blocked | The player, or the browser, refused it; the hover text says how to allow it. |
| No microphone | No mic found | No mic found | The browser found none. |
| Voice off for a phase | Voice off | Voice off | The game has voice off for now: slashed, and it takes no tap. |
| Development room | No voice in dev | No voice in dev | The development room runs no voice: it takes no tap. |
The player’s level fills the microphone in green while the room gets the player’s voice. With the Escape menu open, the button stays in its corner above the menu, so a player in a game that captures the cursor reaches it there. Roblox keeps its microphone in the same corner.
The button shows once the room opens voice, or once it says it runs none, as the development room does. It is the one place every player sees whether they are heard in every game, so a creator cannot hide or move it:
- Restyle it through the theme’s colours: the button takes the menu’s
--color-menu-surfaceand--color-menu-edge, and its own--color-voice-speakingfor the level and--color-voice-mutedfor the slash. A game sets them on:rootin its stylesheet, as the menus take theirs. - Remove it by leaving voice off for the game, as every game is until its room sets
voice: true, as Turning voice on and off says. The page then asks for no microphone, shows no voice rows and draws no button. - Start players on open mic with
defaultVoiceMode={VoiceMode.OpenMic}onGame, besidedefaultVolumes. The player’s microphone still starts off: open mic changes what the key does, not whether the player starts heard. A mode the player saved on this device keeps its value, and Reset audio returns to the game’s.
<HideSetting setting="microphone" /> hides the voice rows in Settings and leaves the button.
Drawing a game’s own microphone button
Section titled “Drawing a game’s own microphone button”useVoice holds the player’s microphone as the engine’s button reads it, and a game reads it to draw its own:
muted: whether the player’s microphone is off. It istrueat the start of every session.pushing: whether the player holds their talk key now.armed: whether the player has pressed their talk key this session, which keeps the player’s microphone captured.microphone: whether the room takes the player’s microphone at all.
useVoiceSession‘s access says what the browser answered, talking whether the room gets the player’s speech now, and off whether the game has voice off. useSettings’ voiceMode and pushToTalkKey say what the player’s key does and which key the player chose. useVoice is read-only: no call a game makes turns a player’s microphone on, since only the player’s own press may. A game’s own button sends the player to the engine’s, or to Settings, to turn it on.
What the other engines give a creator
Section titled “What the other engines give a creator”| Engine | Starts silent | Push to talk | What a creator controls |
|---|---|---|---|
| Spawnite | Every session, on every device, for every game | V, the engine’s pushToTalk action; open mic as a setting; a tap on the button on touch |
Move or drop the key with controls(), start on open mic, restyle the button, turn voice off |
| Roblox | Voice is off until the player opts in, after an age check | None built in: AudioDeviceInput.Muted toggled from a creator’s input, V in Roblox’s own example |
Turn voice on or off per experience, and mute a player’s AudioDeviceInput from a server script |
| Unity with Vivox | The developer’s choice | The developer’s own: SetChannelTransmissionModeAsync and MuteInputDevice |
Everything, since the developer builds the controls |
| Unreal with EOS | The developer’s choice | The developer’s own: the player controller’s StartTalking, StopTalking and ToggleSpeaking |
Everything, since the developer builds the controls |
| Godot | No voice is built in | No voice is built in | Not applicable |
Unity, Unreal and Godot leave the default to each game. Roblox, a platform whose players move from game to game as this one’s do, decides it once for every experience, and so does this engine: a player knows in every game that they are silent until they press. Two controls the others give are left out: a creator cannot start players with a live microphone, and cannot turn one on from code, since either would take the choice from the player.
Turning voice on and off
Section titled “Turning voice on and off”A game has no voice until it turns voice on for the whole game, and it can turn voice off for a phase of play, such as a match where only the lobby talks. The room enforces both: a page that keeps sending reaches nobody.
For the whole game
Section titled “For the whole game”Set voice: true in the game’s defineRoom. Voice is off until then, as Roblox leaves voice to each experience’s own settings, since a card game or a lobby wants none:
import { defineGame, defineRoom } from "@spawnite/engine/core";
export const game = defineGame({ name: "talking-party", start: "lobby", room: defineRoom({ maxPlayers: 8, voice: true }),});spawnite build writes voice: true into the bundle’s manifest, so the store page can say the game has voice and the platform hands each seat its voice. A game that leaves it out starts no voice, and no page asks for the microphone, loads voice’s code, opens voice’s connection or draws the microphone button.
For a phase of play
Section titled “For a phase of play”Call setVoice(step, { enabled }) from an authoritative system. The following plugin keeps voice on in the lobby and off while a match plays:
import { createQuery, definePlugin, setVoice, type AuthoritativeStep, defineSystem, Phase,} from "@spawnite/engine/core";import { MatchMachine, MatchTrait } from "@spawnite/engine/matches";
const playing = createQuery(MatchTrait, MatchMachine.is.playing);
/** Voice in the lobby alone: off while a round plays, on between rounds. */function voiceInLobby(step: AuthoritativeStep) { const world = step.world; setVoice(step, { enabled: world.queryFirst(playing) === undefined });}
export const lobbyVoice = definePlugin(() => ({ name: "lobby-voice", // No runsOn: voice is the room's call, and a game played alone has none. systems: [ defineSystem({ name: "voiceInLobby", phase: Phase.Rules, run: voiceInLobby, }), ],}));When voice turns off, the room pauses every microphone, including one that is speaking, and tells each page. Each page stops capturing the microphone and shows voice as off: the microphone button shows a slash and takes no tap, and the Microphone row in Settings says voice is off for now. A player who joins while voice is off joins with it off. When voice turns on again, each microphone comes back only where its player has it on, so a player who never pressed, or who muted while voice was off, stays silent. Neither control turns a microphone on.
Calling setVoice every step with the same value changes nothing; the room tells the pages only when the value changes. A predicted system cannot call it: the type refuses its step, since a predicted system runs again on the page after a correction. In a game whose room sets voice: false, voice stays off in every phase. A checkpoint keeps the phase, so a recording continues across the change.
Reading voice’s state in a view
Section titled “Reading voice’s state in a view”useVoiceSession’s off says why voice is off, so a game’s own HUD can show it:
VoiceOff.Gamein a game whose room setsvoice: false.VoiceOff.Phasewhile a system has voice off.nullwhile voice runs, and outside a room.
No voice hook throws in a game with voice off. useVoice, useSpeaking and usePlayerVoice read as in a room where nobody speaks.
The spawnite upgrade entry microphone-starts-silent lists what a game that drew its own microphone button changes.
What the other engines give
Section titled “What the other engines give”| Engine | Off for the whole game | Off for a phase |
|---|---|---|
| Spawnite | defineRoom({ voice: false }) |
setVoice(step, { enabled: false }), for every player at once |
| Roblox | Turn voice off in the experience’s Communication settings | Per player, by muting each player’s AudioDeviceInput from a server script |
| Unity with Vivox | Do not join a voice channel | Leave the channel, or mute each player’s transmission |
| Unreal with EOS | Do not create a voice room | Leave the room, or mute each player |
| Godot, PlayCanvas | No voice is built in | No voice is built in |
setVoice is one call for the whole room, because the common case, voice in the lobby alone, is for everyone. Silencing chosen players, such as the eliminated in a match, is a send rule of the game’s voice chat, as Who hears whom says.
Who hears whom
Section titled “Who hears whom”A game with voice gets one flat all channel, every player heard by every other at full volume. A game that wants more exports a voice chat from src/game.ts, made with defineVoiceChat, and re-exports it from its room’s scene file, as textChat is. The room runs the chat’s channels and rules on the world after its steps, and forwards each speaker’s microphone only to the listeners a channel admits. A listener no channel admits receives no packet of that speaker.
Channels
Section titled “Channels”A channel is a set of listeners a speaker reaches:
voiceChannel(options)reaches every player in the room, or those itscanReceiveadmits.teamVoiceChannel(options)reaches the speaker’s teammates, by the team question thatteams()answers. A room whose voice chat holds a team channel and whose game lists no plugin that answers the team question fails to start, namingteams().proximityon either places each voice where its speaker stands and fades it with distance. Left out, the channel plays flat: full volume, from no direction.
The following voice chat gives a survival game its group at any distance, and anyone nearby:
import { defineVoiceChat, teamVoiceChannel, voiceChannel,} from "@spawnite/engine/core";
/** A survival game's voice: the player's group at any distance, and * anyone nearby, placed where they stand and fading out by 35 m. A * teammate a few metres away is heard once, at the group's full volume, * from where they stand. */export const voiceChat = defineVoiceChat({ channels: { nearby: voiceChannel({ proximity: { maxDistance: 35 } }), group: teamVoiceChannel(), },});A channel’s name holds at most 64 characters, and a voice chat holds at least one channel. A scene file that exports a voice chat in a game whose room leaves voice off fails to start, naming defineRoom({ voice: true }).
One rule for every pair
Section titled “One rule for every pair”The room asks each channel whether it admits a pair of players, and the listener hears the speaker once, at the highest volume any admitting channel gives. The listener hears the speaker from the speaker’s side where any admitting channel is a proximity channel. A channel admits a pair when every one of the following holds:
- The speaker is not the listener, and neither is a bot.
- The game’s
canSendand the channel’s own let the speaker talk. - On a team channel, the two are teammates.
- The game’s
canReceiveand the channel’s own admit the pair. - On a proximity channel, both have a presence, and the distance between them is under
maxDistance.
Above every channel, a block holds both ways: once either player blocks the other, from text chat or the player app, no channel routes the pair, and no game’s rule can undo it.
A speaker talks on every channel that admits the speaker at once, as Unreal’s TransmitToAllChannels does, so a private channel inside a public one needs the public channel’s canSend to refuse those players for that phase. A route names the loudest channel, and the first declared on a tie.
Proximity
Section titled “Proximity”proximity: true takes every default, and an object changes any of them:
| Option | Default | What it changes |
|---|---|---|
minDistance |
5 m | Within it, the speaker plays at full volume. |
maxDistance |
35 m | At it and past it, the speaker is silent, and the room forwards nothing. |
attenuation |
VoiceAttenuation.Inverse |
The curve between the two: Inverse, Linear, None, or a list of { distance, volume } points. |
At the defaults the inverse curve gives 0.42 at 10 m, 0.22 at 15 m and 0.07 at 25 m, as a voice falls off in a room, shifted to reach silence at maxDistance with no cliff. Linear falls in a straight line, and None holds full volume until maxDistance. A points list runs in straight lines between its points, holds the first point’s volume before it and the last point’s after it, and takes no minDistance. A pair whose volume is 0 is not routed.
The distance runs between the two players’ presences, the entities that stand for them in the world, so a third-person camera does not make everyone quieter. The direction is the speaker seen from the listener’s camera. A player with no presence, such as a spectator, is neither heard nor hears on a proximity channel, and flat channels still reach them.
defineVoiceChat throws, naming the channel, for each of the following:
- A distance that is negative or not finite.
- A
minDistanceabovemaxDistance, or of 0 on the inverse curve. - A points list that is empty, out of order, repeats a distance or holds a volume outside 0 to 1.
Rules and assigned audiences
Section titled “Rules and assigned audiences”canSend(world, speaker) returns true, false, or the words the player’s microphone button shows, such as “Only the dead talk now”. canReceive(world, speaker, listener) returns whether the listener hears the speaker. Both read the world as the last step left it and write nothing. The game’s own rules on defineVoiceChat run before each channel’s.
An audience the game assigns, such as a court, a radio frequency or the dead, is a trait the game’s authoritative systems write and a rule reads. The following voice chat gives each court its own placed voice at full volume, beside anyone nearby:
import { addTrait, definePlugin, defineTrait, defineVoiceChat, Reach, readTrait, setTrait, VoiceAttenuation, voiceChannel, type EntityAuthority, type PlayerEntity,} from "@spawnite/engine/core";
// 2v2 courts in a park: a court's four players hear each other placed and// at full volume, and anyone nearby is heard fading. Courts are not teams:// red and blue repeat on every court.
/** The court a player plays on, or -1 for none: the game's authoritative * systems write it, and the voice chat reads it. */export const CourtTrait = defineTrait( "court", { court: -1 }, { reach: Reach.Authority },);
/** Gives each player a court of none as they join, since `setTrait` * refuses a trait the player does not hold. */export const courts = definePlugin(() => ({ name: "courts", onPlayerJoin: ({ step, player }) => addTrait(step, player, CourtTrait),}));
/** Seats `player` on `court`, or on none with -1. */export function seatOnCourt( writer: EntityAuthority, player: PlayerEntity, court: number,) { setTrait(writer, player, CourtTrait, { court });}
export const voiceChat = defineVoiceChat({ channels: { court: voiceChannel({ canReceive: (_world, speaker, listener) => { const court = readTrait(speaker, CourtTrait)?.court ?? -1; return ( court >= 0 && court === readTrait(listener, CourtTrait)?.court ); }, proximity: { maxDistance: 40, attenuation: VoiceAttenuation.None }, }), nearby: voiceChannel({ proximity: true }), },});The dead who hear everyone, while the living never hear the dead, take one rule for the whole chat:
import { defineTrait, defineVoiceChat, hasTrait, Reach, type PlayerEntity,} from "@spawnite/engine/core";
/** Marks a player who died this round: the game's authoritative systems * add it and take it away. */export const DeadTrait = defineTrait("dead", {}, { reach: Reach.Authority });
const isDead = (player: PlayerEntity) => hasTrait(player, DeadTrait);
/** The dead hear everyone, and the living never hear the dead. */export const voiceChat = defineVoiceChat({ canReceive: (_world, speaker, listener) => !isDead(speaker) || isDead(listener),});A receive rule that throws refuses the pair it ran for on every channel, and a send rule that throws refuses the speaker on every channel. The development room throws an error that names the rule and the channel; a deployed room logs it once a minute for each rule and runs on.
When a change reaches the players
Section titled “When a change reaches the players”A speaker who talks now is routed after every step, so a team change or a step out of range stops the speaker’s voice on that tick. The room routes every other speaker ten times a second, since a silent speaker sends nothing to leave.
Testing who hears whom
Section titled “Testing who hears whom”readVoiceRoutes(world, voiceChat) answers who the game’s voice chat lets hear whom and how loud, from the function the room runs: the game’s routing, before a block and each listener’s own mutes. Each route names its speaker, listener and channel, its volume from 0 to 1 before the listener’s own controls, and isPlaced. It is exported from @spawnite/engine/core and @spawnite/engine/testing, so a game’s own test proves its routing headless:
// @vitest-environment nodeimport { expect } from "vitest";import { createTransform, requireAuthority, setPresence, spawn, TransformTrait, type PlayerEntity,} from "@spawnite/engine/core";import { addPlayer, it, readVoiceRoutes, type WritableWorld,} from "@spawnite/engine/testing";import { courts, seatOnCourt, voiceChat } from "./voiceCourts";
// Who hears whom on the courts, headless, from the function the room// runs: the Voice page shows this file whole, as a game's own test.
const test = it.extend("plugins", () => [courts()]);
/** Stands `player` `x` metres along the park, once the next step commits * the player's presence. */function standAt(world: WritableWorld, player: PlayerEntity, x: number) { const body = spawn(requireAuthority(world), { traits: [TransformTrait(createTransform({ position: [x, 0, 0] }))], }); setPresence(requireAuthority(world), player, body);}
test("a court hears itself, and not the next court", ({ world, step }) => { // Two courts 100 m apart, four players on each, a metre between them. const players = [0, 0, 0, 0, 1, 1, 1, 1].map((court, index) => { const player = addPlayer(world, { name: `Player ${index}` }); standAt(world, player, court * 100 + index); seatOnCourt(requireAuthority(world), player, court); return player; }); step();
const routes = readVoiceRoutes(world, voiceChat); const route = (speaker: PlayerEntity, listener: PlayerEntity) => routes.find( (each) => each.speaker === speaker && each.listener === listener, );
expect(route(players[0], players[3])).toMatchObject({ channel: "court", volume: 1, isPlaced: true, }); expect(route(players[0], players[4])).toBeUndefined();});
test("hears a stranger on the next court nearby, fading, once they stand within 35 m", ({ world, step,}) => { const [ada, bea] = [0, 1].map((court) => { const player = addPlayer(world, { name: `Player ${court}` }); seatOnCourt(requireAuthority(world), player, court); return player; }); standAt(world, ada, 0); standAt(world, bea, 20); step();
const [route] = readVoiceRoutes(world, voiceChat);
expect(route).toMatchObject({ channel: "nearby", isPlaced: true }); expect(route.volume).toBeLessThan(0.2);});It proves the game’s routing, not the transport: the development room runs no voice, so a playtest on the platform hears the result.
Reading voice in a dump
Section titled “Reading voice in a dump”spawnite simulate and spawnite play dump show a game’s voice, so you check who hears whom with the commands you already run. They show it only where the game’s room turns voice on:
spawnite simulateprints oneVoice:line for each route above the dump, such asVoice: 12 hears 7 on nearby at volume 0.417, placed., and its--jsonholds the routes undervoice.routes. A simulation joins one player, so it shows a route only where your scene adds a second player.spawnite play dump, in a room game, holdsvoicefrom the room:isEnabled,routes, read on the room’s world, andconnections, each player’s voice as the room holds it. Where the dump cannot hold the room’s voice, as while the page shows the room’s past, a line under it andvoiceNotein its--jsonsay why.
Each route names its speaker and listener by dump key, its channel, its volume to three significant figures and isPlaced, as readVoiceRoutes reads them. The routes sort by speaker, then by listener, so two dumps of one world compare line by line. While a system has voice off with setVoice, isEnabled reads false, simulate says so in a line above the routes, and the room forwards none of them. This dump comes from a playtest of a game with one proximity channel, nearby, played by the page’s player and two bots, with Bot 1 moved 20 m away. It shows two routes and one connection:
{ "voice": { "isEnabled": true, "routes": [ { "speaker": "31598401", "listener": "82157730", "channel": "nearby", "volume": 0.118, "isPlaced": true }, { "speaker": "82157730", "listener": "108874466", "channel": "nearby", "volume": 1, "isPlaced": true } ], "connections": [ { "player": "31598401", "name": "Bot 1", "state": "unavailable", "reason": "no-media-server" } ] }}Each connection names its player by dump key, its name, its state and, where the state alone does not say why, its reason:
state |
What it means |
|---|---|
unavailable |
The room runs no media server: no-media-server in the development room or a room whose media server did not start, or media-server-stopped. |
none |
The player has no voice to open: no-voice-ticket for a seat the platform gave none, or not-opened for a page that has not opened voice. |
waiting |
The player app has not opened the seat’s voice yet, or opened one that ended: resume-expired or seat-replaced. |
connected |
The room speaks to the player app. |
reconnecting |
The voice socket dropped and the room holds the voice 15 seconds for a resume, or a transport lost its connection: transport-disconnected. |
failed |
A transport failed: transport-failed. |
left |
The player left voice. |
Once a player’s voice is open, the connection also holds send and receive, each transport’s state, and isSending, whether the microphone reaches the room. A transport reads idle until the player app first uses it: the receive transport as the first voice reaches the player, the send transport as the microphone first sends. It then reads connecting, connected, disconnected, failed or closed.
The open connection also holds transport, how the player app reaches the room, as the app reports the route each transport took:
transport |
What it means |
|---|---|
direct-udp |
Straight to the room over UDP. |
direct-tcp |
Straight to the room over TCP, on the room’s own port, as on a network that blocks UDP. Either transport on TCP makes the player’s. |
relay |
Through the relay, for a network that lets neither through. Either transport on the relay makes the player’s, and relayedBytes holds the bytes the room sent the player through it. |
none |
The app has reported no route yet: no transport has connected. |
The development room runs no media server, so every player there reads unavailable, and the routes are the part of the dump to check. A room the platform hosts holds the same read, and no tool reaches it from your machine yet.
What the other engines give
Section titled “What the other engines give”| Engine | Who hears whom | Distance |
|---|---|---|
| Spawnite | Channels a game declares, with send and receive rules; a speaker heard once, at the loudest admitting channel | minDistance, maxDistance and a curve on any channel |
| Roblox | AudioDeviceInput access lists, set by server scripts |
Custom curves on AudioEmitter |
| Unity with Vivox | Channels a client joins: group, echo or positional | Channel3DProperties: conversational and audible distance, a fade model |
| Unreal VoiceChat | JoinChannel, positional or not; a speaker on every channel joined, heard once per channel |
MinDistance, MaxDistance and an attenuation model |
| Fortnite | Island scope Team, All or None | Full-volume and falloff distances, three curves |
The room decides who hears whom, as Roblox’s server scripts do, rather than each client joining channels, so a modified page cannot listen to a channel it was not given. A listener hears each speaker once, as Vivox does on flat channels and Unreal does not, which halves a phone’s decoding where two channels admit a pair.
In the player app
Section titled “In the player app”In the player app, the app owns the microphone, the playback and the voice panel, outside the game’s frame. The room tells the app each route’s volume in whole decibels, and the page tells the app where each placed speaker stands from its camera, at most 30 times a second while a placed voice plays. A game reads who speaks through useSpeaking, among the players its player hears. openVoicePanel({ player }) opens the app’s panel, at that player’s row where one is given, and does nothing outside the app.
The app draws the microphone button in the top-left corner, with the names of whoever is speaking under it. Its arrow, a long press on a phone, the menu’s Voice and openVoicePanel open the panel. The panel holds what the engine’s Settings rows hold outside the app, and more:
- Join voice, Leave voice and Listen only. Leave closes voice both ways until Join. Listen only keeps the player hearing and refuses every talk, from the game’s forwarded key and from the app’s own button.
- The microphone and the talk method. On a keyboard the page forwards the player’s talk key, V unless the player or the game picks another, and the app takes it once the player’s own press of its button armed it. On a phone under push to talk, the app draws its own Hold to talk button beside the microphone.
- The input. The microphone the player picks, its live level, noise suppression, automatic gain and its volume.
- What the player hears. The voice volume and Deafen.
- Each player heard. A speaking mark, a mute, a volume from 0% to 200%, Block and Report.
The iOS and Android apps listen only for now: their players hear voice and talk from a browser. A game changes none of these. Its defaultVoiceMode and defaultVolumes.voiceVolume apply where the player saved nothing.
Showing who is speaking
Section titled “Showing who is speaking”useSpeaking(player) returns whether a player is speaking, given their player entity: a player who controls nothing speaks too, since their voice belongs to the player and not the character. usePlayerByPresence(character) finds the player whose character a mark hangs over. The page’s own player counts while their microphone sends speech; another player counts while this page plays their speech. It turns on with the first word and stays on for 0.3 s after the last, so a mark drawn from it does not flicker between words.
import type { Entity } from "@spawnite/engine/core";import { Icon, useSpeaking } from "@spawnite/engine";
function SpeakingMark({ player }: { player: Entity }) { const speaking = useSpeaking(player); return speaking ? <Icon name="mic" className="size-3.5" /> : null;}Holdfast draws it beside each warden’s name in its scoreboard.
Each player’s volume
Section titled “Each player’s volume”Each other player’s row, under People on the Audio tab of Settings, runs from 0% to 200%, and starts at 100%, which plays them as they send. Past 100%, the row adds up to 6 dB, so 200% plays a quiet player at about twice their amplitude. The mute button beside it silences them for this player alone. Discord’s per-user slider has the same range and curve, and Roblox’s per-player volume runs from 0 to 2. The rows last as long as the page is in the room, since a player’s key names someone else in the next room.
The Voice volume row in Settings sets every voice at once, on the same 0% to 200% scale, and the two multiply.
A game that draws its own player list reads the same values beside each name with usePlayerVoice(player), given that player’s entity: isHeard, volume and isMuted, and one verb, mute. A game cannot unmute a player or set a volume, because that could undo the player’s own choice: only Settings does. The sample below is a mute button for such a list:
import type { Entity } from "@spawnite/engine/core";import { Button, Text, usePlayerVoice } from "@spawnite/engine";
/** A mute button beside a player's name in a game's own player list, * shown while the local player hears them. Unmuting is the player's * own, in Settings. */export function VoiceMute({ player }: { player: Entity }) { const { isHeard, isMuted, mute } = usePlayerVoice(player); if (!isHeard) return null; return isMuted ? <Text>Muted</Text> : <Button onPress={mute}>Mute</Button>;}The page plays each voice through a gain of its own on the page’s audio context, then through one limiter so a boosted voice never clips, as LiveKit’s Web Audio mix does. An audio element still plays each voice, muted, because Chrome hands a remote WebRTC stream to Web Audio only while an element plays it. Desktop Chrome’s echo cancellation hears Web Audio’s output as it hears an element’s. A page with no Web Audio plays the element itself, up to 100%.
useVoice holds the player’s microphone, which the player’s presses write and a game reads, as Drawing a game’s own microphone button says. useVoiceSession holds the rest of voice as it runs: the browser’s answer about the microphone, who is speaking, and the player’s volume for each other player.
Voice in development
Section titled “Voice in development”Voice runs on the platform: the rooms a published game plays in forward each player’s microphone. The development room, which spawnite play runs on your machine, runs no voice. It tells each page so, and the page asks for no microphone. The Microphone row in Settings says that voice runs when the game plays on the platform, and useVoiceSession’s unavailable reads true. Both ways to turn voice off work in the development room: off reads as it would on the platform, and the microphone button shows voice as off while a system has it off.
A game’s code needs nothing for this. useVoice, useVoiceSession and useSpeaking work as in any room where nobody speaks: the room never opens voice, nobody is heard, and nobody is speaking.
How the engine keeps voice clear
Section titled “How the engine keeps voice clear”The engine sends Opus in mono at up to 24 kbit/s in 20 ms packets, which keeps a room’s bandwidth low. Three settings keep it clear on a real network:
- In-band forward error correction is on. Each packet carries a rough copy of the one before, so a lost packet is rebuilt rather than guessed. This is the browser’s own default, which the room’s answer used to turn off.
- Discontinuous transmission is on. A silent microphone sends one small packet every 400 ms instead of 50 a second.
- Each player’s audio starts with at least 120 ms in the receiving page’s jitter buffer. WebRTC starts it at 80 ms and lets it shrink to about 20 ms on a quiet link, so the first late packets stutter while it grows back; with stalls of 60 to 120 ms in the first seconds, the floor keeps the first sentence as clear as on a clean link.
The browser’s echo cancellation is always on, so a player on speakers does not send the others their own voices back.