@webaudio-kit/core
Browser-safe playback helpers, math utilities, frequency clamping, and per-call node cleanup.
webaudio-kit is a small React + TypeScript package set for tone generators, frequency sweeps, safe volume defaults, and analyser-driven UI in browser prototypes.
pnpm add @webaudio-kit/react @webaudio-kit/core
The public API stays intentionally small for the first production release.
import { AudioProvider, useTone } from "@webaudio-kit/react";
function ToneButton() {
const tone = useTone({ frequency: 440, gain: 0.15, type: "sine" });
return (
<button type="button" onClick={() => void tone.play({ durationMs: 600 })}>
Play 440 Hz
</button>
);
}
export function App() {
return (
<AudioProvider>
<ToneButton />
</AudioProvider>
);
}Browser-safe playback helpers, math utilities, frequency clamping, and per-call node cleanup.
AudioProvider plus hooks for tones, sweeps, master volume, context state, and analyser access.
A Vite React sandbox for manually testing tone generation, sweeps, pan, gain, and waveform output.
Tone and sweep nodes feed the master gain, analyser, then destination. The waveform should move while sound is playing.
AudioContext is created lazily after user interaction so React apps avoid browser autoplay violations.
The provider starts with a 0.2 master gain and examples keep gain controls bounded.
The demo draws analyser data so developers can verify the provider graph is live.
Package tarballs are built and reinstalled before publish so exports match the public API.
$ pnpm verify tests pass types pass packages build demo and site build lint and format pass
webaudio-kit can help build audible UI controls and prototypes. It is not certified audiology software, and it should not be used to diagnose hearing conditions or replace calibrated test equipment.