AudioBits is currently tested in Chromium-based browsers. Other browsers are not yet verified.
Energy charge
Hold to build energy. Shape the sound with progress.
Add to project
npx shadcn@latest add joacod/audiobits/energy-chargeAdds editable source and the audiobits runtime dependency. Installation guide
Installs the catalog defaults and sound controller. The website visuals and input system stay in the showcase.
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 { createEnergyCharge } from "./sounds/experiences/energy-charge/progress";
const audio = createAudio();
const charge = createEnergyCharge(audio);
let request = 0;
export async function play() {
const token = ++request;
await audio.start();
if (token !== request) return;
charge.start(0);
}
export function update(value: number) {
charge.setCharge(value);
}
// Release with the recipe's natural tail.
export function release() {
request++;
charge.release();
}
export function stop() {
request++;
charge.stop();
}
export async function dispose() {
stop();
charge.dispose();
await audio.dispose();
}
Production lifecycleCustomize or inspect
Connect your application's state and events to the sound controller. The full showcase source includes the browser host, input, and visuals.
View complete public source