Hey Kas:<br><br>After an experiment, I must take slight exception to one thing you said:<br><br><div class="gmail_quote">2009/10/8 Kassen <span dir="ltr">&lt;<a href="mailto:signal.automatique@gmail.com">signal.automatique@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div>...When the shred a UGen was defined in exits the UGen will be disconnected from anything it connected to (I&#39;m not sure everything that connects to the Ugen on the other end will also be disconected but that doesn&#39;t matter much here). Because of this the DAC will no longer poll it for new samples so it won&#39;t take any CPU anymore. This, in adition to calculation order, is the big advantage of the &quot;pull through&quot; model we use for the UGens.<br>
</div></div></blockquote><br>Here&#39;s a simple program that defines a SinOsc and plays it in its own shred.  After 3.5 seconds, the shred is killed (and we know that it has exited since its heartbeat / printing stops), yet the sound plays on.<br>
=============<br>fun void playit() {<br>    SinOsc s =&gt; dac;<br>    while (true) {<br>    &lt;&lt;&lt; now / 1::second, &quot;playing...&quot; &gt;&gt;&gt;;<br>    1::second =&gt; now;<br>    }<br>}<br><br>spork ~ playit() @=&gt; Shred @ _player;<br>
3.5::second =&gt; now;<br>&lt;&lt;&lt; now / 1::second, &quot;terminating shred...&quot; &gt;&gt;&gt;;<br>_player.exit();<br>&lt;&lt;&lt; now / 1::second, &quot;waiting before exiting&quot; &gt;&gt;&gt;;<br>7.5::second =&gt; now;<br>
&lt;&lt;&lt; now / 1::second, &quot;exiting!&quot; &gt;&gt;&gt;;<br>============<br>produces<br>bash-3.2$ chuck ~/Projects/Chuck/Tests/<a href="http://shred_exit.ck">shred_exit.ck</a><br>0.000000 playing... <br>1.000000 playing... <br>
2.000000 playing... <br>3.000000 playing... <br>3.500000 terminating shred... <br>3.500000 waiting before exiting <br>4.000000 playing... <br>11.000000 exiting! <br>===========<br>[Digression: why the heck does playit() print out &quot;4.00 playing...&quot; when it was terminated at t=3.5? That may be because an exit() doesn&#39;t take effect until the next time a shred blocks.  If so, that would be a nice thing to document.]<br>
<br>I think what you meant was &quot;When the shred a UGen was defined in exits *NORMALLY* the UGen will be disconnected from anything it connected to...&quot;  To test that, we simply let the player shred exit (without unchucking the dac):<br>
===========<br>fun void playit() {<br>    SinOsc s =&gt; dac;<br>    &lt;&lt;&lt; now / 1::second, &quot;playit playing&quot; &gt;&gt;&gt;;<br>    1::second =&gt; now;<br>    &lt;&lt;&lt; now / 1::second, &quot;playit exiting&quot; &gt;&gt;&gt;;<br>
}<br><br>spork ~ playit();<br>7.5::second =&gt; now;<br>&lt;&lt;&lt; now / 1::second, &quot;finished&quot; &gt;&gt;&gt;;<br>===========<br>
And yep, sure enough, the sound stops after 1 second.  <br><br>So the moral of the story: if you terminate a shred via exit(), it does NOT get the benefit of a standard shred clean-up.<br><br>Perhaps &quot;cleanup of a terminated shred&quot; should be added to the someday-nice-to-have wish list.<br>
<br>Cheers,<br><br>- Rob<br><br> </div>