# Reverb

> A reverb device: six types of room, a decay, a pre-delay, a damping and a mix, a panel that draws the tail with a handle, a Web Audio engine and tools for agents.

```tsx
import { useState } from "react";
import {
  type ReverbState,
  reverbDevice,
} from "@/components/audio-ui/devices/reverb/device";
import { createReverbEngine } from "@/components/audio-ui/devices/reverb/engine";
import { ReverbPanel } from "@/components/audio-ui/devices/reverb/panel";
import { useDeviceLoop } from "@/hooks/use-device-loop";
import { useDeviceSignal } from "@/hooks/use-device-signal";
import { useMasterBus } from "@/hooks/use-master-bus";
import { useDemoSound } from "@/hooks/use-demo-source";

const MASTER_VOLUME = 0.7;

/**
 * A reverb you can plug in: its state, a panel that draws the tail it makes
 * and an engine that plays it, each its own file and none knowing the others.
 * Play the loop and drag the handle along: the decay time.
 */
export function BlockReverb() {
  const [state, setState] = useState<ReverbState>(() =>
    reverbDevice.defaults()
  );
  const master = useMasterBus(MASTER_VOLUME);
  const sound = useDemoSound("groove");
  const { engine } = useDeviceLoop({
    create: createReverbEngine,
    destination: master,
    sound,
    state,
  });
  const signal = useDeviceSignal(engine, reverbDevice);
  return (
    <div className="rounded-xl h-full w-full min-w-0">
      <ReverbPanel onValueChange={setState} signal={signal} value={state} />
    </div>
  );
}
```

Puts the sound in a room. It is a [device](/docs/devices): a state, a panel, an engine and tools, each its own file.

## Installation

**CLI**

```bash
npx shadcn@latest add @audio-ui/reverb
```

It installs the device's state, its engine and its panel to `components/audio-ui/devices/reverb/`. The demo above, which wires them to a loop, is `@audio-ui/block-reverb`.

**Manual**

**1. Install the packages:**

```bash
npm install @ui-sdk/core@0.1.0-beta.14 @ui-sdk/react@0.1.0-beta.14
```

**2. Add the pieces you want. All of them, or only the state and the panel if your engine is elsewhere:**

```bash
npx shadcn@latest add @audio-ui/reverb-device @audio-ui/reverb-panel @audio-ui/reverb-engine
```

**3. Copy and paste the demo that wires them, if you want it.**

```tsx title="components/examples/block-reverb.tsx"
import { useState } from "react";
import {
  type ReverbState,
  reverbDevice,
} from "@/components/audio-ui/devices/reverb/device";
import { createReverbEngine } from "@/components/audio-ui/devices/reverb/engine";
import { ReverbPanel } from "@/components/audio-ui/devices/reverb/panel";
import { useDeviceLoop } from "@/hooks/use-device-loop";
import { useDeviceSignal } from "@/hooks/use-device-signal";
import { useMasterBus } from "@/hooks/use-master-bus";
import { useDemoSound } from "@/hooks/use-demo-source";

const MASTER_VOLUME = 0.7;

/**
 * A reverb you can plug in: its state, a panel that draws the tail it makes
 * and an engine that plays it, each its own file and none knowing the others.
 * Play the loop and drag the handle along: the decay time.
 */
export function BlockReverb() {
  const [state, setState] = useState<ReverbState>(() =>
    reverbDevice.defaults()
  );
  const master = useMasterBus(MASTER_VOLUME);
  const sound = useDemoSound("groove");
  const { engine } = useDeviceLoop({
    create: createReverbEngine,
    destination: master,
    sound,
    state,
  });
  const signal = useDeviceSignal(engine, reverbDevice);
  return (
    <div className="rounded-xl h-full w-full min-w-0">
      <ReverbPanel onValueChange={setState} signal={signal} value={state} />
    </div>
  );
}
```

**Agent**

Paste this prompt to your agent. It does the rest: it installs the skill, adds the component and wires it to your audio.

```text
Install the audio/ui skill with `npx skills add ouestlabs/audio-ui`, then follow it to add the reverb from audio/ui to my project and wire it to my audio code. Read the docs at https://www.audio-ui.dev/llms.txt first.
```

To let the agent read the docs live, connect the [MCP server](/docs/mcp). More in [Agent Skill](/docs/agents).

## Controls

| Control | Range | Default | What it does |
| --- | --- | --- | --- |
| On | On or off | On | Turns the device on. Off, the signal passes through unchanged. |
| Type | Room, Plate, Hall, Spring, Freeverb, Schroeder | Room | The algorithm the room is made with, picked in the title bar. Room, noise dying away, smooth and even, is the default. Plate is a Dattorro plate, dense and bright. Hall is a feedback delay network, wide and even. Spring is the dispersive loop of a spring tank, with its chirp, in mono. Freeverb is eight damped combs and four allpasses per side. Schroeder is four combs and two allpasses, the first digital reverb, in mono. |
| Decay | 0.2 s to 10 s | 2.2 s | How long the tail takes to fall by 60 dB. Drag the handle at the end of the tail to set it. |
| Pre-delay | 0 ms to 200 ms | 20 ms | The time between the sound and the start of the tail. |
| Damping | 1 kHz to 20 kHz | 7 kHz | Closes the highs of the tail, as soft walls do: a one-pole low-pass on what goes into the room, the same for every type. |
| Mix | 0 % to 100 % | 25 % | The balance of the room and the dry signal. |

## Panel

The panel draws the level of the tail falling in dB, from the end of the pre-delay to -60 dB, and picks the type in its title bar. `reverbDecay(state)` is the curve it draws, and `reverbImpulse(sampleRate, state)` makes the impulse response of the room.

```tsx
import { ReverbPanel } from "@/components/audio-ui/devices/reverb/panel";
import { reverbDevice } from "@/components/audio-ui/devices/reverb/device";

const [state, setState] = useState(() => reverbDevice.defaults());

<ReverbPanel onValueChange={setState} value={state} />;
```

## Engine

Create it, connect it and update it as for any device: see [The engine](/docs/devices#the-engine).

The room is a convolver fed an impulse response made from the type, the decay and the damping. Room is noise shaped to the decay. Every other type is its own algorithm rung by a click, from `@audio/reverb-dattorro`, `@audio/reverb-fdn`, `@audio/reverb-spring`, `@audio/reverb-freeverb` and `@audio/reverb-schroeder`, its feedback set so the tail falls by 60 dB over the decay time. These algorithms hold no modulation, so the impulse response is the algorithm itself, and every type plays at the cost of one convolver. A plate, a spring and a Freeverb ring for half a second at the least: a shorter decay brings their tail down along the same exponential. A spring longer than about 9 s stops at that.

A convolver cannot change its impulse without a click, so the engine has two and cross-fades: a new room is built in the idle one once a control has rested for 120 ms. Building a type other than Room takes a few tens of milliseconds for a long decay.
