# Overdrive

> An overdrive device: a band-pass before a soft clip, a drive, a tone and a mix, a panel that draws the band that reaches the clip, a Web Audio engine and tools for agents.

```tsx
import { useState } from "react";
import {
  type OverdriveState,
  overdriveDevice,
} from "@/components/audio-ui/devices/overdrive/device";
import { createOverdriveEngine } from "@/components/audio-ui/devices/overdrive/engine";
import { OverdrivePanel } from "@/components/audio-ui/devices/overdrive/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;

/**
 * An overdrive you can plug in: its state, a panel that draws the band that
 * reaches the clip and an engine that plays it, each its own file and none
 * knowing the others. Play the loop, drag the handle and turn the drive.
 */
export function BlockOverdrive() {
  const [state, setState] = useState<OverdriveState>(() =>
    overdriveDevice.defaults()
  );
  const master = useMasterBus(MASTER_VOLUME);
  const sound = useDemoSound("groove");
  const { engine } = useDeviceLoop({
    create: createOverdriveEngine,
    destination: master,
    sound,
    state,
  });
  const signal = useDeviceSignal(engine, overdriveDevice);
  return (
    <div className="rounded-xl h-full w-full min-w-0">
      <OverdrivePanel onValueChange={setState} signal={signal} value={state} />
    </div>
  );
}
```

A pedal-style distortion. A band-pass filter picks what is pushed into the soft clip, so the lows do not turn to mud. 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/overdrive
```

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

**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/overdrive-device @audio-ui/overdrive-panel @audio-ui/overdrive-engine
```

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

```tsx title="components/examples/block-overdrive.tsx"
import { useState } from "react";
import {
  type OverdriveState,
  overdriveDevice,
} from "@/components/audio-ui/devices/overdrive/device";
import { createOverdriveEngine } from "@/components/audio-ui/devices/overdrive/engine";
import { OverdrivePanel } from "@/components/audio-ui/devices/overdrive/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;

/**
 * An overdrive you can plug in: its state, a panel that draws the band that
 * reaches the clip and an engine that plays it, each its own file and none
 * knowing the others. Play the loop, drag the handle and turn the drive.
 */
export function BlockOverdrive() {
  const [state, setState] = useState<OverdriveState>(() =>
    overdriveDevice.defaults()
  );
  const master = useMasterBus(MASTER_VOLUME);
  const sound = useDemoSound("groove");
  const { engine } = useDeviceLoop({
    create: createOverdriveEngine,
    destination: master,
    sound,
    state,
  });
  const signal = useDeviceSignal(engine, overdriveDevice);
  return (
    <div className="rounded-xl h-full w-full min-w-0">
      <OverdrivePanel 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 overdrive 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. |
| Band | 100 Hz to 8 kHz | 800 Hz | The centre of the band that reaches the clip. Drag the handle on the plot across to set it. |
| Width | 0.30 to 6.00 | 0.80 | The width of that band. A high value is narrow. |
| Drive | 0 dB to 40 dB | 14 dB | How hard the band is pushed into the clip. |
| Tone | 500 Hz to 20 kHz | 4.5 kHz | Closes the highs after the clip. |
| Mix | 0 % to 100 % | 80 % | The balance of the distorted signal and the clean one. |

## Panel

The panel draws the band-pass that picks what reaches the clip, with a handle on its centre. `overdriveBand(state)` is the curve it draws. Pass `signal`, the device's live sound from [`useDeviceSignal`](/docs/hooks/use-device-signal), to see the spectrum of what comes out behind the curve.

```tsx
import { OverdrivePanel } from "@/components/audio-ui/devices/overdrive/panel";
import { overdriveDevice } from "@/components/audio-ui/devices/overdrive/device";

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

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

## Engine

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

Only what the band-pass lets through goes into the clip, and the clean sound goes round it in the dry path. The drive is a gain before one fixed soft-clip table, and the shaper oversamples 4x to keep the clip from aliasing. That oversampling is the [latency](/docs/devices#latency) of the device.
