Lab

rack

Racks: devices in parallel chains, each with its volume, pan, switch and solo, lined up on the slowest and summed, and eight macros that turn parameters of the devices inside over a stretch of their travel; the engine that plays one on a track's chain.

pnpm dlx shadcn@latest add @audio-ui/rack
import { heardChains, macroPositions, playedState, deviceLatency, rackLatency, /* … */ } from "@/lib/rack";
Fileslib/rack.ts
Depends onarrangement, device-library
npm@audio-ui/engine
Used byarrangement-engine, drum-rack, instrument-rack
ExportKindWhat it is
FindDevicetypeFinds a device of the library by the id a track device stores.
heardChainsfunctionThe chains a solo lets through: the soloed ones, or all of them while none is.
MacroPositionstypeWhere on its travel each mapped parameter sits, by device then parameter, from a rack's macros.
macroPositionsfunctionThe positions a rack's macros put their parameters at, over the ones a rack around it already set.
playedStatefunctionA device's state as it plays: its own, with what the macros mapped to it set.
deviceLatencyfunctionHow long a device delays the sound as it plays, in seconds: a rack, as long as its slowest chain.
rackLatencyfunctionHow long a rack delays the sound, in seconds: its slowest chain, each device on it in turn, switched on or off.
RackEngineinterfaceA rack playing on a context: one link of a chain, its sound in at input and out at output.
createRackEnginefunctionPlays racks on ctx: each chain takes the rack's input, its devices in series (one switched off passes the sound on, as late as it would make it), then waits for the slowest chain so all of them meet on the same frame, then its volume, pan and switch, summed at the output.

Usage

Devices in parallel chains, each with its own volume, pan, switch and solo, lined up on the slowest and summed, and eight macros mapped onto the parameters inside, each over a range. It is what plays a rack on a track's chain, in the arrangement engine; its face is the Rack panel.

import { createRackEngine, rackLatency } from "@/lib/rack";

const engine = createRackEngine(ctx, libraryDevice); // find: a device of the library by its id
source.connect(engine.input);
engine.output.connect(destination);
engine.update(rack, { tempo }); // the rack as the document holds it

macroPositions gives each mapped parameter's value for the macros' positions, heardChains the chains a solo leaves heard, and rackLatency(rack, find, sampleRate) how late the slowest chain is, for delay compensation; a rack's engine also says so with latency().

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