Web Audio
Sound Lab
Design zero-dependency micro-interaction sounds using the native Web Audio API—preview waveforms live and export ready-to-paste TypeScript sound hooks.
Initializing Sound Lab workspace...
Design zero-dependency micro-interaction sounds using the native Web Audio API—preview waveforms live and export ready-to-paste TypeScript sound hooks.
TRIANGLE · 880 Hz · 45ms · 0 KB audio assets
let sharedCtx: AudioContext | null = null;
export async function playUiSound() {
if (!sharedCtx || sharedCtx.state === "closed") {
sharedCtx = new AudioContext();
}
if (sharedCtx.state === "suspended") {
await sharedCtx.resume();
}
const now = sharedCtx.currentTime;
const osc = sharedCtx.createOscillator();
const gain = sharedCtx.createGain();
osc.type = "triangle";
osc.frequency.setValueAtTime(880, now);
osc.frequency.exponentialRampToValueAtTime(240, now + 0.045);
gain.gain.setValueAtTime(0.001, now);
gain.gain.linearRampToValueAtTime(0.24, now + 0.008);
gain.gain.exponentialRampToValueAtTime(0.0008, now + 0.029);
osc.connect(gain);
gain.connect(sharedCtx.destination);
osc.start(now);
osc.stop(now + 0.052);
}Tactile Presets
Oscillator Waveform