Hi all.
I’m building a large subtractive synth in one SynthDef that I can use for many different uses. I want to implement presets for this synth, and recently discovered the ‘variants’ option of SynthDef.new. It’s really powerful, and a clean way to code presets in my opinion.
I can use these variants in a Pdef/Pbind, but if I do this I cannot then use the Pbind arguments to change argument values further. I would want to have this control in a live performance to tweak aspects of one of my presets on-the-fly, for example. See code example below - if I set an argument in ‘variants’ and use that variant in a Pbind, any further changes later in the Pbind seem to be ignored.
(
SynthDef.new(\testsynth, {
// lpf is set to 6000 by default
arg freq = 440, amp = 0.5, out = 0, pan = 0, gate = 1, lpf = 6000;
var sig, env;
env = Env.perc().kr(2);
sig = WhiteNoise.ar(amp);
sig = sig * env;
sig = LPF.ar(sig, lpf);
Out.ar(out, Pan2.ar(sig, pan));
},
// lpf is set to 500 by the variant, if applied
variants: (testvariant: [lpf: 500])
).add;
Pdef(\test, Pbind(
\instrument, 'testsynth.testvariant',
// if variant is used, argument below is ignored
\lpf, 5000,
));
)
Am I just using Pbind and variants incorrectly?