LabDAW

Distortion

A distortion device: four curves, a drive, a tone, a mix and an output, a panel that draws the transfer curve, a Web Audio engine and tools for agents.

Audio UI

Bends the sound into one of four curves. The more the drive, the more the peaks round off, or fold back. It is a device: a state, a panel, an engine and tools, each its own file.

Installation

pnpm dlx shadcn@latest add @audio-ui/distortion

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

Controls

Controls · 6

Panel

The panel draws the transfer curve, the output for each input, against the straight line of a clean sound, and picks the curve with buttons drawn from each. distortionShape(curve, input) is a curve at an input after the drive, and distortionCurve(state) is the whole curve with the mix and the output.

import { DistortionPanel } from "@/components/audio-ui/devices/distortion/panel";
import { distortionDevice } from "@/components/audio-ui/devices/distortion/device";

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

<DistortionPanel onValueChange={setState} value={state} />;

Engine

Create it, connect it and update it as for any device: see The engine.

The drive is a gain before the table of the curve, so turning it never changes the table; only picking another curve does. The tables are written by the curves of @audio/effect-distortion (distortionTable(curve)) over the whole range of the drive, so a fold keeps folding at full drive. The shaper oversamples 4x to keep the curve from aliasing, which is the latency of the device.

Built by Ouest Labs, the source code is available on GitHub.
RSS