[chuck-dev] hotswapping UGens

Tom Lieber lieber at princeton.edu
Wed Jan 21 10:33:38 EST 2009


2009/1/21 Kassen <signal.automatique at gmail.com>:
> 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()
>         {
>         while(1)
>             {
>             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
> before.

It doesn't seem like the melody should keep playing on the Shakers
since the noteOn is being called assuming the instrument is a Sitar.
:D

-- 
Tom Lieber
http://AllTom.com/


More information about the chuck-dev mailing list