Class SoundSource

A sound source is a way to position and orient sounds in the world. If you don't need to position your sounds, you can work with a SoundPlayer instead.

Hierarchy (view full)

Constructors

Properties

channels: Map<string, AudioBufferSourceNode> = ...

All sounds played on a channel.

gainNode?: GainNode

The gain node if configured.

The destination node to connect AudioBufferSourceNode AudioBufferSourceNodes to. In the case of a SoundSource, this will be the panner node.

sounds: AudioBufferSourceNode[] = []

All free sounds (those not played on a channel).

Methods

  • Set the gain (~volume). Only works if this instance has been configured with again!

    Parameters

    • gain: number

      The new value.

    Returns void

  • Set the orientation of this source. Only relevant if you also configured a cone.

    Parameters

    • x: number

      The x-direction.

    • y: number

      The y-direction.

    • z: number

      The z-direction.

    Returns void

  • Set the position of this source.

    Parameters

    • x: number

      The x-coordinate.

    • y: number

      The y-coordinate.

    • z: number

      The z-coordinate.

    Returns void

  • Stop the AudioBufferSourceNode on a channel if any is currently playing.

    Parameters

    • channel: string

      The channel to stop.

    Returns void