LabDAW

Chorus

A chorus device: a rate or a note value, a depth, a delay, one to eight voices and a mix, a panel that draws the sweep of each voice, a Web Audio engine and tools for agents.

Audio UI

Thickens the sound with a short delay that a slow oscillator sweeps up and down, or up to eight of them, swept in turn. It is a device: a state, a panel, an engine and tools, each its own file.

Installation

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

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

Controls

Controls · 8

Panel

The panel draws the delay time of each voice over two seconds as its oscillator moves it. chorusSweep(state, tempo, voice) is what it draws for a voice. With Sync on, it draws the oscillator at the rate it really has.

import { ChorusPanel } from "@/components/audio-ui/devices/chorus/panel";
import { chorusDevice } from "@/components/audio-ui/devices/chorus/device";

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

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

Engine

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

One voice is a delay node: the output of the oscillator, scaled by the depth, is added to its time. The sweep is kept inside the delay, so the time never goes negative.

Two to eight voices run on the audio thread: the kernel of @audio/effect-chorus in an AudioWorklet loaded from a blob (CHORUS_WORKLET is its source), 128 frames at a time, its depth the same sweep as a share of the delay. The kernel averages its voices, and on a full sound they hardly correlate, so the worklet raises them by the square root of their count. A worklet cannot import, so the device carries the kernel as published (CHORUS_KERNELS, in its kernels.ts). The worklet is fed only while more than one voice plays. Until it has loaded, and in a context with no worklets, the chorus plays one voice: ready resolves once it is in the graph.

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