Hello, I am trying to re-trigger an envelope after the synth is created. I found this StackOverflow post, but it’s unclear to me how it works.
The issue seems to be that as long as the argument that re-triggers the pitch envelope starts with t_
it works, but all other argument names do not. So wired. Here is an example:
(
SynthDef(\test,
{
|freq = 300, gate = 1, amp = 0.2, t_ = 0, pDec = 1|
var sig, aEnv, pEnv;
aEnv = EnvGen.kr(Env.cutoff(5, curve: \exp), gate, doneAction:2);
pEnv = EnvGen.kr(Env.new([0, pDec], [1], \sine), t_) * freq;
sig = SinOsc.ar(freq + pEnv, mul: amp * aEnv);
Out.ar(0, sig ! 2);
}
).add;
)
x = Synth(\test);
x.set(\t_, 1, \pDec, 1);
x.set(\t_, 1, \pDec, 10);
x.set(\t_, 1, \pDec, 5);
Each subsequent set
changes the pitch of the output. This other example however only lets me trigger the pitch env once. The only difference I can tell is the argument name changed from t_
to p_
. Is there something special about this name?
(
SynthDef(\test,
{
|freq = 300, gate = 1, amp = 0.2, p_ = 0, pDec = 1|
var sig, aEnv, pEnv;
aEnv = EnvGen.kr(Env.cutoff(5, curve: \exp), gate, doneAction:2);
pEnv = EnvGen.kr(Env.new([0, pDec], [1], \sine), p_) * freq;
sig = SinOsc.ar(freq + pEnv, mul: amp * aEnv);
Out.ar(0, sig ! 2);
}
).add;
)
x = Synth(\test);
x.set(\p_, 1, \pDec, 1);
x.set(\p_, 1, \pDec, 10);
x.set(\p_, 1, \pDec, 5);
Thanks,