@phifans/audio
    Preparing search index...

    Class Bus

    An audio bus is the root entry of the whole audio system. You music create it first to use the audio.

    The audio bus only handles the core part: the global AudioContext, the global Clock, and with a master GainNode for controlling the master volume.

    Audio bus itself doesn't handle anything about Clip, you must create at lease one Channel to play a Clip:

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

    clip.channel = channel;
    clip.play();

    You can adjust the master volume by setting Bus#volume:

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

    Constructors

    Properties

    audioCtx: AudioContext = GlobalAudioCtx

    The global AudioContext.

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

    Channels in this bus.

    clock: Clock = GlobalAudioClock

    The global Clock.

    Clock

    gain: GainNode

    The GainNode of the audio bus, used to control the master volume.

    Accessors

    • get volume(): number

      Get the volume of this audio bus

      Returns number

    • set volume(volume: number): void

      Set the volume of this audio bus

      Parameters

      • volume: number

      Returns void

    Methods

    • Create a new audio channel with given name. If the channel exists, we will return the channel directly.

      Parameters

      • name: string

        The audio channel name.

      Returns Channel

      The new audio channel.

    • Delete an audio channel.

      Parameters

      • name: string

        The audio channel name.

      Returns boolean

      Return true if the channel exists.