How to view the Linen.kr envelope shape

Is there a way to plot or view the shape of the Linen.kr envelope? I’ve tried the following but it doesn’t work.

Linen.kr(gate, attackTime:0.0, susLevel:1.5, releaseTime:1, doneAction: Done.freeSelf).plot;

If you plot a UGen or an array of UGens, then you must enclose it with a pair of curly brackets. Thus your code

Linen.kr(gate, attackTime:0.0, susLevel:1.5, releaseTime:1, doneAction: Done.freeSelf).plot;

should be rewrittne as follows:

{ Linen.kr(gate, attackTime:0.0, susLevel:1.5, releaseTime:1, doneAction: Done.freeSelf) }.plot // it does not still work.

However, the word gate is not accepted: sclang thinks this is a variable, but it is not declared. Moreover, you should change the value is changed from 1 to 0 to release the envelope according to the help document of Linen. You can do this by using an Impulse for example:

{ Impulse.kr(0) }.plot // By default, the value changes in 64 samples of the sample-rate of the server.

or

{ Impulse.ar(0) }.plot // the value changes in a sample of the sample-rate of the server.

.kr(0)

and

.ar(0)

means Impulse is generated only one time. If you change the value, then it produces impulses according to the value per second.

Thus, the following might be what you would like to have:

{ Linen.kr(Impulse.kr(0), attackTime:0.01, susLevel:0.5, releaseTime:1, doneAction: Done.freeSelf) }.plot(3);

plot(3) means plot for 3 seconds, and you need to wait 3 seconds to see the result.

1 Like

i’d personally recommend Env.asr over Linen (there is an Env.linen, but it’s a little different):

Env.asr(0, 1.5, 1, \lin).kr(Done.freeSelf, gate)

Env gives you a lot more nice options, including curved segments (which sound more realistic than linear ones in the context of amplitude envelopes). and, of course, you can plot an Env directly:

Env.asr(0, 1.5, 1, \lin).plot
1 Like

You missed the curly brackets

{ Linen.kr(LFPulse.kr(2), attackTime: 0.1, susLevel: 1, releaseTime: 0.05, doneAction: 2) }.plot(0.5);

Regards

Daniel

1 Like

Env.linen is good if you want to retrigger the envelope in a monosynth

I couldn’t figure out how to make the Linen.kr slope down with just an integer as the gate parameter but then I decided to use Env.asr as @nathan mentioned and that gave me a better sound that I was looking for but it still wasn’t quite plucky enough so then I looked through the docs and found Env.adsr and that gave me the perfect short snappy/plucky sound I was aiming for. All the replies helped me out. Here’s my basic synthdef:

SynthDef(\synth3, { | out, amp = 1 freq = 0, gate = 0.1, pan = 0, div = 6 |
     var audio = LFSaw.ar(freq, 1, amp/div, 0);
    var env = Env.adsr(0.00, 0.2, 0.1, 3, 1, -9).kr(Done.freeSelf, gate);
    Out.ar(out, Pan2.ar(audio, pan, env));
 }).add;