# Introduction and quick start

URL: https://www.audiobits.dev/docs

Choose a starting point, install the AudioBits runtime, and play your first procedural sound.

AudioBits API · 0.7.0 · Available on npm.

AudioBits generates procedural browser audio from recipes. Use the
[catalog](https://www.audiobits.dev/catalog) to hear and adjust sounds and interactive experiences, then
use these guides to bring them into your application.

The `audiobits` npm package is the audio runtime: it interprets recipe data and
creates browser audio. The shadcn registry installs editable recipes and
sound controllers into your project. Demo renderers stay in the showcase. Each
item declares `audiobits` as an npm dependency, so installed source uses the same runtime as an original sound you
write yourself.

## Choose a starting point

**[Runtime](https://www.audiobits.dev/docs#install-the-runtime)**

Install `audiobits` from npm, then write or integrate an original sound with
the quick start below.

**[Catalog & Editable Source](https://www.audiobits.dev/docs/catalog)**

Hear ready-made sounds in the showcases. Install or copy only their recipes
or sound controllers, then connect your existing application controls.

**[AI Agents](https://www.audiobits.dev/docs/agents)**

Install the official AudioBits Skill to help coding agents create sounds and
wire them into your application.

Browse the [live catalog](https://www.audiobits.dev/catalog) for sounds to adapt, or see the
[runtime reference](https://www.audiobits.dev/docs/api) for public APIs. The agent guide also links to
[optional MCP tooling](https://www.audiobits.dev/docs/mcp) for complex workflows.

## Install the runtime

For an original sound, install AudioBits directly with your project's package
manager. This installs the runtime, not catalog source or the agent Skill.

**npm**

```sh
npm install audiobits
```

**pnpm**

```sh
pnpm add audiobits
```

**yarn**

```sh
yarn add audiobits
```

**bun**

```sh
bun add audiobits
```

## Play a tone

> **Start audio from a user gesture**
>
> Create the engine and definition without allocating browser audio. Call `play()`
> directly from your button's click handler and report rejected promises to the user.
> Retry a failed start with a fresh Play gesture.

```ts
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);
let request = 0;

export async function play() {
  const token = ++request;
  await audio.start();
  if (token !== request) return;
  sound.play();
}
export function stop() {
  request++;
  audio.stopAll({ tails: "cut" });
}
export async function dispose() {
  stop();
  await audio.dispose();
}
```

> **Own the host lifecycle**
>
> Bind `play()` to your button click and surface failures with
> `void play().catch(showError)`. For hiding, SPA navigation, suspension and disposal,
> bind `stop()` to Stop and await `dispose()` when removing the host.
> See [Production lifecycle](https://www.audiobits.dev/docs/lifecycle). The catalog never plays on load.

## Next

- [Listen and adjust](https://www.audiobits.dev/catalog) catalog sounds and complete interactive experiences.
- [Catalog and editable source](https://www.audiobits.dev/docs/catalog): installation, customization, and integration.
- [Official Skill and agent workflows](https://www.audiobits.dev/docs/agents): integration and original audio creation.
- [Recipes](https://www.audiobits.dev/docs/recipes): validated JSON and supported fields.
- [Playback and lifecycle](https://www.audiobits.dev/docs/lifecycle): sound versus voice, Stop, and teardown.
- [Parameters](https://www.audiobits.dev/docs/parameters): controls, smoothing, and seeded replay.
- [Buses and routing](https://www.audiobits.dev/docs/buses): named routes, gain, and mute.
- [Native interop](https://www.audiobits.dev/docs/native): caller-owned analyser taps.
- [API reference](https://www.audiobits.dev/docs/api): public exports and limits.

Browser verification target: current Chromium. Other browsers and operating
systems are unverified and deliberately deferred.
