AudioBits

API reference

Public package exports and resource limits.

AudioBits API · 0.1.2 · Available on npm.

Imports use public package exports. audiobits/schema.json supplies structural recipe JSON Schema; audiobits/capabilities.json supplies this package version's shipped primitives and browser gate. Semantic limits still require validateRecipe; sample-rate constraints are checked at playback.

ExportResponsibility
createAudio(options?)Own an engine; defaults: 32 voices, eight per sound, -12 dB master
defineSound(input)Author typed recipe data; validate and freeze; throws AudioBitsError
validateRecipe(input)Return a recipe or bounded path-specific issues
recipeSchemaDraft version 1 JSON schema
AudioBitsErrorError with code and validation issues
audiobits/recipesEight curated recipe definitions

The recipe exports are confirmation, impact, thruster, tactileClick, gentleRejection, glassNotification, whoosh, and powerUp.

Public types include Recipe, its layer/source/envelope/filter/value and parameter types, ValidationResult, RecipeIssue, AudioEngine, AudioOptions, AudioState, Sound, Voice, PlayOptions, and Bus.

Playback options

sound.play({ at, gainDb, pan, parameters, seed, bus }) uses absolute context time for at; omit it for immediate play. Past times are rejected. Gain is -60–0 dB, pan is -1–1, and seed is an unsigned 32-bit integer. Future voices reserve capacity. Invalid options fail before stealing or graph allocation.

Engine and per-sound limits are integers from 1–128. Oldest-voice stealing uses a 5 ms output fade with at most one extra retiring voice. audio.counts separates reservations from retirees. At most 32 buses, including master, may be live.

Guides

Recipes, Lifecycle, Parameters, Buses, and Native interop explain the contracts and cleanup paths.

Defaults provide headroom for the curated sounds; arbitrary recipes, resonance, or concurrency require application-specific signal and listening checks.

Buses provide gain, mute, and routing. Shared effects are deferred until multiple real sound requirements justify an API.

On this page