Class MediaStreamSound

The base interface for any sound-producing entity, including individual sounds, groups, and playbacks. BaseSound

Hierarchy

  • PlaybackContainer<typeof FilterManager, this> & FilterManager<this>
    • MediaStreamSound

Implements

Constructors

Properties

_cacophony?: Cacophony
_filters: BiquadFilterNode[] = []
_position: Position = ...
_stereoPan: number = 0
_threeDOptions: PannerOptions = ...
_volume: number = 1
context: BaseContext
globalGainNode: GainNode
panType: PanType
playbacks: MediaStreamPlayback[]
stopTracksOnStop: boolean
stream: MediaStream

Accessors

  • get isPlaying(): boolean
  • Returns a boolean indicating whether the object is currently playing. an object is playing if any of its playbacks are currently playing.

    Returns boolean

    True if the object is playing, false otherwise.

  • get position(): Position
  • Retrieves the current 3D spatial position of the sound in the audio context. The position is returned as an array of three values[x, y, z].

    Returns Position

    The current position of the sound.

  • set position(position): void
  • Sets the 3D spatial position of the sound in the audio context. The position is an array of three values[x, y, z]. This method updates the position of all active playbacks of the sound.

    Parameters

    • position: Position

      The new position of the sound.

    Returns void

  • get stereoPan(): null | number
  • Returns null | number

  • set stereoPan(value): void
  • Parameters

    • value: number

    Returns void

  • get volume(): number
  • Gets the volume of the sound. This volume level affects all current and future playbacks of this sound instance. The volume is specified as a linear value between 0 (silent) and 1 (full volume).

    Returns number

    The current volume of the sound.

  • set volume(volume): void
  • Sets the volume of the sound. This volume level affects all current and future playbacks of this sound instance. The volume is specified as a linear value between 0 (silent) and 1 (full volume).

    Parameters

    • volume: number

      The new volume level for the sound.

    Returns void

Methods

  • Adds a BiquadFilterNode to the container's filter chain. Filters are cloned when creating new playbacks - existing playbacks are not affected. Each playback gets independent filter instances for isolated processing.

    Parameters

    Returns void

  • Parameters

    • connection: any

    Returns any

  • Returns void

  • Fades in all playbacks from silence to their current volume.

    Parameters

    • duration: number

      The fade duration in milliseconds.

    • Optional type: FadeType

      The fade curve type. Defaults to "linear".

    Returns Promise<void>

    Resolves when all fades complete.

  • Fades out all playbacks from their current volume to silence.

    Parameters

    • duration: number

      The fade duration in milliseconds.

    • Optional type: FadeType

      The fade curve type. Defaults to "linear".

    Returns Promise<void>

    Resolves when all fades complete.

  • Fades the volume of all playbacks to a target value over a duration.

    Parameters

    • value: number

      The target volume (0 to 1).

    • duration: number

      The fade duration in milliseconds.

    • Optional type: FadeType

      The fade curve type. Defaults to "linear".

    Returns Promise<void>

    Resolves when all fades complete.

  • Pauses all current playbacks of the sound.

    Returns void

  • Starts playback of the sound and returns a Playback instance representing this particular playback. Multiple Playback instances can be created by calling this method multiple times, allowing for the same sound to be played concurrently with different settings.

    Returns BasePlayback[]

    An array containing the Playback instances that have been started.

  • Removes a BiquadFilterNode from the container's filter chain. Only affects future playbacks - existing playbacks retain their cloned filters.

    Parameters

    Returns void

    Throws

    If the filter was never added to this container.

  • Parameters

    Returns void

  • Stops all current playbacks of the sound immediately. This will halt the sound regardless of how many times it has been played.

    Returns void

  • Fades out all playbacks then stops them.

    Parameters

    • duration: number

      The fade-out duration in milliseconds.

    • Optional type: FadeType

      The fade curve type. Defaults to "linear".

    Returns Promise<void>

    Resolves when the fade completes and all playbacks are stopped.