Free running LFOs + amp env retrigger with Pmono

hey, thanks for your reply:

when keeping the initial segment and adjusting the envelope time > sustain
you get a discontinuity.

(
SynthDef(\test, {
	var trig = \trig.tr(1);
	var trigMod = LFNoise0.ar(8);
	var sig, gainEnv;
	
	gainEnv = EnvGen.ar(Env(
		[0, 0, 1, 0], 
		[0, \atk.kr(1), \rel.kr(1)], 
		[0, \atkCurve.kr(4), \relCurve.kr(-4)]
	), trig * trigMod, doneAction: Done.none);
	
	sig = SinOscFB.ar(\freq.kr(440), \fdbk.kr(0.6));
	
	sig = sig * gainEnv;
	
	sig = Pan2.ar(sig, \pan.kr(0), \amp.kr(0.25));
	Out.ar(\out.kr(0), sig);
}).add;
)
// envelope time: atk + rel > then sustain: dur * legato

(
Pdef(\test,
	Pmono(\test,

		\trig, Pwhite(0.5, 1.0, inf),
		\legato, 1.0,
		\dur, 0.25,

		\atk, 0.01,
		\rel, 2,
		\atkCurve, 4,
		\relCurve, -4,

		\freq, 220,

		\pan, 0,
		\amp, 0.25,
		\out, 0,
	)
).play;
)

I thought when wanting to “re-trigger” from zero you need to define an initial segment. Envelope re-trigger , attack time >impulse rate - #5 by jamshark70
i think it works without the initial segment and envelope time > sustain.
this is confusing me even more actually.

ive written down some notes from different threads covering this topic, which lead to the conclusion that i need an initial segment in my Envelope when i want it to retrigger.

retriggering means that the envelope should go back to its initial level and restart from there.
You don’t want an envelope to jump immediately from one level to another level.
Envelope generators avoid discontinuities by defining an envelope segment: “start from where you are now, and proceed towards the target in the requested amount of time.”

it’s “start from current level, go toward 1.” (So what about the initial 0? That’s used to initialize the envelope generator once and only once, at the start of the synth.)

If you want a retrigger to reset to zero, you have to define the reset in the Env.

like in this example:

(
SynthDef(\retrig_env, {
	var sig, trig, freqEnv;
	trig = Impulse.ar(1);
	freqEnv = EnvGen.ar(Env([0, 0, 1, 0], [0.001, \atk.kr(0.5), \rel.kr(0.5)], [0, 0, (-20)]), trig, doneAction: Done.none);
	sig = Formant.ar([110,108], \formFreq.kr(9500) * freqEnv, \bw.kr(88));
	sig = sig * \amp.kr(0.3);
	Out.ar(\out.kr(0), sig);
}).add;
)

x = Synth(\retrig_env, [\atk, 0.5, \rel, 0.5]);
x = Synth(\retrig_env, [\atk, 0.5, \rel, 3]);