@phifans/audio
    Preparing search index...

    Class Channel

    An audio channel is a bridge connecting Bus and Clip.

    You can't create it directly, instead you need to use Bus#createChannel:

    const bus = new Bus();
    const channel = bus.createChannel('main');

    You can adjust channel volume by setting Channel#volume:

    console.log(channel.volume); // Get current channel volume
    channel.volume = 0.5; // Set channel volume to 50%;
    Index

    Constructors

    Properties

    bus: Bus

    The bus that owned this channel.

    Bus

    clipQueue: Clip[] = []

    Clips waiting to be played in next tick.

    Clips could be added by Channel#pushClipToQueue.

    Clip

    gain: GainNode

    The GainNode of the audio channel.

    name: string

    The name of this channel.

    ticker: Ticker = GlobalAudioTicker

    The ticker of this channel, used to update Channel#clipQueue.

    Accessors

    • get volume(): number

      Get the volume of this audio channel

      Returns number

    • set volume(volume: number): void

      Set the volume of this audio channel

      Parameters

      • volume: number

      Returns void

    Methods

    • Disconnect audio nodes, clean clip queue, and stop ticker.

      Returns void

    • Push clip(s) to Channel#clipQueue. This/ese clip(s) will be played in next tick.

      const clip = await Clip.from('https://example.com/test.mp3');
      const channel = Bus.createChannel('main');

      channel.startTick(); // Remember to start the ticker first!
      channel.pushClipToQueue(clip); // The clip will be played in next frame.

      Parameters

      Returns number