Audio UI
Sweeps notches through the sound with a slow oscillator. In Phaser mode it is a chain of four all-pass filters around a centre frequency. In Classic mode it is 2 to 12 first-order all-pass stages, as analog phasers have. In Flanger mode it is a very short delay. 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/phaser
It installs the device's state, its engine and its panel to components/audio-ui/devices/phaser/. The demo above, which wires them to a loop, is @audio-ui/block-phaser.
Controls
Controls · 11
Panel
The panel draws what the oscillator does over two seconds, and picks the mode in its title bar. phaserSweep(state) is what it draws, and phaserSettings(state) gives the numbers that go on the nodes.
Copy to Clipboardimport { PhaserPanel } from "@/components/audio-ui/devices/phaser/panel"; import { phaserDevice } from "@/components/audio-ui/devices/phaser/device"; const [state, setState] = useState(() => phaserDevice.defaults()); <PhaserPanel onValueChange={setState} value={state} />;
Engine
Create it, connect it and update it as for any device: see The engine.
The phaser and flanger paths are always built and the mode crossfades them, so switching does not click. One oscillator moves the filters, in cents, and the delay, in seconds. The flanger's sweep is kept inside its delay so the time never goes negative.
The classic phaser runs on the audio thread: the kernel of @audio/effect-phaser in an AudioWorklet loaded from a blob (PHASER_WORKLET is its source), 128 frames at a time, with its own oscillator. A worklet cannot import, so the device carries the kernel as published (PHASER_KERNELS, in its kernels.ts). The worklet is fed only while Classic plays. Until it has loaded, and in a context with no worklets, Classic plays the phaser: ready resolves once it is in the graph.