pnpm dlx shadcn@latest add @audio-ui/arrangement
import { deviceParameterKey, parseDeviceParameter, macroIndex, FULL_ZONE, inZone, /* … */ } from "@/lib/arrangement";| Files | lib/arrangement.ts |
|---|---|
| Depends on | Nothing |
| npm | @audio-ui/core, @audio-ui/engine, @audio-ui/react |
| Used by | arranged-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 |
| Export | Kind | What it is |
|---|---|---|
ClipAction | type | What a clip's menu does to it. |
Arranged | interface | A clip laid on a track of an arrangement. |
TrackKind | type | What a track holds: audio clips, MIDI clips, or other tracks (a group, which holds no clip and plays what its tracks play). |
DeviceParameterKey | type | A 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>. |
AutomatedParameter | type | What a track's automation can move: its volume, where it sits in the stereo field, or a parameter of one of its devices. |
deviceParameterKey | const | The key a device's parameter is automated under. |
parseDeviceParameter | function | The device and the parameter a key names, or null for the track's own volume and pan. |
macroIndex | function | The index of a rack's macro a parameter id names, macro-1 to macro-8, or -1. |
TrackAutomation | type | A 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. |
TrackDevice | interface | A device on a track's chain: which one (its stable id, such as audioui.compressor), its state, and whether it is switched on. |
RackChain | interface | A chain of a rack: devices in series, and how loud and where it sits in what the rack sums. |
ChainZone | interface | The notes a chain of an instrument rack plays: its keys, lowest to highest pitch, and its velocities, 0 to 1, both ends in. |
FULL_ZONE | const | The zone of a chain with none: every key, every velocity. |
inZone | function | Whether a chain plays a note of pitch struck as hard as velocity: inside its keys and its velocities. |
DrumVoice | type | The voices of the drum synthesis a pad can play. |
DrumSound | type | What 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). |
DrumPad | interface | The 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. |
RackMapping | interface | A 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. |
RackMacro | interface | A knob of a rack, 0 to 1, that turns the parameters mapped to it together. |
Rack | interface | Devices in parallel chains, summed, and eight macros over the devices inside. |
RACK_DEVICE | const | The id a rack's track device carries in place of a device of the library. |
MACRO_COUNT | const | How many macros a rack has. |
newRack | function | A rack with one chain holding devices, and its eight macros at rest, turning nothing. |
INSTRUMENT_RACK_DEVICE | const | The id an instrument rack's track device carries: an instrument whose chains each start with an instrument, played together by every note. |
DRUM_RACK_DEVICE | const | The id a drum rack's track device carries: an instrument whose chains are pads, each played by a note. |
DRUM_DECAYS | const | How long each voice of the drum synthesis rings by default, in seconds. |
SAMPLE_DECAY | const | How long a recording on a pad plays by default, in seconds, unless it ends sooner. |
newDrumRack | function | The 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. |
padRecordings | function | The recordings the pads of tracks' drum racks play: what a project keeps with its clips' recordings. |
renamePadRecordings | function | A track whose drum racks' pads play the recordings rename gives for theirs: what a project opened under new recording ids needs. |
rackDevices | function | Every device inside a rack, down the racks within it. |
TrackColor | type | A 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. |
ArrangementTrack | interface | A track of an arrangement. |
Mix | interface | What a track's header sets: how loud it is, where it sits in the stereo field, and whether it is silenced or soloed. |
UNITY_MIX | const | |
mixOf | function | What a track's header shows: its mix, over unity, with the track's own color. |
NEW_TRACK | const | Where files or a device dropped on the add-track button go: a track of their own. |
hasOutput | function | Whether a track has an output: a MIDI track with no instrument has none, so no volume, pan or sends (MIX-024). |
automatedParameter | function | The 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. |
clipReach | function | How 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. |
ClipPeaks | type | A recording's shape: an amplitude per slice from 0 to 1, or its lowest and highest samples, from -1 to 1. |
ClipReading | type | What reading a clip's recording takes: how it plays, not where it lies. |
clipPeakCount | const | How many slices peaks holds. |
clipFramePositions | function | Where 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. |
framesToRead | function | The frames to read for positions: from the first one any column touches to one past the last, within the source's frames. |
sampleBands | function | The 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. |
sampleLine | function | The 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. |
clipWaveform | function | What 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. |
clipWaveformBands | function | The 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. |
TimeSelection | interface | A stretch of time on some tracks: what a drag across bare lanes selects. |
Clipping | interface | What 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. |
ClipScale | interface | A MIDI clip's scale: a root (0 for C) and a scale's name, kept while it is off. |
ClipSwing | interface | How 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. |
swungTime | function | Where 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. |
PlayedNote | interface | Where a note of a MIDI clip plays in the arrangement, transposed with the clip. |
playedNotes | function | The 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. |
volumeGain | function | A volume envelope's value, 0…1, as a gain: 0 is silence, then -60 dB up to +6 dB along the way. |
volumeValue | function | The volume envelope's value, 0…1, that plays at gain: unity is 0 dB. |
panPosition | const | A pan envelope's value, 0…1, as a pan from -1 (left) to 1 (right). |
flatAutomation | function | Where a parameter's envelope starts when it is first drawn: the mix's value, flat. |
automationAt | function | An 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. |
devicePositions | function | Where 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_SECONDS | const | The fade a clip laid down gets at each edge, in seconds: enough to take the click off a cut. |
withEdgeFades | function | A clip's fades as it is laid down: EDGE_FADE_SECONDS at each edge, or half its length when it is shorter. |
warpOnImport | function | A 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. |
withCrossfades | function | A track's played clips with their crossfades: two that meet with fades of one length play through each other. |
rackWithMacros | function | A rack with each macro an envelope moves where turned has it, by its parameter id. |
withoutDeviceAutomation | function | A track's automation without the envelopes of the devices gone; the same one when it had none of theirs. |
mixAt | function | A 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 loopsEverything the Arrangement, its clip views and the arrangement engine read comes from here, so a host's own engine reads the same document.