Value of controls at the very begining

Honestly, I’m starting to get despaired to ever understand SC… Every single move I do I’m falling into something of which I don’t grasp the logic.

This one:

({
	var i=0;
	var trig2=1; //0;
	var trig1=0; // 1;
	i=Impulse.kr(1);
	trig1=Trig1.kr(i,0.4);
	trig2=Trig1.kr((1-trig1),0.32);
	[Trig.kr(i,0.01),trig1, (1-trig1), trig2];
	
}.plot(5);)

What I expect is that at every impulse, the trig1 stays at 1 for 0.4sec and when falling to 0, trig2 raises from 0 to 1 for 0.32.

It’s working fine expect at the start where trig2 starts at 1 instead of 0 as if it was triggered by something… I can’t see what would be the “non-positive to positive” signal that is instructing him to raise to 0…

What’s the logic here ?

There’s none, it’s a bug:

Unfortunately some UGens show unreliable behavior at initialization. As a rule of thumb, double check what exacty is going on at init if something (like here) is heavily depending on it. I have been fooled several times by similar bugs.
The good news is that there are almost always reliable workarounds. E.g. in the above thread I suggested Dseq + ToggleFF. Duty is also often quite practical and – to my experience – reliable at init time.

1 Like

Still a sore point with me that we won’t fix it. (Oops, that’s a different issue… this looked like the Impulse init bug, which is quite bad but IIRC is unlikely to be fixed.)

hjh

Here is a workaround for that. Not perfect, but it works.

({
var i=0;
var trig2=1; //0;
var trig1=0; // 1;
i=Impulse.kr(1);
trig1=Trig1.kr(i,0.4);
trig2=Trig1.kr((1-trig1)*EnvGen.kr(Env([0,0,1], [0.1, 0])),0.32);
[Trig.kr(i,0.01),trig1, (1-trig1), trig2];

}.plot(5);)
1 Like

A bug !!! Gosh ! Hours spent trying to look for a logic in a bug… Some day, I’ll be confident enough to distinguish bugs from normal behaviours.
Solved with the ToggleFF .

1 Like