Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnvGen with doneAction 14 - unexpected behaviour. #1279

Open
miguel-negrao opened this issue Dec 16, 2014 · 5 comments
Open

EnvGen with doneAction 14 - unexpected behaviour. #1279

miguel-negrao opened this issue Dec 16, 2014 · 5 comments
Assignees
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: server plugins
Milestone

Comments

@miguel-negrao
Copy link
Member

(
x = SynthDef(\test, {

    var env = Env([ 1, 0 ],[ 6 ], \lin );

    EnvGen.kr(env, \gate.kr(0), doneAction:2).poll

}).play
)

This will post 1 indefinitely, while

(
x = SynthDef(\test, {

    var env = Env([ 1, 0 ],[ 6 ], \lin );

    EnvGen.kr(env, \gate.kr(0), doneAction:14).poll

}).play
)

frees the synth immediately after the first control bloc. The expected behaviour would be to behave the same as with doneAction 0-13 and just keep posting 1 indefinitely.

This seems like a bug, no ?

@miguel-negrao miguel-negrao added bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: server plugins labels Dec 16, 2014
@telephon
Copy link
Member

Not sure if this is in DoneAction (see SC_Node.cpp). Maybe it is in EnvGen, but I don't see where.

The behavior appears to be different in Linen

(
x = SynthDef(\test, {

    Linen.kr(\gate.kr(0), doneAction:14).poll

}).play
)
x.set(\gate, 1);

@telephon
Copy link
Member

In the method: void EnvGen_Ctor(EnvGen *unit), there is an initialization of the current stage of the envelope to a very large integer:

unit->m_stage = 1000000000;

This appears to be overridden in cases where gate = 1. But if gate remains 0, the value is counted up from 1000000000, or stays the same.

In EnvGen_nextSegment, there is a test whether the envelope has overrun:

if (unit->m_stage+1 >= numstages) { // num stages

this is called immediately in our case.

By contrast, in Linen, where this problem doesn't exist, the default is different: unit->m_stage = 4;.

@telephon
Copy link
Member

I've tried to escape the above initialization case, and eventually gave up, because I don't really know what the behavior should be before the gate has been triggered: what value should the UGen return?.

But the above diagnosis seems to be correct.

@scztt scztt added this to the 3.7 milestone Mar 25, 2015
@scztt scztt self-assigned this Mar 25, 2015
@scztt
Copy link
Contributor

scztt commented Jun 28, 2015

this may be fixed via #1424?

@telephon
Copy link
Member

As it seems, #1424 breaks:

{ SinOsc.ar(440, 0, EnvGen.ar(Env([0, 1, 0],[0, 0.5], -3), Impulse.ar(1))) }.play

But I left it in, commented out, so we can continue from that.

@crucialfelix crucialfelix modified the milestones: 3.7.x, 3.8 Apr 7, 2016
@nhthn nhthn modified the milestones: 3.8, 3.9 Jan 15, 2017
@nhthn nhthn modified the milestones: 3.9, 3.9.x Oct 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: server plugins
Projects
None yet
Development

No branches or pull requests

5 participants