Skip to content

Source

A Source represents an emitting sound source. It stores transform and simulation settings, and one or more SteamAudioNode render its audio.

source.setPosition(position: Vector3Like): void

Sets the source position in world space.

source.setOrientation(orientation: QuaternionLike): void

Sets the source orientation as a quaternion.

source.setTransform(position: Vector3Like, orientation: QuaternionLike): void

Sets both position and orientation in one call.

source.setSettings(settings: Partial<SourceSettings>): void

Updates source settings at runtime. See SourceSettings.

source.setDirectOverrides(overrides: DirectOverrides | null): void

Manually overrides distance attenuation, air absorption, directivity, occlusion, and transmission values sent to the audio node. Pass null to clear overrides.

source.getDirectOutputs(target?: DirectOutputs): DirectOutputs

Returns the latest direct simulation outputs. The optional target object is mutated and returned, which can reduce allocations.

source.dispose(): void

Disposes the source and any nodes connected to it.

spatialization : SpatializationSettings — direct sound spatialization renderer. Defaults to { mode: 'binaural', blend: 1, interpolation: 'nearest' }.

  • mode: 'binaural' maps to Steam Audio Direct Binaural. interpolation may be 'nearest' (default, lower CPU cost) or 'bilinear' (smoother moving wide-band sources at a higher CPU cost).
  • mode: 'panning' uses Steam Audio stereo speaker panning.
  • mode: 'none' leaves direct audio unspatialized.
  • blend is available for binaural and panning modes. It is in [0, 1], where 1 is fully spatialized.

direct : false | DirectSettings — configures direct-path sound. Pass false to disable the direct path.

perspectiveCorrection : boolean — opt this source into the World’s perspective correction. Default: false. This changes spatialization direction only; simulation remains in world space.

reflections : false | ReflectionSettings — enables or configures per-source reflections. Requires world reflections.

airAbsorption : boolean | AirAbsorptionSettings — enables default air absorption or supplies a custom model.

occlusion : false | { type?: 'raycast' | 'volumetric', radius?: number, samples?: number } — occlusion settings.

distanceAttenuation : DistanceAttenuationSettings | false — distance attenuation model, or false to disable.

directivity : false | { dipoleWeight?: number, dipolePower?: number } — directional emission pattern.

mixLevel : number in [0, 1] — direct-path output gain. Default: 1. Use an external GainNode for gains above unity.

transmission : false | { maxSurfaces?: number, type?: 'frequency-dependent' | 'frequency-independent' } — transmission model. Requires occlusion. maxSurfaces is an integer in [1, 8]; default: 1. type defaults to 'frequency-independent'.

{ model: 'default' } : Physics-based inverse-distance attenuation.

{ model: 'inverse', minDistance?: number } : Inverse distance with a custom minimum distance.

{ model: 'curve', minDistance, maxDistance, curve, sampleCount? } : Custom curve function sampled into a lookup table.

reverbScale : ThreeBand — per-band reverb scale. Default: [1, 1, 1].

mixLevel : number — reflections mix level. Default: 1.

distanceAttenuation : number in [0, 1].

airAbsorption : ThreeBand in [0, 1].

directivity : number in [0, 1].

occlusion : number in [0, 1].

transmission : ThreeBand in [0, 1].

ThreeBand values must contain exactly three entries: low, mid, and high.

distanceAttenuation : number.

airAbsorption : [number, number, number].

directivity : number.

occlusion : number.

transmission : [number, number, number].