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

EnvelopeFollower last() method #53

Open
boonier opened this issue Mar 7, 2024 · 5 comments
Open

EnvelopeFollower last() method #53

boonier opened this issue Mar 7, 2024 · 5 comments

Comments

@boonier
Copy link

boonier commented Mar 7, 2024

There seems to be some problem with naming the method:

fun float last() (line 48)

When I try to plug the value from that method into a ugen, I get an instance VM crash.

When renaming to lastT() for example, the EnvelopeFollower class functions as normal. Perhaps there is a conflict with the inherited Chugraph class' last() method?

adc => EnvelopeFollower env => blackhole;
SinOsc s => dac;

while (true)
{
    100::ms => now;
   env.last() => s.gain;
    <<<env.last()>>>;
}
@boonier
Copy link
Author

boonier commented Mar 13, 2024

So as to make this easy to test, the following will crash ChucK (for me).

Seems like a seg fault

class EnvelopeFollower extends Chugraph
{
    20::ms => dur _rate;

    Gain _gain;
    OnePole _pole;
    Step _step;

    inlet => _gain;
    inlet => _gain;
    _gain => _pole => blackhole;
    _step => outlet;

    {
        3 => _gain.op;
        0.99 => _pole.pole;

        spork ~ _updateAtRate();
    }

    fun float last()
    {
        return _step.last();
    }

    fun dur rate()
    {
        return _rate;
    }

    fun dur rate(dur d)
    {
        d => _rate;
        return d;
    }

    fun void _updateAtRate()
    {
        while (true)
        {
            _pole.last() => _step.next;
            _rate => now;
        }
    }
}

adc => EnvelopeFollower env => blackhole;
SinOsc s => dac;

while (true)
{
    100::ms => now;
    env.last() * 200 => s.freq;
    <<<env.last()>>>;
}

@heuermh
Copy link
Owner

heuermh commented Mar 13, 2024

Thank you for the follow up, @boonier! I can reproduce on my end

$ chuck crash.ck
Assertion failed: (func->native_func_kind == ae_fp_mfun), function execute,
file chuck_instr.cpp, line 5299.
Abort trap: 6

Since _step => outlet in your example I suppose there is no need to override last()? If I comment out the method declaration it runs fine

$ chuck fixed.ck
0.004344 :(float)
0.022559 :(float)
0.000005 :(float)
0.000015 :(float)
0.000000 :(float)
...

@heuermh
Copy link
Owner

heuermh commented Mar 13, 2024

Odd the EnvelopeFollower example in LiCK does not crash for me

$ chuck --loop
...
[chuck]: (VM) sporking incoming shred: 1 (envFollowerExample.ck)...
0.000001 :(float)
0.000000 :(float)
0.000000 :(float)
0.000002 :(float)
0.000000 :(float)
...
$ chuck + import.ck
$ chuck + examples/envFollowerExample.ck

@boonier
Copy link
Author

boonier commented Mar 13, 2024

hmm I have no idea...

I have a question, what does the Step do in this class - is it like a sample and hold?

@heuermh
Copy link
Owner

heuermh commented Mar 13, 2024

Yep, exactly like a sample and hold.

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

No branches or pull requests

2 participants