# Equalizer

> An equalizer device: four bands with a type, a frequency, a gain and a width, a panel with a handle on each band, a Web Audio engine and tools for agents.

```tsx
import { useState } from "react";
import {
  type EqualizerState,
  equalizerDevice,
} from "@/components/audio-ui/devices/equalizer/device";
import { createEqualizerEngine } from "@/components/audio-ui/devices/equalizer/engine";
import { EqualizerPanel } from "@/components/audio-ui/devices/equalizer/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 shape worth looking at: some weight, a dip in the low mids, some air. */
const START = { highDb: 5, lowDb: 3, lowMidDb: -4 };

/**
 * An equalizer you can plug in: its state, a panel that draws it and an engine
 * that plays it, each its own file and none knowing the others. A loop
 * plays through it while its session's play switch is on, and the spectrum
 * behind the curve is what comes out.
 */
export function BlockEqualizer() {
  const [state, setState] = useState<EqualizerState>(
    () => equalizerDevice.apply(equalizerDevice.defaults(), START).state
  );
  const master = useMasterBus(MASTER_VOLUME);
  const sound = useDemoSound("groove");
  const { engine } = useDeviceLoop({
    create: createEqualizerEngine,
    destination: master,
    sound,
    state,
  });
  const signal = useDeviceSignal(engine, equalizerDevice);

  return (
    <div className="rounded-xl h-full w-full min-w-0">
      <EqualizerPanel onValueChange={setState} signal={signal} value={state} />
    </div>
  );
}
```

Shapes the spectrum with four bands in series, then an output level. The panel draws the filters the engine runs, so what you see is what you hear. 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/equalizer
```

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

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

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

```tsx title="components/examples/block-equalizer.tsx"
import { useState } from "react";
import {
  type EqualizerState,
  equalizerDevice,
} from "@/components/audio-ui/devices/equalizer/device";
import { createEqualizerEngine } from "@/components/audio-ui/devices/equalizer/engine";
import { EqualizerPanel } from "@/components/audio-ui/devices/equalizer/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 shape worth looking at: some weight, a dip in the low mids, some air. */
const START = { highDb: 5, lowDb: 3, lowMidDb: -4 };

/**
 * An equalizer you can plug in: its state, a panel that draws it and an engine
 * that plays it, each its own file and none knowing the others. A loop
 * plays through it while its session's play switch is on, and the spectrum
 * behind the curve is what comes out.
 */
export function BlockEqualizer() {
  const [state, setState] = useState<EqualizerState>(
    () => equalizerDevice.apply(equalizerDevice.defaults(), START).state
  );
  const master = useMasterBus(MASTER_VOLUME);
  const sound = useDemoSound("groove");
  const { engine } = useDeviceLoop({
    create: createEqualizerEngine,
    destination: master,
    sound,
    state,
  });
  const signal = useDeviceSignal(engine, equalizerDevice);

  return (
    <div className="rounded-xl h-full w-full min-w-0">
      <EqualizerPanel 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 equalizer 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. |
| Low type | Low cut, Low shelf, Bell, Notch, High shelf, High cut | Low shelf | The shape of the first band. A shelf by default. |
| Low freq | 20 Hz to 500 Hz | 100 Hz | The frequency of the first band. |
| Low gain | -18 dB to 18 dB | 0 dB | The gain of the first band. A cut or a notch has none. |
| Low Q | 0.30 to 12.00 | 0.71 | The width of the first band. A shelf has a fixed slope and ignores it. |
| Low mid type | Low cut, Low shelf, Bell, Notch, High shelf, High cut | Bell | The shape of the second band. A bell by default. |
| Low mid freq | 100 Hz to 2 kHz | 400 Hz | The frequency of the second band. |
| Low mid gain | -18 dB to 18 dB | 0 dB | The gain of the second band. |
| Low mid Q | 0.30 to 12.00 | 1.00 | The width of the second band. |
| High mid type | Low cut, Low shelf, Bell, Notch, High shelf, High cut | Bell | The shape of the third band. A bell by default. |
| High mid freq | 800 Hz to 8 kHz | 2.5 kHz | The frequency of the third band. |
| High mid gain | -18 dB to 18 dB | 0 dB | The gain of the third band. |
| High mid Q | 0.30 to 12.00 | 1.00 | The width of the third band. |
| High type | Low cut, Low shelf, Bell, Notch, High shelf, High cut | High shelf | The shape of the fourth band. A shelf by default. |
| High freq | 2 kHz to 20 kHz | 8 kHz | The frequency of the fourth band. |
| High gain | -18 dB to 18 dB | 0 dB | The gain of the fourth band. |
| High Q | 0.30 to 12.00 | 0.71 | The width of the fourth band. |
| Output | -12 dB to 12 dB | 0 dB | The level of the output. |

## Panel

The curve is the sum of the four filters and the output level. Each band has a handle on it: drag it to set the frequency and the gain of the band, and it follows the pointer one to one. A cut or a notch has no gain, so its handle only slides. Double-click a handle to flatten the band.

Pick a band by its number or its handle, and its type, frequency, gain and width appear under the curve, the unused ones drawn off. Pass `signal`, the device's live sound from [`useDeviceSignal`](/docs/hooks/use-device-signal), to draw the spectrum of what comes out behind the curve.

The type of a band decides what it uses:

| Type | Gain | Width |
| --- | --- | --- |
| Low cut, high cut | No | Yes |
| Notch | No | Yes |
| Low shelf, high shelf | Yes | No |
| Bell | Yes | Yes |

The cuts are 12 dB per octave, which is what a browser filter node does.

```tsx
import { EqualizerPanel } from "@/components/audio-ui/devices/equalizer/panel";
import { equalizerDevice } from "@/components/audio-ui/devices/equalizer/device";

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

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

## Engine

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

Four `BiquadFilterNode`s in series and an output gain. The curve is drawn from the same formulas the node runs, and the width of a band goes through `toWebAudioQ` on the way to the node, so the two agree. Off, every band goes flat and the output goes to 0 dB.

## Measure your engine

A host that brings its own engine can check it against what the panel draws. See [Measure your engine](/docs/devices#measure-your-engine): it works for the equalizer, the filter and the channel EQ.
