Confused by Done Ugen

I wanted to sequence three envelopes. In the snippet below, env0 should start immediately. When it is done it should trigger env1. When env1 is done it should trigger env2. The Done trigger for env1 seems to work as expected but the Done trigger for env2 seems to fire immediately - not waiting for env1 to finish. Am I misunderstanding how Done is supposed to work?

Thanks,

(
Ndef(\test, {
	
	var trig0 = 1;
	var env0 = Env([1, 2], [2], -4).kr(gate:trig0);
	
	var trig1 = Done.kr(env0);
	var env1 = Env([3, 4], [2], -4).kr(gate:trig1);
	
	var trig2 = Done.kr(env1);
	var env2 = Env([5, 6], [2], -4).kr(gate:trig2);
	
	env2.poll;
	
	Silent.ar(2);
})
)

It’s working here.

Which version? Maybe you’re seeing an old bug that was fixed?

hjh

SC version 3.10.3
Mac OSX 10.14.5 Mojave

Ok, that’s recent.

I’m not sure what the issue is, then. I tried your code and found that env2 starts at its initial level 5, and 4 seconds later, rises to 6. In my test, it definitely held 5 and did not rise immediately.

We have occasionally seen c++ compilation issues where some UGens behave differently on different platforms. Right now all we know is that there’s some strange result for you on Mac, and expected behavior for me in Linux. I think we need more people to test, to be more sure where the bug does and doesn’t occur.

hjh

just did a quick test here on Mac OS 10.14.6 with SC 3.10.2
and when polling I consistently got starts at:
//env0 UGen(EnvGen): 1.00295
//env1 UGen(EnvGen): 3
//env2 UGen(EnvGen): 5.00295

CD

That’s definitely a bug.

But it might be fixed in the development branch. The EnvGen c++ sources include the following in the development branch, but it’s not in 3.10.

I’ve been using the development branch, which might explain why my result is different.

Maybe try a “bleeding edge” build. http://supercollider.s3.amazonaws.com/builds/supercollider/supercollider/osx/develop-latest.html

hjh

it seems to be fine in the bleeding edge build. thanks

Last update: 3.10.4 just came out, a day or two before this thread. So it isn’t fixed in that release.

There won’t be another 3.10.x release (I was just told).

So it’ll be fixed in 3.11 (the fix is already merged in).

hjh

Just wanted to mention that I’m still seeing this issue as well – SC 3.11.0 / MacOS 10.14.6.

In the example upthread, I’ve got env2 being triggered immediately.

A related example: evaluating the following:

(
    o = OSCFunc.new({|m, t| "reply!".postln }, '/reply', Server.default.addr);
    
    SynthDef.new(\foo, { 
        var sig, env;

        env = EnvGen.kr(Env.adsr, \gate.kr(0));
        sig = SinOsc.ar * env;

        SendReply.kr(Done.kr(env), '/reply', [0]);

        Out.ar(0, sig)
    }).add
)

…and then creating an instance of the Synth:

x = Synth.new(\foo)

…triggers the OSCFunc immediately, before \gate has been set high.

Please let me know if it would be helpful for me to open or comment on a GitHub issue – I had a quick look and it seems as though there’s been quite a lot of discussion around EnvGen and Done over the years, so I’m not sure where’s the best place to jump in.