LabDAW

Filter

A filter device: a type, six circuits, a cutoff, a resonance and a drive, a panel with a handle on the curve and a live spectrum, a Web Audio engine and tools for agents.

Audio UI

Takes part of the spectrum out: a low-pass, a high-pass, a band-pass or a notch, through a circuit modeled on an analog one. It is a device: a state, a panel, an engine and tools, each its own file.

Installation

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

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

Controls

Controls · 6

Panel

The panel draws the curve of the filter, with a handle on it, and picks the circuit in its title bar, those without the type greyed out. Pass signal, the device's live sound from useDeviceSignal, to see the spectrum of what comes out behind the curve. filterCurve(state) is the curve it draws: an analog circuit's is measured on it, its response to a click too quiet to saturate, read at each frequency the plot draws.

import { FilterPanel } from "@/components/audio-ui/devices/filter/panel";
import { filterDevice } from "@/components/audio-ui/devices/filter/device";

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

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

Engine

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

A circuit runs on the audio thread: the kernels of @audio/filter-moog-ladder, @audio/filter-diode-ladder, @audio/filter-korg35 and @audio/filter-oberheim in an AudioWorklet loaded from a blob, 128 frames at a time, about a percent of a core at most. A worklet cannot import, so the device carries their code as published (FILTER_KERNELS, in its kernels.ts), at the versions the registry was built with; the curve reads the packages as installed. A change of circuit or type is a message, the new one starting from rest. Until it has loaded, and in a context with no worklets, the signal passes unchanged: ready resolves once it is in the graph. circuitSettings(state) is what goes on it, and circuitMakeup how its level is brought back.

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