Audio UI
Repeats the sound. The echoes fade by the feedback, each darker than the one before. 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/delay
It installs the device's state, its engine and its panel to components/audio-ui/devices/delay/. The demo above, which wires them to a loop, is @audio-ui/block-delay.
Controls
Controls · 12
Panel
The panel draws the echoes the state makes, one line each, fainter as they fade: a multitap's every half time. delayTaps(state, windowMs) returns them. With Sync on, the handle lands on the nearest note value and the Time control is drawn off. With Sync off, the note list is. The mode is picked in the title bar, and the grain delay's pitch, spray, jitter and grain size show with it alone.
Copy to Clipboardimport { DelayPanel } from "@/components/audio-ui/devices/delay/panel"; import { delayDevice } from "@/components/audio-ui/devices/delay/device"; const [state, setState] = useState(() => delayDevice.defaults()); <DelayPanel onValueChange={setState} value={state} />;
Engine
Create it, connect it and update it as for any device: see The engine.
The repeats go round a low-pass filter, so each is darker than the one before. A change of time glides slowly, so the echo bends like a tape instead of clicking, and the feedback stops short of 95 % so it cannot run away. A note longer than the delay can hold (two seconds) is held to that. The 1/8d the block starts on is a dotted eighth at the loop's 100 BPM, 450 ms.
The ping-pong, multitap and grain modes run on the audio thread: the kernels of @audio/effect-pingpong, @audio/effect-multitap and @audio/effect-graindelay in an AudioWorklet loaded from a blob, 128 frames at a time, their wet sound through a tone filter of its own. A worklet cannot import, so the device carries their code as published (DELAY_KERNELS, in its kernels.ts). A multitap's and a grain delay's lines are made as long as the longest settings need, so a multitap's time glides and a grain delay's grains follow every knob at once. A ping-pong's line is as long as its time: a new time waits for the knob to rest, then fades in on a fresh line as the old one fades out, as does a change of mode. The worklet is fed only while one of its modes plays, and until it has loaded, and in a context with no worklets, they play the echo: ready resolves once it is in the graph.