Lab

arrangement

The document of an arrangement of clips on tracks: its clips, tracks and mixes, how far a clip reaches, where a MIDI clip's notes play, and what a track's volume and pan automation gives at a point of the song

pnpm dlx shadcn@latest add @audio-ui/arrangement
import { deviceParameterKey, parseDeviceParameter, macroIndex, FULL_ZONE, inZone, /* … */ } from "@/lib/arrangement";
Fileslib/arrangement.ts
Depends onNothing
npm@audio-ui/core, @audio-ui/engine, @audio-ui/react
Used byarranged-clip, arrangement-editor, arrangement-engine, arrangement-view, block-audio-editor, block-device-chain, block-mixer, block-timeline, clip-waveform, dawproject, device-view, drum-kit, drum-rack, drum-rack-panel, instrument-rack, midi-clip-panel, mixer-view, rack, rack-panel, recording, timeline, track-automation, use-arrangement, use-time-selection, use-timeline-cursor
ExportKindWhat it is
ClipActiontypeWhat a clip's menu does to it.
ArrangedinterfaceA clip laid on a track of an arrangement.
TrackKindtypeWhat a track holds: audio clips, MIDI clips, or other tracks (a group, which holds no clip and plays what its tracks play).
DeviceParameterKeytypeA parameter of a device on a track, by the device's id and the parameter's, at any depth of its racks: device:<device>:<parameter>.
AutomatedParametertypeWhat a track's automation can move: its volume, where it sits in the stereo field, or a parameter of one of its devices.
deviceParameterKeyconstThe key a device's parameter is automated under.
parseDeviceParameterfunctionThe device and the parameter a key names, or null for the track's own volume and pan.
macroIndexfunctionThe index of a rack's macro a parameter id names, macro-1 to macro-8, or -1.
TrackAutomationtypeA track's automation: for each parameter it moves, the points of its envelope across the whole arrangement, x from its start (0) to its end (1) and y the parameter's value from 0 to 1, with the curve of the segment leaving each point.
TrackDeviceinterfaceA device on a track's chain: which one (its stable id, such as audioui.compressor), its state, and whether it is switched on.
RackChaininterfaceA chain of a rack: devices in series, and how loud and where it sits in what the rack sums.
ChainZoneinterfaceThe notes a chain of an instrument rack plays: its keys, lowest to highest pitch, and its velocities, 0 to 1, both ends in.
FULL_ZONEconstThe zone of a chain with none: every key, every velocity.
inZonefunctionWhether a chain plays a note of pitch struck as hard as velocity: inside its keys and its velocities.
DrumVoicetypeThe voices of the drum synthesis a pad can play.
DrumSoundtypeWhat a pad of a drum rack plays: a voice of the drum synthesis, or a recording, tune semitones from its own pitch, for decay seconds (a recording ends sooner when it is shorter).
DrumPadinterfaceThe note a chain of a drum rack answers, 0 to 127, and what it plays: the instrument at the head of its chain, such as a Drum Synth, or else sound.
RackMappinginterfaceA parameter a macro turns: the device by its id, and the stretch of the parameter's travel the macro's turn covers, 0 to 1 of it.
RackMacrointerfaceA knob of a rack, 0 to 1, that turns the parameters mapped to it together.
RackinterfaceDevices in parallel chains, summed, and eight macros over the devices inside.
RACK_DEVICEconstThe id a rack's track device carries in place of a device of the library.
MACRO_COUNTconstHow many macros a rack has.
newRackfunctionA rack with one chain holding devices, and its eight macros at rest, turning nothing.
INSTRUMENT_RACK_DEVICEconstThe id an instrument rack's track device carries: an instrument whose chains each start with an instrument, played together by every note.
DRUM_RACK_DEVICEconstThe id a drum rack's track device carries: an instrument whose chains are pads, each played by a note.
DRUM_DECAYSconstHow long each voice of the drum synthesis rings by default, in seconds.
SAMPLE_DECAYconstHow long a recording on a pad plays by default, in seconds, unless it ends sooner.
newDrumRackfunctionThe kit a drum rack starts with: a kick on C2, a snare on D2 and a closed hat on F#2 (notes 36, 38 and 42), given the ids of their chains.
padRecordingsfunctionThe recordings the pads of tracks' drum racks play: what a project keeps with its clips' recordings.
renamePadRecordingsfunctionA track whose drum racks' pads play the recordings rename gives for theirs: what a project opened under new recording ids needs.
rackDevicesfunctionEvery device inside a rack, down the racks within it.
TrackColortypeA track's color: an index into the colors the timeline offers, or a color of the user's own as a CSS hex such as #3e63dd.
ArrangementTrackinterfaceA track of an arrangement.
MixinterfaceWhat a track's header sets: how loud it is, where it sits in the stereo field, and whether it is silenced or soloed.
UNITY_MIXconst
mixOffunctionWhat a track's header shows: its mix, over unity, with the track's own color.
NEW_TRACKconstWhere files or a device dropped on the add-track button go: a track of their own.
hasOutputfunctionWhether a track has an output: a MIDI track with no instrument has none, so no volume, pan or sends (MIX-024).
automatedParameterfunctionThe parameter a track's lane shows in automation mode: the one shown, or for a track with no output, whose volume and pan are gone (MIX-024), its first device parameter.
clipReachfunctionHow far a clip can be stretched on the timeline: undefined when it loops, since it has no end then, as far as its warp stretches its source when it is warped, otherwise the length of its source.
ClipPeakstypeA recording's shape: an amplitude per slice from 0 to 1, or its lowest and highest samples, from -1 to 1.
ClipReadingtypeWhat reading a clip's recording takes: how it plays, not where it lies.
clipPeakCountconstHow many slices peaks holds.
clipFramePositionsfunctionWhere each column edge of a stretch of a clip reads its recording, in frames of the source: columns + 1 positions, fractional, from the first column's left edge to the last one's right edge, as a player reads it.
framesToReadfunctionThe frames to read for positions: from the first one any column touches to one past the last, within the source's frames.
sampleBandsfunctionThe lowest and highest sample each column covers, from -1 to 1, from the samples values read from frame first: the same bands as clipWaveformBands, sharper than the peaks allow.
sampleLinefunctionThe sound as a line through its samples, for a zoom past one frame per column: the level at each column edge, interpolated between the samples values read from frame first, and each sample's place, as a fractional column, with its level.
clipWaveformfunctionWhat an audio clip shows of its recording across its length, columns amplitudes from 0 to 1, from the peaks of its source (peaks, spread evenly over sourceLength): the stretch it plays, folded round its loop, mirrored when reversed, stretched by its warp, as a player reads it.
clipWaveformBandsfunctionThe same read as clipWaveform, for each column the highest and the lowest it reaches, from -1 to 1: the sound as it is, lopsided where it is.
TimeSelectioninterfaceA stretch of time on some tracks: what a drag across bare lanes selects.
ClippinginterfaceWhat a copy holds: how long it is, and the part of each clip in it, from 0, with how many tracks below the first one it came from.
ClipScaleinterfaceA MIDI clip's scale: a root (0 for C) and a scale's name, kept while it is off.
ClipSwinginterfaceHow a MIDI clip swings: amount from 0, straight, to 1, where an off-beat plays a third of a step late, as in a triplet; division is the step that swings, an eighth or a sixteenth.
swungTimefunctionWhere time plays once swung on steps step long: the even steps stay, the odd ones are pushed late by amount of a third of a step, and the time between moves in a straight line, so no two notes ever change places.
PlayedNoteinterfaceWhere a note of a MIDI clip plays in the arrangement, transposed with the clip.
playedNotesfunctionThe notes a MIDI clip plays, where they play in the arrangement: the ones starting inside it, from where it starts in its source, and round its loop again and again when it has one.
volumeGainfunctionA volume envelope's value, 0…1, as a gain: 0 is silence, then -60 dB up to +6 dB along the way.
volumeValuefunctionThe volume envelope's value, 0…1, that plays at gain: unity is 0 dB.
panPositionconstA pan envelope's value, 0…1, as a pan from -1 (left) to 1 (right).
flatAutomationfunctionWhere a parameter's envelope starts when it is first drawn: the mix's value, flat.
automationAtfunctionAn envelope's value at x, 0…1 of the arrangement: along the curve of the segment it falls in, the first point's value before it, the last's after.
devicePositionsfunctionWhere each automated device parameter of a track stands at x, 0…1 of the arrangement, as a position along its travel from 0 to 1, by device then parameter; one a change by hand has overridden plays as it is set.
EDGE_FADE_SECONDSconstThe fade a clip laid down gets at each edge, in seconds: enough to take the click off a cut.
withEdgeFadesfunctionA clip's fades as it is laid down: EDGE_FADE_SECONDS at each edge, or half its length when it is shorter.
warpOnImportfunctionA clip of a recording just brought in, warped in Beats so it plays in time at tempo (CLP-019): a short loop as that loop, any other on the first beat of each bar, starting on its first beat and as long as the whole recording plays.
withCrossfadesfunctionA track's played clips with their crossfades: two that meet with fades of one length play through each other.
rackWithMacrosfunctionA rack with each macro an envelope moves where turned has it, by its parameter id.
withoutDeviceAutomationfunctionA track's automation without the envelopes of the devices gone; the same one when it had none of theirs.
mixAtfunctionA track's gain and pan at x, 0…1 of the arrangement: its envelopes where it has them, its mix where it has none or where a change by hand has overridden them, until the automation is enabled again.

Usage

The arrangement as one document: its tracks (with their mixes, device chains, sends, groups and racks), its clips, tempo, time signatures, locators, loop and length, and what is read from them. It holds the types and the reads; the edits are commands in arrangement-state, installed with useArrangement.

import { clipReach, mixOf, playedNotes } from "@/lib/arrangement";

const mix = mixOf(track); // its volume, pan, switch and sends
const notes = playedNotes(clip); // a MIDI clip's notes as it plays them, its loop and transpose applied
const reach = clipReach(clip); // how far it may be stretched: undefined when it loops

Everything the Arrangement, its clip views and the arrangement engine read comes from here, so a host's own engine reads the same document.

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