/** * Audio backend — the shared internal surface every other audio module * (procedural, playback) builds on. Keeps the Howler reference and the * cross-module mutable state in one place so the public surface modules * stay backend-agnostic. * * Not part of the public `me.audio.*` API — the two getters * `getAudioContext` / `getMasterGain` are re-exported from `audio.ts` * for end users; everything else (the `state` object, `soundLoadError`) * is internal. */ import { Howl } from "howler"; /** * Whether to stop on an audio loading error. * * When `true`, melonJS throws an exception and aborts loading. * When `false`, melonJS disables sound and logs a warning to the console. * @default true */ export declare let stopOnAudioError: boolean; /** * Cross-module mutable state. A single object so multiple consumers * can read and mutate the same fields without the "ESM `let` exports * don't share writes across modules" footgun. * * Fields: * - `tracks` — loaded Howl instances keyed by logical sound name. * `Howl | undefined` because missing keys return undefined at runtime * even though the type signature wouldn't normally admit it. * - `currentTrackId` — the name of the currently-playing track managed * by the `playTrack` / `stopTrack` helpers. * - `retryCounter` — retry counter for `soundLoadError`'s back-off. * - `audioExts` — the active list of audio formats set by `init`. * @ignore */ export declare const state: { tracks: Record; currentTrackId: string | null; retryCounter: number; audioExts: string[]; }; /** * Look up a loaded `Howl` instance by logical name, or throw a * uniform "audio clip X does not exist" error if it isn't loaded. * Used by every per-clip helper across `playback.ts` / `audio.ts` so * the error contract stays identical across the whole surface. * @ignore */ export declare function getSoundOrThrow(sound_name: string): Howl; /** * Event listener callback on load error. Retries the load up to 3 * times, then either throws or disables audio (depending on the * `stopOnAudioError` flag re-exported from `audio.ts`). * @ignore */ export declare const soundLoadError: (sound_name: string, onerror_cb?: () => void, stopOnError?: boolean) => void; /** * Returns the underlying WebAudio `AudioContext` used by the audio * module (the same one shared with file-based playback), or `null` if * audio is disabled or no compatible WebAudio implementation is * available. * * Use this when you need to build a custom WebAudio graph — procedural * SFX, custom filters / spatial nodes, audio analysis — without * spawning a second context. Browsers throttle or refuse multiple * `AudioContext` instances on the same page and each has its own * suspend-until-gesture state, so sharing matters. * * The context is lazily created on first access; the call also returns * the cached instance on every subsequent call. * @category Audio */ export declare function getAudioContext(): AudioContext | null; /** * Return the audio module's master gain node — the single `GainNode` * every playback path runs through on its way to `ctx.destination`, * and the lever that {@link setVolume} / {@link muteAll} manipulate. * * Connect to this node (instead of `ctx.destination`) whenever you * build a custom WebAudio graph and want the result to respect the * engine's mute / volume state. Returns `null` when audio is disabled * or unavailable. * @category Audio */ export declare function getMasterGain(): GainNode | null; /** * Get the audio module's global volume. * @ignore */ export declare function getGlobalVolume(): number; /** * Set the audio module's global volume. * @ignore */ export declare function setGlobalVolume(v: number): void; /** * Mute or unmute the audio module globally. * @ignore */ export declare function setGlobalMuted(muted: boolean): void; /** * Whether the audio module is currently muted globally. * @ignore */ export declare function isGlobalMuted(): boolean; /** * Stop every playing sound on every channel. * @ignore */ export declare function stopAllPlayback(): void; /** * Whether the given audio codec is supported by the backend / browser. * @ignore */ export declare function hasCodec(codec: string): boolean; /** * Whether at least one audio backend (HTML5 or WebAudio) is available. * @ignore */ export declare function isAudioAvailable(): boolean; //# sourceMappingURL=backend.d.ts.map