/** * Procedural audio — fire-and-forget envelope-shaped primitives that * build on the shared `AudioContext` exposed by `backend.ts`. Designed * for "just play a beep / explosion / whoosh" use cases where loading * an audio file would be overkill. * * Two primitives: * - `tone` for pitched sources (clicks, chimes, lasers, chord pings). * - `noise` for non-pitched sources (explosions, hi-hats, swooshes, * wind, footsteps). * * Both share the same envelope + output routing rails so future * primitives can be added with zero copy-paste. */ import type { NoiseOptions, ToneOptions } from "./types.ts"; /** * Fire a single-shot envelope-shaped oscillator on the shared * {@link getAudioContext} context. Designed for the "just play a beep" * niche where loading an audio file is overkill — UI clicks, hit * confirms, retro arcade-style cues, placeholder feedback during * prototyping. * * Multi-partial `freq` makes chimes, bells, and simple chords a single * call; `pitchSlide` covers percussive pitch-drops and rising stings. * The context is shared with file-based playback, so the usual browser * autoplay gating applies: the first call after a user gesture lets * every subsequent call play. * * **Requires WebAudio.** When WebAudio is not supported (or audio is * explicitly disabled) this is a silent no-op: {@link getAudioContext} * returns `null` and nothing is scheduled. Use the return value of * {@link getAudioContext} to detect that case up front if your game * wants to show a "no audio" badge or fall back to a different * feedback channel. * @param opts - the {@link ToneOptions} (frequency, duration, * envelope, pan, slide). See the interface for per-field defaults. * @example * // simple UI click * me.audio.tone({ freq: 1200, duration: 0.08, pitchSlide: 0.5 }); * // chime, panned right, two partials a fifth apart * me.audio.tone({ freq: [880, 1320], duration: 0.4, gain: 0.18, pan: 0.5 }); * // descending "thud" — square wave with a wide pitch drop * me.audio.tone({ freq: 200, duration: 0.15, wave: "square", pitchSlide: 0.25 }); * @category Audio */ export declare function tone(opts: ToneOptions): void; /** * Fire a single-shot envelope-shaped noise burst on the shared * {@link getAudioContext} context. Sits alongside {@link tone} as the * non-pitched half of the procedural-audio surface — `tone` is the right * tool for anything with a clear pitch (clicks, chimes, lasers), `noise` * is the right tool for anything percussive without one (explosions, * hi-hats, swooshes, footsteps, wind). * * The output runs through the master gain shared with file-based * playback, so {@link muteAll} / {@link setVolume} apply uniformly. * Browser autoplay gating applies — the first call after a user * gesture lets every subsequent call play. * * **Requires WebAudio.** When WebAudio is not supported (or audio is * explicitly disabled) this is a silent no-op: {@link getAudioContext} * returns `null` and nothing is scheduled. * @param opts - the {@link NoiseOptions} (duration, spectral colour, * envelope, pan, optional filter + sweep). See the interface for * per-field defaults. * @example * // Explosion: brown rumble closing into a thud * me.audio.noise({ * duration: 0.8, * type: "brown", * gain: 0.4, * filter: { type: "lowpass", frequency: 800 }, * filterSweep: 0.3, * }); * // Hi-hat: short, bright, top-end only * me.audio.noise({ * duration: 0.05, * filter: { type: "highpass", frequency: 7000 }, * gain: 0.2, * }); * // Swoosh: bandpass white with rising sweep — UI transition, melee whoosh * me.audio.noise({ * duration: 0.3, * filter: { type: "bandpass", frequency: 400, Q: 1.5 }, * filterSweep: 4, * gain: 0.3, * }); * // Wind / breath: long, low-pink, no sweep * me.audio.noise({ * duration: 2, * type: "pink", * filter: { type: "bandpass", frequency: 600 }, * gain: 0.08, * }); * // Footstep on dirt — short brown thump * me.audio.noise({ * duration: 0.08, * type: "brown", * filter: { type: "lowpass", frequency: 200 }, * gain: 0.25, * }); * @category Audio */ export declare function noise(opts: NoiseOptions): void; //# sourceMappingURL=procedural.d.ts.map