/** * AudioManager — handles all audio playback for the browser client. * * Public interface: unlock(), handleAudioEvent(), dispose(). * Manages ambient loops and music tracks via the Web Audio API * (per-stream MediaElementAudioSourceNode -> GainNode graph) with * sample-accurate fade-in / fade-out / cross-fade. SFX uses a bare * HTMLAudioElement and is exempt from fades by design (ADR-169). * * If the browser cannot create an AudioContext, the manager falls * back to instant-gain mode: audio still plays via HTMLAudioElement, * fade ramps are skipped. * * Owner context: @sharpee/platform-browser */ export declare class AudioManager { private ambientChannels; private musicTrack; private outgoingStreams; private audioContext; private instantGainMode; private unlocked; private pendingEvents; /** * Unlock audio playback. Must be called from a user gesture handler * (keydown, click) so the browser allows AudioContext.resume() and * Audio.play(). Constructs the AudioContext lazily on first call. */ unlock(): Promise; /** * Handle an audio event from the engine's event pipeline. * Queues events until audio is unlocked by a user gesture. * * @param event - Object with `type` and `data` fields. */ handleAudioEvent(event: { type: string; data: any; }): void; /** * Tear down all audio resources. Cuts audio without ramping — * dispose is the explicit teardown path. Safe to call before * unlock(): the AudioContext close is null-guarded. */ dispose(): void; private playAmbient; private stopAmbient; private stopAllAmbient; private playMusic; private stopMusic; private playSfx; /** * Construct a new stream: HTMLAudioElement + (optionally) Web Audio * graph + fade-in ramp. Returns null only on truly unrecoverable * failure (no src). In all other cases returns an ActiveStream, * possibly in instant-gain mode (graph nodes null). */ private startStream; /** * Begin a fade-out on `stream` and schedule its teardown after the * fade completes. The stream is moved into `outgoingStreams` until * teardown fires. */ private startFadeOut; /** * Schedule a fade-in ramp from 0 to target on the gain node. * Anchors at 0 with setValueAtTime so the ramp has a defined start. */ private scheduleFadeIn; /** * Tear down a stream's graph + element synchronously, no ramping. * Used by dispose() and at the tail of fade-out timers. */ private teardownStreamInstant; /** * Validate a fade-duration value from event payload. * Returns the value in ms, or undefined if invalid (callers fall * back to defaults). Per ADR-169: negative, NaN, non-finite, and * Infinity are all invalid; 0 is honored (instant cut). */ private validateFadeMs; } //# sourceMappingURL=AudioManager.d.ts.map