Audio
constAudio:object
Defined in: server/api.d.ts:3308
Replicated sound. A sound is a Wwise event NAME — every event the game ships (~6,300, e.g. “cabbage_explosion”, “UI_Menu_Select”, “Amb3D_Storm_ThunderClaps_Play”) works out of the box, and custom banks dropped in Phoenix/Content/WwiseAudio/Windows/ work once loadBank() names them. Posting an event whose bank isn’t resident is silently inaudible.
Type Declaration
Section titled “Type Declaration”dialoguePolicy
Section titled “dialoguePolicy”
readonlydialoguePolicy:DialoguePolicy
Whose native spoken lines every client lets through (see setDialoguePolicy). Each speaker reads true (every line, the default), “nonverbal” or false.
mutedEvents
Section titled “mutedEvents”
readonlymutedEvents:string[]
The Wwise events every client refuses to play (see setMutedEvents), lowercased.
bankFor()
Section titled “bankFor()”bankFor(
event):string
The soundbank this event needs loaded, from the cooked assets’ own RequiredBank. Clients load it automatically when a post is refused, so this is for diagnostics and preloading.
Parameters
Section titled “Parameters”string
Wwise event name.
Returns
Section titled “Returns”string
The bank name, or “” for an unknown event.
clearMusic()
Section titled “clearMusic()”clearMusic(
event):void
Pops a track off the music stack, starting whatever was under it. It cannot restore state-driven score, and the name stays blocked for the session.
Parameters
Section titled “Parameters”string
The event name passed to setMusic.
Returns
Section titled “Returns”void
loadBank()
Section titled “loadBank()”loadBank(
bank):void
Loads a soundbank on every client; clients that aren’t in-world yet retry until they are.
Parameters
Section titled “Parameters”string
Soundbank name, without the .bnk extension.
Returns
Section titled “Returns”void
playSoundAt()
Section titled “playSoundAt()”playSoundAt(
event,x,y?,z?,options?):number
Plays a spatialized one-shot at a world position on every client in range.
Parameters
Section titled “Parameters”string
Wwise event name (case-insensitive).
number | Vector3Like
World-space X coordinate.
number
World-space Y coordinate.
number
World-space Z coordinate.
options?
Section titled “options?”range = cm within which clients are sent the post (default 10000, 0 = everyone); bank = soundbank to load first; duration = seconds until it ends itself; stopEvent = authored terminator posted when it ends; virtualWorld and map = only the players in that world of that map hear it, map being a player.location().areaId (left out, every player in range does, whatever their world).
string
duration?
Section titled “duration?”number
string
range?
Section titled “range?”number
stopEvent?
Section titled “stopEvent?”string
virtualWorld?
Section titled “virtualWorld?”number
Returns
Section titled “Returns”number
A sound id for stopSound, or 0 when the event name was empty.
playSoundForAll()
Section titled “playSoundForAll()”playSoundForAll(
event,options?):number
Plays a sound at every connected player’s listener, wherever they are.
Parameters
Section titled “Parameters”string
Wwise event name.
options?
Section titled “options?”bank = soundbank to load first; duration = seconds until it ends itself; stopEvent = authored terminator posted when it ends.
string
duration?
Section titled “duration?”number
stopEvent?
Section titled “stopEvent?”string
Returns
Section titled “Returns”number
A sound id for stopSound.
playSoundForPlayer()
Section titled “playSoundForPlayer()”playSoundForPlayer(
player,event,options?):number
Plays a sound at one player’s listener — private, with no distance falloff.
Parameters
Section titled “Parameters”player
Section titled “player”The only recipient.
string
Wwise event name.
options?
Section titled “options?”bank = soundbank to load first; duration = seconds until it ends itself; stopEvent = authored terminator posted when it ends.
string
duration?
Section titled “duration?”number
stopEvent?
Section titled “stopEvent?”string
Returns
Section titled “Returns”number
A sound id for stopSound, or 0 when the player is gone.
playSoundOnObject()
Section titled “playSoundOnObject()”playSoundOnObject(
object,event,options?):number
Plays a sound attached to a world object: it moves with the object on every client and stops when the object is destroyed or streams out. Heard by the players who have the object streamed in and on screen when the post arrives; one who streams it in later does not get it, so a sound for the object’s whole life belongs in WorldObject.create’s sound instead.
Parameters
Section titled “Parameters”object
Section titled “object”number | WorldObject
World object (or its network id) whose actor the sound follows.
string
Wwise event name.
options?
Section titled “options?”socket = mesh socket it rides, up to 64 characters (omitted or missing on the mesh: the object’s root, or a skeletal mesh’s Head bone when it has one); the rest as playSoundAt.
string
duration?
Section titled “duration?”number
socket?
Section titled “socket?”string
stopEvent?
Section titled “stopEvent?”string
Returns
Section titled “Returns”number
A sound id for stopSound, or 0 when the object is gone, the event name was empty or the socket name too long.
playSoundOnPlayer()
Section titled “playSoundOnPlayer()”playSoundOnPlayer(
player,event,options?):number
Plays a sound attached to a player, heard by everyone in range who shares their virtual world and map, including them.
Parameters
Section titled “Parameters”player
Section titled “player”Player whose body the sound follows.
string
Wwise event name.
options?
Section titled “options?”Same options as playSoundAt.
string
duration?
Section titled “duration?”number
range?
Section titled “range?”number
stopEvent?
Section titled “stopEvent?”string
Returns
Section titled “Returns”number
A sound id for stopSound, or 0 when the player is gone.
setDialoguePolicy()
Section titled “setDialoguePolicy()”setDialoguePolicy(
policy):boolean
Mutes the game’s own spoken lines on every client, by who says them: player (each client’s own character: spell incantations, mount and exploration remarks, grunts), players (other players’ bodies), npcs (NPC.create), characters (Character.create), world (the game’s own people, such as townsfolk, students, vendors and ghosts, and lines posted at a spot) and floo (the Floo Network’s announcer). A muted line never starts: no sound, no subtitle, no lip movement. Clients raise dialogueMuted for each one, so a script can play a replacement. Players who join later get the policy too.
Parameters
Section titled “Parameters”policy
Section titled “policy”Partial<DialoguePolicy>
Per speaker: true lets every line play, “nonverbal” only the grunts, breaths, laughs and gasps, false none. Speakers left out keep their setting.
Returns
Section titled “Returns”boolean
False for a non-object, an unknown speaker or a value other than true, false or “nonverbal”; nothing changes then.
setMusic()
Section titled “setMusic()”setMusic(
event,priority?):void
Pushes a track onto every client’s music priority stack. Only events that actually contain a Play action work — most “music” event names only flip Wwise states.
Parameters
Section titled “Parameters”string
Music event name (must be unique while pushed).
priority?
Section titled “priority?”number
Stack priority, clamped to -5..5 (default 5 = above the game’s score).
Returns
Section titled “Returns”void
setMutedEvents()
Section titled “setMutedEvents()”setMutedEvents(
events):string[]
Mutes Wwise events on every client: each post of one is refused, the game’s own and those of Audio’s play functions alike, and what they are already playing fades out. For the game’s own sounds no other switch reaches, such as the castle’s ambience bed (amb_2d_hogwarts_lerp_location_loop_start), which carries the Great Hall’s chatter at mealtimes. Unmuting an event plays it again on whatever it was playing on when it was muted; a post the game made while it was muted stays refused. Replaces the whole list; players who join later get it too. Throws a TypeError for a non-array or an entry that is not a non-empty string, and a RangeError for more than 64 distinct events; the list stays as it was then.
Parameters
Section titled “Parameters”events
Section titled “events”string[]
Wwise event names (case-insensitive), at most 64. An empty array lets every event play again.
Returns
Section titled “Returns”string[]
The list as applied: lowercased and deduplicated, in the order given.
setRTPC()
Section titled “setRTPC()”setRTPC(
name,value):void
Sets a global Wwise real-time parameter on every client.
Parameters
Section titled “Parameters”string
Wwise RTPC name.
number
New value.
Returns
Section titled “Returns”void
setState()
Section titled “setState()”setState(
group,state):void
Sets a global Wwise state on every client.
Parameters
Section titled “Parameters”string
Wwise state group.
string
State within the group.
Returns
Section titled “Returns”void
stopAll()
Section titled “stopAll()”stopAll():
void
Stops every sound on every client, including the game’s own music and ambience (those mostly re-post on their own). The way out of a held/looping event nobody holds an id for.
Returns
Section titled “Returns”void
stopAllSounds()
Section titled “stopAllSounds()”stopAllSounds():
void
Old name of stopAll.
Returns
Section titled “Returns”void
Deprecated
Section titled “Deprecated”Use stopAll, the name the client’s Audio has.
stopEventFor()
Section titled “stopEventFor()”stopEventFor(
event):string
The terminator that would be posted for this event, derived from the game’s own soundbanks.
Parameters
Section titled “Parameters”string
Wwise event name.
Returns
Section titled “Returns”string
The stop event’s name, or “” when the event is a one-shot that needs none.
stopSound()
Section titled “stopSound()”stopSound(
soundId):boolean
Stops that sound on every client that started it.
Parameters
Section titled “Parameters”soundId
Section titled “soundId”number
An id returned by one of the play functions.
Returns
Section titled “Returns”boolean
True when the stop was broadcast.
unloadBank()
Section titled “unloadBank()”unloadBank(
bank):void
Unloads a soundbank on every client.
Parameters
Section titled “Parameters”string
Soundbank name.
Returns
Section titled “Returns”void