Skip to main content
Version: 0.2.0

Source

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

Methods

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

Sets the source's audio input.

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

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.


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.