Dear all,<br><br>I just noticed that I accidentally send this to the DEV list instead of the users one. That was of course a mistake. I hope this didn't bother anyone, I'll try to pay more attention on the future. <br>
<br>Sorry,<br>Kas.<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Kassen</b> <span dir="ltr"><<a href="mailto:signal.automatique@gmail.com">signal.automatique@gmail.com</a>></span><br>
Date: 2009/1/21<br>Subject: hotswapping UGens<br>To: ChucK Developer Mailing List <<a href="mailto:chuck-dev@lists.cs.princeton.edu">chuck-dev@lists.cs.princeton.edu</a>><br><br><br>Fellow ChucKists,<br><br>Inspired by Scott's explanation of casting I thought I'd try a new trick that may be quite interesting for livecoding.<br>
<br>first run this file;<br>-----------------------------<br>new UGen @=> Foo.instrument;<br>
public class Foo<br> {<br> static UGen @instrument;<br> spork ~attach();<br> <br> fun void attach()<br> {<br> while(1)<br> {<br> if(!instrument.isConnectedTo( dac )) instrument => dac;<br>
second => now;<br> }<br> }<br> }<br><br>Foo foo;<br>new Sitar @=> foo.instrument;<br><br>//your melody goes here<br>while(second => now) 1 => (foo.instrument $ Sitar).noteOn;<br>
--------------------------------------------<br><br>Then run this to hot-swap the UGen while the original code runs;<br><br>--------------<br>new Shakers @=> Foo.instrument;<br>-----------------------<br><br>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.<br>
<br>Yours,<br>Kas.<br>
</div><br>