/** * File-based playback — load audio assets, then play / pause / fade / * seek / etc. Every function in this module operates on the shared * `state.tracks` map exposed from `backend.ts`, so the audio module's * other surfaces (track helpers, mix, unload) can see the same set of * loaded sounds. */ import type { LoadSettings, PannerAttributes, SoundAsset } from "./types.ts"; /** * Load an audio file. * * `sound.src` is treated as a base path / prefix; the URL is built as * `${sound.src}${sound.name}.${ext}` for each extension configured by * {@link init}, until one loads. Data URLs (`data:audio/...`) are * used as-is and skip the prefix-and-extension dance. * @param sound - The {@link SoundAsset} descriptor — logical `name`, * `src` base path / prefix (or data URL), and optional playback * flags (`autoplay`, `loop`, `stream`, `html5`). * @param onloadcb - Called when the resource has finished loading. * @param onerrorcb - Called when loading fails. * @param settings - Optional {@link LoadSettings} — `nocache` (query * string appended for cache busting) and `withCredentials` (forwarded * to the underlying XHR for cross-origin authenticated requests). * @returns The number of assets loaded (always `1` on success). * @category Audio */ export declare function load(sound: SoundAsset, onloadcb?: () => void, onerrorcb?: () => void, settings?: LoadSettings): number; /** * Play the specified sound. * @param sound_name - Audio clip name (case-sensitive). * @param loop - Whether to loop the clip. Defaults to `false`. * @param onend - Called when the sound instance ends playing. * @param volume - Playback volume, `0.0..1.0`. Defaults to the current * global volume. * @returns The sound instance ID. * @example * // play the "cling" audio clip * me.audio.play("cling"); * // play & loop the "engine" audio clip * me.audio.play("engine", true); * // play the "gameover_sfx" audio clip and call myFunc when finished * me.audio.play("gameover_sfx", false, myFunc); * // play the "gameover_sfx" audio clip at half volume * me.audio.play("gameover_sfx", false, null, 0.5); * @category Audio */ export declare function play(sound_name: string, loop?: boolean, onend?: (() => void) | null, volume?: number): number; /** * Fade a currently playing sound between two volumes. * @param sound_name - Audio clip name (case-sensitive). * @param from - Volume to fade from, `0.0..1.0`. * @param to - Volume to fade to, `0.0..1.0`. * @param duration - Fade time in milliseconds. * @param id - Sound instance ID. When omitted, all sounds in the group * are faded. * @category Audio */ export declare function fade(sound_name: string, from: number, to: number, duration: number, id?: number): void; /** * Get or set the playback position of a sound. * @param sound_name - Audio clip name (case-sensitive). * @param args - Optional seek position in seconds, optionally followed * by the sound instance ID. * @returns The current seek position when no extra arguments are given. * @example * // read the current position of the background music * let current_pos = me.audio.seek("dst-gameforest"); * // rewind the background music to the beginning * me.audio.seek("dst-gameforest", 0); * @category Audio */ export declare function seek(sound_name: string, ...args: number[]): number; /** * Get or set the playback rate of a sound. * @param sound_name - Audio clip name (case-sensitive). * @param args - Optional playback rate (`0.5..4.0`, where `1.0` is * normal speed), optionally followed by the sound instance ID. * @returns The current playback rate when no extra arguments are given. * @example * // read the current playback rate * let rate = me.audio.rate("dst-gameforest"); * // speed it up 2× * me.audio.rate("dst-gameforest", 2.0); * @category Audio */ export declare function rate(sound_name: string, ...args: number[]): number; /** @inheritDoc */ export declare function stereo(sound_name: string): number; /** @inheritDoc */ export declare function stereo(sound_name: string, pan: number, id?: number): void; /** @inheritDoc */ export declare function position(sound_name: string): [number, number, number]; /** @inheritDoc */ export declare function position(sound_name: string, x: number, y?: number, z?: number, id?: number): void; /** @inheritDoc */ export declare function orientation(sound_name: string): [number, number, number]; /** @inheritDoc */ export declare function orientation(sound_name: string, x: number, y?: number, z?: number, id?: number): void; /** * Get or set the panner-node attributes for a sound or sound group. * @param sound_name - Audio clip name (case-sensitive). * @param attributes - The {@link PannerAttributes} to apply (cone angles, * distance model, panning algorithm, …). See the interface for * per-field defaults. * @param id - Sound instance ID. When omitted, all sounds in the group * are affected. * @returns The resulting {@link PannerAttributes} after the update. * @example * me.audio.panner("cling", { * panningModel: "HRTF", * refDistance: 0.8, * rolloffFactor: 2.5, * distanceModel: "exponential", * }); * @category Audio */ export declare function panner(sound_name: string, attributes?: PannerAttributes, id?: number): PannerAttributes; /** * Stop the specified sound on all channels. * @param sound_name - Audio clip name (case-sensitive). When omitted, * every sound currently playing is stopped. * @param id - Sound instance ID. When omitted, all sounds in the group * are stopped. * @example * me.audio.stop("cling"); * @category Audio */ export declare function stop(sound_name?: string, id?: number): void; /** * Pause the specified sound on all channels. Does not reset the * current playback position. * @param sound_name - Audio clip name (case-sensitive). * @param id - Sound instance ID. When omitted, all sounds in the group * are paused. * @example * me.audio.pause("cling"); * @category Audio */ export declare function pause(sound_name: string, id?: number): void; /** * Resume the specified sound on all channels. * @param sound_name - Audio clip name (case-sensitive). * @param id - Sound instance ID. When omitted, all sounds in the group * are resumed. * @example * // play an audio clip * let id = me.audio.play("myClip"); * // ... * // pause it * me.audio.pause("myClip", id); * // ... * // resume * me.audio.resume("myClip", id); * @category Audio */ export declare function resume(sound_name: string, id?: number): void; //# sourceMappingURL=playback.d.ts.map