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

plugins: do not advance stages before env start #1424

Closed
wants to merge 1 commit into from

Conversation

scztt
Copy link
Contributor

@scztt scztt commented Apr 17, 2015

If env has not been triggered for the first time, don't advance to the next segment. Set the initial shape to hold, so that we hold the first envelope value before start. Fixes #334

If env has not been triggered for the first time, don't advance to the next segment. Set the initial shape to hold, so that we hold the first envelope value before start. Fixes #334
@scztt
Copy link
Contributor Author

scztt commented Apr 17, 2015

It would be good to have a couple people take a look at this, and cross-test it with some of the other envgen bugs as well. It fixes the case in question but envgen is a complex ugen and very at risk of other breakages....

@crucialfelix
Copy link
Member

has conflicts, should be easy to fix up

@crucialfelix
Copy link
Member

I built a new up to date PR with this code to test. Will push that and close this when I've figured it out.

Some of the parts of this PR were merged in at a later date, but not the critical line that turns it on.

// this fixes doneAction 14, but breaks with EnvGen_next_aa

@vivid-synth
Copy link
Member

Nit: can you change the spaces to tabs to stay consistent?

@crucialfelix
Copy link
Member

yep, my editor already did that for me :) I haven't pushed the PR up yet

@@ -2785,6 +2788,7 @@ static inline bool check_gate_ar(EnvGen * unit, int i, float & prevGate, float *

static inline bool EnvGen_nextSegment(EnvGen * unit, int & counter, double & level)
{
if (unit->m_stage == ENVGEN_NOT_STARTED) { return true; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduced a bug where EnvGen.ar would not work:

// EnvGen.ar should continue to work.
// this should play the SinOsc
{ SinOsc.ar(440, 0, EnvGen.ar(Env([0, 1, 0],[0, 0.5], -3), Impulse.ar(1))) }.play

and was reverted for the 3.7.2 release 0f69855

The other minor refactoring in this PR did make it in and are fine.

@crucialfelix
Copy link
Member

crucialfelix commented Aug 23, 2016

I've checked through this. As noted, some parts of it are merged already; one part introduced a bug.

and actually it doesn't seem to fix the pause bug:

SynthDef(\pausefail, { |gate = 0|
    var freq_eg = EnvGen.kr(
        Env([200, 400, 300], [2, 2], \exp, releaseNode: 1),
        gate,
        doneAction: 1
    );
    Poll.kr(2, freq_eg);
}).add;

f = { |msg|
    if(#['/n_go', '/n_end', '/n_on', '/n_off'].includes(msg[0])) {
        msg.postln;
    };
};

thisProcess.addOSCRecvFunc(f);

// this should pause the synth immediately
// because it starts with gate 0
a = Synth(\pausefail, [gate: 0]);
// but you will see Poll will continue to post showing that the synth is not paused

/*
-> Synth('pausefail' : 1000)
UGen(EnvGen): 200
[ /n_go, 1000, 1, -1, -1, 0 ]
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
UGen(EnvGen): 200
*/

a.run(false);  // /n_off, correctly, and Poll stops
a.run(true);   // /n_on, correctly, and Poll resumes

a.set(\gate, 1);  // polled value increases

a.set(\gate, 0);  // polled value decreases and node pauses (OK)

a.free;

Or maybe that is what is supposed to do: keep playing until it gets a gate that goes from positive to 0 and then pause.

To experiment with this you can go to https://github.com/supercollider/supercollider/blob/master/server/plugins/LFUGens.cpp#L2818
and just uncomment that line.

There is nothing else in this PR besides that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants