Taos API Reference
    Preparing search index...

    Class AudioEngine

    The central audio API: a thin, game-oriented layer over the Web Audio API. Owns one AudioContext, a tree of AudioBuses (master plus sfx / music / ui / voice), an AudioLoader, and the pool of live SoundHandle voices.

    Standalone — instantiate one with new AudioEngine(), drive it from your own loop:

    const audio = new AudioEngine();
    audio.resumeOnGesture(); // unlock on first interaction
    const clip = await audio.load('/sfx/hit.ogg');
    audio.play(clip, { bus: 'sfx' }); // one-shot
    audio.playAt(clip, enemy.position).follow(enemy);
    // per frame:
    audio.updateListener(camPos, camForward, camUp);
    audio.update(dt);
    Index

    Constructors

    Accessors

    • get ready(): boolean

      True once the context exists and is running (not suspended/closed).

      Returns boolean

    Methods

    • Resume the context on the first user interaction. Attaches one-shot pointer/touch/key listeners to target (default window) and removes them once the context is running. Safe to call before any gesture.

      Parameters

      Returns void

    • Stop the current music track, optionally fading out over fade seconds.

      Parameters

      • fade: number = 0

      Returns void

    • Fade the current music out over duration seconds, then stop.

      Parameters

      • duration: number = 2

      Returns void

    • Per-frame housekeeping: advance follow()-bound spatial voices and prune finished ones. Call once per frame after gameplay updates.

      Parameters

      • _dt: number = 0

      Returns void