Skip to content

Spatial audio & effects ​

Spatial cues use one or more coordinate/network-ID emitters. Each emitter has refDistance, maxDistance and gain. The built-in player uses HRTF directionality relative to the listener's camera orientation. GTA coordinates are converted from Z-up into Web Audio's Y-up space.

lua
emitters = {
  { coords = vec3(100, 200, 30), refDistance = 5, maxDistance = 65, gain = 1 },
  { netId = NetworkGetNetworkIdFromEntity(speaker), refDistance = 3, maxDistance = 40, gain = 0.8 },
}

Distance and speakers ​

Gain is full inside the reference distance and zero at the maximum distance. linear, inverse and exponential curves are available. With multiple speakers, the loudest emitter wins: the same signal is rendered once rather than summed once per speaker. The client follows streamed entity positions; an unresolved entity is silent.

Attached entities must exist in the selected server routing bucket at creation. Moving out of the bucket or deleting the last valid emitter removes the source. setEmitters revalidates replacement emitters through the server API.

Audience ​

The server scopes delivery by bucket, range, explicit players and optional caller-owned audience filter. registerAudienceFilter(id, fn) calls fn(player, sourceHandle); only an exact true permits the listener and errors fail closed. Keep callbacks synchronous and fast.

interior=<GTA interior ID> adds a client gate; 0 means outdoors. It is an exact interior match, not a sound-through-doors model. Local mute/interior controls govern rendering; server bucket/player/filter checks govern delivery.

Effects ​

  • Occlusion: bounded asynchronous line probes reduce gain and lowpass when the selected speaker is blocked. Probe priority rotates through sources.
  • Vehicle muffling: applies when the source and listener occupy different vehicle contexts. It does not model windows or roof state.
  • Water: muffles audio for an underwater listener.
  • Lowpass and reverb: the built-in Web Audio graph supplies a configurable lowpass and a shared synthetic impulse reverb send.

These are optional approximations. Native soundsets and xSound do not acquire Web Audio DSP merely by selecting a cue; Integrations documents their capabilities. No material acoustics, physical propagation delay or sample-accurate distributed playback is claimed.