[chuck-users] extending UGen

Kassen signal.automatique at gmail.com
Sat Oct 1 07:33:04 EDT 2011

Dear list,

Here's a small exercise testing the "new" feature, it generates noise
according to the classical "3x+1" series;

//may generate extreme signals. Mind your ears, speakers and neighbours,
class Foo extends Step
    true => next;

    spork ~ gen();
    fun void gen()
        50 => int x;
        1 => float value;
        while (true)
            if (x == 1) Std.rand2(1, 100) => x;
            else if (x % 2) 1 + (3 * x) => x;
            else x / 2 => x;

            x::samp => now;
            last() * -1 => next;

Foo bar => dac;
3::minute => now;

Notice that we can use .last() and .next() from inside of the class; this is
nice. Not so clear -yet- is whether we can create our own "tick" that will
be called every samp at the moment the UGen is ticked by the one downstream
or whether we could get to values send into this by the ChucK operator...
but it works and it's nice!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20111001/5e8bb5e4/attachment.html>

More information about the chuck-users mailing list