LabDAW

Mid/side

A mid/side device: a widening, a level for the centre, a level for the sides and a bass mono frequency, a panel with one handle for the two levels, a Web Audio engine and tools for agents.

Audio UI

Sets the centre and the sides of a stereo signal apart. The mid is what both channels share, such as a kick or a voice, and the side is what sets them apart, such as a wide pad. Each has its own level, and Bass mono takes the lows out of the side so everything under a frequency sits in the middle. Widen makes sides first, even from a mono sound, for the side level to set. For a gain, a pan or a single width control, use the utility. It is a device: a state, a panel, an engine and tools, each its own file.

Installation

pnpm dlx shadcn@latest add @audio-ui/mid-side

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

Controls

Controls · 8

Panel

The panel is a square with the side level across and the mid level up, and one handle to drag to both at once. The crossing of the two lines is a signal left as it is. The widening is picked in its title bar.

import { MidSidePanel } from "@/components/audio-ui/devices/mid-side/panel";
import { midSideDevice } from "@/components/audio-ui/devices/mid-side/device";

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

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

Engine

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

The signal is split into mid, (L + R) / 2, and side, (L - R) / 2. Each has its own gain, and the output is L = mid + side and R = mid - side. A mono input is spread to both sides first, so it is all mid. Off, both levels are unity and the sides keep their lows.

Haas is a delay node on the right channel. Detune runs on the audio thread: the shifters of @audio/spatial-microshift, two read heads that glide through a 50 ms ring and cross-fade, in an AudioWorklet loaded from a blob (DETUNE_WORKLET is its source), 128 frames at a time. A worklet cannot import, so the device carries the module as published (MID_SIDE_KERNELS, in its kernels.ts). A new detune fades in on a fresh pair of shifters, run through the last 50 ms of sound first so it sounds at once. The worklet is fed only while Detune plays. Until it has loaded, and in a context with no worklets, Detune passes the sound as it is: ready resolves once it is in the graph.

Bass mono is a high-pass on the side only. It is a second-order Butterworth filter, so the sides are 3 dB down at the frequency, and a signal in the centre is untouched.

Measured in Chrome, with the levels at 0 dB a centre signal and a side signal come out as they went in. A mid of -6 dB takes 6 dB off a centre signal and nothing off a side one, and a side of -24 dB or +6 dB moves a side signal by that much and leaves a centre one alone. With Bass mono at 200 Hz, a side signal at 50 Hz is 24 dB down, one at 100 Hz is 12 dB down, one at 400 Hz is 0.3 dB down and one at 2 kHz is untouched, and a centre signal at 50 Hz is untouched.

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