Skip to main content
Version: 0.3.0


The Source class is a handle for an audio object which can be positioned in space and assigned input signals to. You can create a source by calling createSource on the renderer:

let source = renderer.createSource();
source.setInput(/* AudioNode */);
source.setPosition(42, 10, 3.1415)

Public Interface


name? : string

The name of the source (optional). This property will be used in the Attenuation Curve Designer and the Source Viewer.


setInput(input: AudioNode | MediaStreamTrack | any, outputIndex?: number, connect?: boolean): void

Sets the source's audio input.

If you provide a MediaStream track, the source automatically handles the creation of a MediaStreamSourceNode.

outputIndex defines the outlet of the provided input node.

If the connect argument is set to true (default), the audio node will be connected to the renderer's input. Set it to false if you want to connect the source later on manually.

Will throw if a non supported input type is provided.

getInputNode(): AudioNode

Returns the source's audio input node.

connect(): void

Connects the source's signal to the renderer.

disconnect(): void

Disconnects the source's signal from the renderer.

setPosition(x: number, y: number, z: number): void

Sets the sources position in space using cartesian coordinates.

getPosition(): Point3D

Returns the source's current position in cartesian coordinates.

setGainLinear(gain: number): void

Sets the source's gain as a linear gain value.

getGainLinear(): number

Returns the current linear gain.

setGainDecibels(dB: number): void

Sets the source's gain in decibels.

getGainDecibels(): number

Returns the source's gain in decibels.

setReverbSendLinear(gain: number): void

Sets the reverb send level (linear).

getReverbSendLinear(): number

Returns the reverb send level (linear).

setReverbSendDecibels(dB: number): void

Sets the reverb send level (in decibels).

getReverbSendDecibels(): number

Returns the reverb send level (in decibels).

setAttenuationCurveIndex(index: number): void

Assigns an attenuation curve to this source (default index 0).

getAttenuationCurveIndex(): number

Returns the currently assigned attenuation curve index.

delete(): void

Removes this source from the renderer, frees its source slot, and also removes the renderers reference, so it cannot be accidentally connected to the renderer again.