Skip to main content

SoundChannel

A group of sounds with a shared gain stage: input → output → SoundManager.output.

Every sound in the channel is mixed into SoundChannel.input; SoundChannel.output carries the channel volume and mute. Insert Web Audio effects between the two to process the whole channel at once:

const music = manager.getChannel('music');
const muffle = music.audioContext.createBiquadFilter();
muffle.type = 'lowpass';
music.input.disconnect();
music.input.connect(muffle).connect(music.output);

Index

Constructors

constructor

Properties

publicreadonlyaudioContext

audioContext: AudioContext

publicreadonlyinput

input: GainNode

Gain node every sound in the channel connects to

publicmaxConcurrentTracks

maxConcurrentTracks: number = Infinity

Maximum number of simultaneously playing tracks in this channel, default Infinity

publicreadonlyname

name: string

publicreadonlyoutput

output: GainNode

Output gain node that carries the channel volume and mute, connected to the manager's master input

publicvoiceStealing

voiceStealing: boolean = false

What happens when a maxConcurrentTracks cap *false (default) drops the new play *true stops the oldest playing track in that scope to make room for it.

Accessors

publicmuted

  • get muted(): boolean
  • Returns boolean

publicsounds

  • get sounds(): readonly Sound<string>[]
  • Sounds currently routed through this channel


    Returns readonly Sound<string>[]

publicvolume

  • get volume(): number
  • set volume(volume: number): void
  • Channel volume [0-1], default 1


    Returns number

  • Parameters

    • volume: number

    Returns void

Methods

publicmute

  • mute(): void
  • Global mute, mutes all sounds managed by the SoundManager by muting the master output node


    Returns void

publicplayingCount

  • playingCount(): number
  • Number of currently-playing tracks across the channel's sounds


    Returns number

publictoggle

  • toggle(): void
  • Returns void

publicunmute

  • unmute(): void
  • Global unmute, unmutes all sounds managed by the SoundManager by setting the gain on the master output node to SoundManager.volume. Warning Does not unmute specifically muted channels


    Returns void