@maruaudio/dsp/control/param-macros defines the table layout and value law that let a Processor's macro knobs drive its own parameters. A macro is a 0..1 position; what it moves is an f32 table the host stages into a data slot: a header row [version, rowCount, 0, 0, 0, 0] and up to 32 target rows [macroIndex, targetParamIndex, min, max, curveCode, 0]. Each row's value is min + (max − min) × curve(position), in the target's physical units, over the CcCurve vocabulary of @maruaudio/audio-contracts: linear, exp (v²), log (√v) and s-curve (smoothstep v²(3 − 2v)).
Functions
| Name | Inputs | Output | Domain as coded |
|---|---|---|---|
paramMacroCurve | position, curveCode | curve value in 0..1 | Position clamped to 0..1; NaN and −Infinity read as 0; an unknown code is linear |
paramMacroValue | position, min, max, curveCode | min + (max − min) × curve | min > max inverts the sweep; no clamp on min or max |
PARAM_MACRO_ROW_COLUMNS, PARAM_MACRO_MAX_ROWS, PARAM_MACRO_SLOT_ELEMENTS | constants | 6, 32, 198 | (1 + 32) × 6 elements |
PARAM_MACRO_COL_* | constants | macro 0, target 1, min 2, max 3, curve 4 | Column 5 is reserved and must be 0 |
PARAM_MACRO_CURVE_* | constants | linear 0, exp 1, log 2, s-curve 3 | CcCurve order |
PARAM_MACRO_VERSION | constant | 1 | Header column 0 |
Lifecycle
The DSP node holds no state. The owning Processor validates and copies the table when it loads the resource, and evaluates the rows when a macro changes. Resolving targetParamIndex to a parameter is the owner's dispatch, not this DSP node's.
When to use it
Let a few macro knobs sweep many parameters of one instrument at once, each with its own range and curve. The Sampler module uses it for its macro resources.
Limits
- The law is in physical units: the Processor has no descriptor tapers, so a host that wants a tapered sweep authors min, max and curve to suit.
- The log curve costs one
Math.sqrt; the rest is scalar arithmetic with no allocation.