Link params
Make one knob drive others, like a macro.To make one param move others (a macro, a linked pair, a one-knob morph), override
onParamChanged. It runs off the audio thread on a discrete edit, and ctx.setParam
moves another param through the normal undo path, so the whole gesture is one undo entry.
const MACRO = 0, A = 1, B = 2;
onParamChanged(index: i32, ctx: ControlCtx): void {
if (index == MACRO) {
const v = ctx.param(MACRO);
ctx.setParam(A, v); // A follows the macro
ctx.setParam(B, 1.0 - v); // B runs the other way
}
}Note
onParamChanged fires on discrete edits: a knob release, a preset load,
an automation point. It does not fire for continuous modulation, which flows
through ctx.modulatedParam(idx, i) in process.
Reference another param by name with ctx.paramIndex("id") if you don't want to track
indices. Full handler list in the control surface
reference.