LabDAW

Mixer

The mixer of an arrangement, controlled: a channel for each track and return with pan, sends, fader, meter, peak, solo and mute, then the main track, every meter reading the real signal of its channel.

Audio UI

A channel for each track and each return track, then the main track. Each channel has its pan, its sends, its fader, its meter and its loudest peak, and Solo, Mute and, for a track that records, an Arm light. It is built from the Knob, Fader and Meter, and it is the mixer a workstation shows under its tracks: the state is an arrangement, and every change is one of its commands.

Installation

pnpm dlx shadcn@latest add @audio-ui/block-mixer

Usage

mixer-view (npx shadcn@latest add @audio-ui/mixer-view) is the view on its own. It is controlled: the arrangement comes in through useArrangement, and every change goes out as a command or through onMix.

import { MixerView } from "@/components/audio-ui/mixer-view";

<MixerView
  arrangement={arrangement} // useArrangement
  engine={engine} // useArrangementEngine: the position and each channel's meter
  onMix={automation.changeMix} // a fader, a pan or a switch of a channel
  onSelectTrack={setSelected}
  overridden={automation.overridden} // what was moved by hand, by track
  selectedTrack={selected}
/>;

armed and onArm add an Arm light to the channels of tracks that record. Leave them out and no channel has one.

A channel

  • Pan and sends are knobs, dragged up and down; a send is a small knob for each return track. A channel with no output, such as a MIDI track with no instrument, has none of them, nor a fader or a peak.
  • The fader runs from silence to +6 dB, 0 dB by default, and a double-click sets it back to 0. It is the same fader as the track's in the arrangement: one moves the other.
  • The meter shows the channel's peak and its level, after its fader and its switches; the main track has a scale beside its own.
  • The peak is the loudest sample the channel has played, in dB, in a pill over its pan. It turns red past 0 dBFS, and a click clears it.
  • The loudness of the mix, in the main track's channel under its fader: its integrated loudness in LUFS since it was last cleared, what streaming services and broadcasters hold a file to (-14 LUFS for streaming). A click clears it.
  • Solo, Mute and Arm are the same state as the track's header in the arrangement, in one group.

The main track stays in sight at the right, apart from the channels by a line, while the channels scroll; the return tracks follow the tracks' channels and scroll with them. A channel moves by its name: dragged, or picked up with Space or Enter, moved with the arrows, Home and End, dropped with Space or Enter and put back with Escape. Each step is announced, a group moves with its tracks, and the arrangement's rows follow once it lands. A track in a group names the group it plays into.

Meters

The meters read the engine's channels: engine.meter(id) gives the AnalyserNodes of a track, and a meter takes a live source, so a channel costs no React render per frame. useAudioLevels makes one from the analysers:

import { Meter } from "@/components/audio-ui/meter";
import { useAudioLevels } from "@/hooks/use-audio-levels";

const levels = useAudioLevels(analysers); // memoize the array: a new one restarts sampling

<Meter aria-label="Drums level" peakMarks="hidden" source={levels} />;

The level is the RMS of the time-domain samples in dB. It rises at once and falls back at 30 dB a second, so a drum hit reads as a hit and does not flicker. Nothing is published while the signal is silent. The analysers are never connected to ctx.destination, so reading a level plays nothing.

Over an engine of your own

The view asks three things of the engine: position, a live source of seconds, meter(id), the analysers of a track by its id, or null when there are none yet, and tap(id), the node the main track's sound passes through after its volume, which its loudness is read from (useLoudness), or null. Any engine that gives those, an AudioWorklet or WASM one, drives the view; the commands of the arrangement tell it what to play.

Accessibility

Every control is a native input behind its own role: the pan is a slider named "Drums pan" and the volume "Drums volume", and mute and solo are toggle buttons, "Mute Drums" and "Solo Drums". A channel is a group with the track's name, so a screen reader reads "Drums, group" then each control, and tabbing goes through its pan, sends, volume, then its switches, then the next track. The faders and knobs take the arrow keys, Home and End.

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