AudioBits is currently tested in Chromium-based browsers. Other browsers are not yet verified.
Thruster
Start once, adjust throttle while it runs, then release with Stop.
Control position · Throttle 20%
Thruster: stopped
Audio: idle
Sound controls
Add to project
npx shadcn@latest add joacod/audiobits/thrusterAdds editable source and the audiobits runtime dependency. Installation guide
Installs the catalog defaults. The usage below reflects your current settings and applied edits.
Use this sound
Use in src/integration.ts. Call play() from a user gesture and handle activation errors. Connect updates to application state; stop on cancellation or hiding, and dispose on removal.
import { createAudio } from "audiobits";
import { thruster } from "./sounds/recipes/thruster/recipe";
const audio = createAudio();
const sound = audio.sound(thruster);
let request = 0;
let voice: ReturnType<typeof sound.play> | undefined;
// Use in src/integration.ts. Call play() from a user gesture; handle errors.
export async function play() {
const token = ++request;
await audio.start();
if (token !== request) return;
voice?.stop();
voice = sound.play({ parameters: {"throttle":0.2}, seed: 42 });
}
// Connect application state to these live parameters.
export function update(value: number) {
voice?.set({ "throttle": value });
}
// Release with the recipe's natural tail.
export function release() {
request++;
voice?.stop();
voice = undefined;
}
export function stop() {
request++;
audio.stopAll({ tails: "cut" });
voice = undefined;
}
// Call on navigation/unmount.
export async function dispose() {
stop();
sound.dispose();
await audio.dispose();
}
Production lifecycleCustomize or inspect
Recipe
Apply valid JSON edits to hear and copy them. Copy Recipe returns the applied definition; the Add command installs catalog defaults.
{
"kind": "sustained",
"layers": [
{
"envelope": {
"attack": 0.08,
"decay": 0.1,
"release": 0.15,
"sustain": 0.8
},
"gainDb": {
"control": "throttle",
"range": [
-30,
-18
],
"scale": "linear"
},
"id": "motor",
"source": {
"frequency": {
"control": "throttle",
"range": [
45,
130
],
"scale": "exponential"
},
"type": "oscillator",
"waveform": "triangle"
}
},
{
"effects": [
{
"filter": "lowpass",
"frequency": {
"control": "throttle",
"range": [
250,
2400
],
"scale": "exponential"
},
"q": 0.7,
"type": "filter"
}
],
"envelope": {
"attack": 0.1,
"decay": 0.1,
"release": 0.2,
"sustain": 0.9
},
"gainDb": {
"control": "throttle",
"range": [
-34,
-22
],
"scale": "linear"
},
"id": "exhaust",
"source": {
"color": "white",
"type": "noise"
}
}
],
"parameters": {
"throttle": {
"default": 0.2,
"max": 1,
"min": 0,
"mode": "live",
"smoothing": 0.04
}
},
"schemaVersion": 1
}