Free running LFOs + amp env retrigger with Pmono

hey, i would like to have free running LFOs which should not restart on each event
and dont want to use additional busses for this, so i think Pmono or PmonoArtic with legato > 1 is the right choice.
Additionally I would like to retrigger the amp envelope each duration and modulate the trigger
with an LFNoise, so ive added an initial segment to the envelope with a time of 0 and no doneAction.
This setup works when the envelope time < dur, otherwise you get a discontinuity.
Ive picked up in some threads that using Pmono / PmonoArtic
without a gated envelope is undesirable, i see why.
But when using a gated envelope i dont get retriggers of the amp envelope each duration as far as im concerned.

(
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;
)

(
Pdef(\test,
	Pmono(\test,

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

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

		\freq, 220,

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

what are your suggestions for this setup?

thanks :slight_smile:

1 Like

When you say “gated envelope”, do you mean an envelope with a releaseNode (e.g. one that holds for as long as gate > 0)? With the test code you posted, I see the envelope being triggered each time you send a trig as one would expect. There’s a discontinuity because of the extra 0 at the beginning of your envelope, since when you re-trigger an envelope that transitions smoothly to the second node - usually this would be the peak of the attack, but in your case it’s 0, so you have a rapid ramp-down to 0, and then the attack.

Without the initial 0, holding the gate open also works without discontinuity - this works exactly as I would expect. If you remove the initial 0’s in your example, can you post the code where you’re not getting what you expect?

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]);

ive thought some more about that:
so you just need the initial segment for the envelope if you want to start it from its initial state when receiving a trigger before it has reached its end? otherwise it will pick up the last value and goes from there?
So then it just comes down to have the trigger frequency / duration fitting the envelope time and you dont need the initial segment for always starting from its initial state?
thanks.