Node::release forces Env's curve to linear

Hi!
I figured out that, whenever I call Node.release with a releaseTime argument, my Env’s curve gets ignored, and forced to be linear.
Example code with pictures:

(
	x = {|gate=1|
		EnvGen.kr(
			Env.asr(0.01,1.0,1,[-4,-32]),
			gate,
			doneAction:2
		)
	}.play;
	{
		Bus(\control,0,1,s).plot(1);
		x.release();
	}.defer(0.1);
)

with x.release()
image
with x.release(1)
image

I think I found a place in scsynth’s source that could be originating this:

Is this a bug or is it intended? why?

EDIT: I’ll add a little explaination about the link between Node.release and EnvGen. Node.release(releaseTime) sets the synth’s \gate control to -(releaseTime+1), like doing a synth.set(\gate,releaseTime+1*(-1)). If releaseTime is not provided or zero, it does synth.set(\gate,0). Since gate == 0 preserves the Env’s curve, while gate < (-1) doesn’t, I looked in the source code for where EnvGen is checking if gate < (-1). And there is that m_shape = shape_Linear, which, even if I don’t really know how it is used, is conceptually agreeing with my plots

http://doc.sccode.org/Classes/EnvGen.html#Forced%20release

Forced release

If the gate of an EnvGen is set to -1 or below, then the envelope will cutoff immediately. The time for it to cutoff is the amount less than -1, with -1 being as fast as possible, -1.5 being a cutoff in 0.5 seconds, etc. The cutoff shape is linear.

I’m afraid this has been documented for a long time.

hjh

All right, I missed that. It is also discussed here:

I had an idea about how to fix it, I’ve posted it on the github issue

I’ve also commented on the github issue.

There’s one faulty assumption here: normally we think of a release as being one segment, but SC’s envelope definition allows the release to be any crazy complex shape the user wants. So you cannot just override one duration.

The use case for forced release is, no matter how the synth defines the envelope, cut it off directly in x amount of time. That’s a valid and necessary use case. I don’t think we should hijack that case. It was implemented that way for a reason.

I think the right way to override an envelope’s release is to use synth args to define the release parameters, and then set them directly. Then you define exactly what you want.

hjh