Skip to content

Web audio

AudioBits

Sound that reacts.

A browser audio engine and recipe language with no runtime dependencies. The npm package is the runtime. The catalog gives you editable recipes and sound controllers, and the AudioBits Skill, with optional MCP support, helps coding agents create sounds and wire them into an app.

View on GitHub Explore the catalogOpen source · MIT runtime · 0BSD catalog

Sound you own, not a file you download

I wanted game and interface sound that responds to what the user is doing, lives in my code as data I can edit, and ships without a folder of audio files.

Pick a sound in the catalog, install its editable source with one command, and connect its parameters to your app state. Playback starts from a user gesture.

Start here

Install it where you work.

This installs the runtime for writing your own sounds. To add an interactive sound controller as editable source, run npx shadcn@latest add joacod/audiobits/reactive-thruster. For coding agents, install the official Skill with npx skills add joacod/audiobits --skill audiobits; it includes an optional MCP server. Browser checks currently target Chromium.

npm install audiobits

Use it

Define and play a sound

Create the engine and a recipe once, then start audio from a click:

import { createAudio, defineSound } from "audiobits"

const recipe = defineSound({
  schemaVersion: 1,
  kind: "one-shot",
  duration: 0.15,
  layers: [
    {
      id: "tone",
      source: { type: "oscillator", waveform: "sine", frequency: 660 },
      gainDb: -18,
      envelope: { attack: 0.004, decay: 0.08, sustain: 0.1, release: 0.04 },
    },
  ],
})

const audio = createAudio()
const sound = audio.sound(recipe)

export async function play() {
  await audio.start()
  sound.play()
}

What stays simple

  • Sounds are versioned recipe data. The browser synthesizes them.
  • Live parameters let sound follow application state.
  • Catalog recipes and sound controllers use 0BSD: copy, edit, and use them without required credit or retained notices.
  • Framework-independent, with no runtime dependencies.