Developers5 of 7
Declaring parameters
Faders, toggles, colours, triggers.
Declared parameters are a sketch's live controls. Declare once at startup; read the live values every frame.
sialk.parameters.declare({
speed: { type: 'number', min: 0, max: 4, default: 1, label: 'Speed' },
glow: { type: 'number', min: 0, max: 1, default: 0.3 },
invert: { type: 'boolean', default: false },
mode: { type: 'enum', options: ['rings', 'bars', 'dust'], default: 'rings' },
tint: { type: 'colour', default: '#ffbb66' },
burst: { type: 'trigger' },
});
Each becomes a control:
| You declare | The performer gets |
|---|---|
number |
a fader |
boolean |
a toggle |
enum |
buttons |
colour |
a swatch |
trigger |
a FIRE button |
Reading them
sialk.parameters.values is one object for the sketch's whole life,
mutated in place. Read it in the draw loop:
function draw() {
const p = sialk.parameters.values;
background(0);
rotate(frameCount * 0.01 * p.speed);
if (p.invert) filter(INVERT);
}
Do not destructure it once at startup: you will read the defaults forever.
Give every number a min and a max
No range, no fader.
Modulation reads the range too: reach is in the parameter's own units, so a sensible min and max makes modulation usable. See modulation.
Label them
label is what a performer reads at a dark desk. glow is a variable name;
Glow amount is a label.
Triggers
A trigger has no value; it fires. Read it as an event, not a state:
let bursts = 0;
function draw() {
if (sialk.parameters.values.burst > bursts) {
bursts = sialk.parameters.values.burst;
// the button was pressed
}
}
Declaring nothing is fine
Purely audio-reactive sketches are fine. No parameter group; the layer still has its own four: scale, position, rotation.