Audio UI
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: a state, a panel, an engine and tools, each its own file.
Installation
Copy to Clipboardpnpm dlx 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.
Controls
Controls · 6
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, to see the spectrum of what comes out behind the curve.
Copy to Clipboardimport { 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.
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 of the device.