Hi,
I’m having trouble understanding how the Env.adsr works. Running the code below I can hear the effect of the envelope on amplitude, but the sound does not go away afterwards - Am I missing something? A gate maybe? How do I make the envelope stop the sound after the release function is complete?
Thank you so much!
(
SynthDef(\envTest, {
arg atk=0.1, dec=0.2, sus=0.1, rel=0.2,
out=0, amp=0.2;
var sig, env;
env = EnvGen.ar(Env.adsr(atk, dec, sus, rel), doneAction:2);
sig = SinOsc.ar(440);
Out.ar(out, sig * amp * env);
}).add;
)
Synth(\envTest);
An ADSR envelope – in all synthesizers – stays open until it’s released by “closing the gate” (gate signal falls to 0).
You haven’t specified a gate, so it’s using the default = 1.
So your SynthDef states that the envelope should never close.
(
SynthDef(\envTest, {
arg atk = 0.1, dec = 0.2, sus = 0.1, rel = 0.2,
out = 0, amp = 0.2, gate = 1;
var sig, env;
env = EnvGen.ar(Env.adsr(atk, dec, sus, rel), gate, doneAction:2);
sig = SinOsc.ar(440);
Out.ar(out, sig * amp * env);
}).add;
)
hjh
Hi,
Thanks so much for getting back to me.
This makes sense, I think I’m being a little silly - not sure I need Env.adsr at all.
Seem to be getting what I’m after with the following:
Env([0, 1, sus, 0], [atk, dec, rel])
Thanks again for your help.