[chuck-users] Fwd: hotswapping UGens

Kassen signal.automatique at gmail.com
Mon Feb 8 09:08:08 EST 2010

Forward of a old message for Andrew to illustrate a technique related to his

Please note that this technique is squarely in the "powertools can maim"
category; it's very powerful, getting around some of ChucK's limitations but
it runs right next to the edge of where the VM will crash because of the


---------- Forwarded message ----------
From: Kassen <signal.automatique at gmail.com>
Date: 21 January 2009 16:14
Subject: hotswapping UGens

Fellow ChucKists,

Inspired by Scott's explanation of casting I thought I'd try a new trick
that may be quite interesting for livecoding.

first run this file;
new UGen @=> Foo.instrument;
public class Foo
    static UGen @instrument;
    spork ~attach();

    fun void attach()
            if(!instrument.isConnectedTo( dac )) instrument => dac;
            second => now;

Foo foo;
new Sitar @=> foo.instrument;

//your melody goes here
while(second => now) 1 => (foo.instrument $ Sitar).noteOn;

Then run this to hot-swap the UGen while the original code runs;

new Shakers @=> Foo.instrument;

Sadly this does need that "attach" function as assignment breaks the link to
the dac. I'm not sure I feel that's desirable behaviour but at least we can
now hotswap UGens without crashing. I don't think I succeeded in that

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

More information about the chuck-users mailing list