[chuck-users] replace crossfade (bug)

Kassen signal.automatique at gmail.com
Sun Sep 2 20:17:31 EDT 2007


we seem to have another bug. The code pasted below (intended to be saved as
"xfade.ck") is intended to set up a small patch, then reload itself
(hopefully in edited form) in a crossfading manner every time the "end" key
is pressed. As far as I can see it's syntactically correct ChucK and the
parser agrees with me (both the latest and the last version will try to run
this without complaints). However, uppon pressing any key the whole thing
will get stuck and it will get stuck so badly that Windows only realises
it's stuck as soon as I try to force it to quit. Moving the definition of
the keyboard and it's message out of the class will crash the whole thing
immediately for reasons unkown (namespace?). Moving the whole keyboard
reader to it's own sporked shred outside of the class, then trying to use
event signalling to set in the x-fade will also get the whole thing stuck.
The issue isn't in the atempt to have some code Machine.add() itself as a
condition either.

I've been at this for a few hours now and I'd say this looks quite bad,
kicking out everything that involves reading the keyboard (and making the
condition time-dependant) fixes it so I suspect there is something inbetween
classes and reading the keyboard profoundly wrong.

For now I give up, Spencer? Ge?


Code pasted below, comments aimed at new users, might prove usefull/fun once
we get to the bottom of why it crashes so terribly, stay tuned.
//construct a "penny", penny is named after a brand of faders popularly used
in DJ mixers
Penny fade;

//realy simple patch to invite editing
SinOsc s => Gain g => fade.in;
fade.out => dac;

SinOsc lfo => g;
//multiplication, i.e. a VCA
3 => g.op;

second => lfo.period;

//infinite loop
while(true) second => now;

class Penny

    //"in" and "out" are simply there for convenience
    Gain in => Envelope fader => Gain out;

    //edit this to something musical
    second => dur fadeTime;

    //fade-in, this happens at the moment the instance is constructed
    fadeTime => fader.duration;
    1 => fader.keyOn;

    //create keyboard interface and asociated message
        Hid hi;
        HidMsg msg;
        hi.openKeyboard( 0 );

    //get the shred ID, needed to kill it later
    me.id() => int myID;

    //run keyboard listening in its own shred
    spork ~ kb_listener();

    fun void kb_listener()
            hi => now;

            //207 refers to the "end" key
            //edit this if you need that key for other purposes

            if(msg.isButtonDown() && ( msg.which == 207)  && Machine.add( "
xfade.ck" ) )
                1 => fader.keyOff;
                fadeTime => now;



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20070903/54a3a7ff/attachment-0001.htm 

More information about the chuck-users mailing list