<div>Hello all-</div><div>I have been doing some granular synthesis in ChucK and I am trying to create overlapping grains without having resort to arrays of Ugens or similar methods to create polyphony.  Although I have seen this technique used often, the following seems to eat up memory rather quickly (due to continuously sporking the SndBuf no doubt).</div>
<div><br></div><div>//BEGIN CODE --&gt;</div><div>//use your own file here...</div><div>Std.getenv(&quot;SSDIR&quot;)+&quot;/&quot;+&quot;Percussion&quot;+&quot;/&quot;+&quot;snare.wav&quot; =&gt; string filename;</div><div>
<br></div><div>fun void voice(){</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>SndBuf s =&gt; Envelope e =&gt; dac;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>filename =&gt; s.read;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> .5 =&gt; s.gain;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>s.pos(Std.rand2(0, s.samples()));</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>5::ms =&gt; e.duration;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>e.keyOn();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>45::ms =&gt; now;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>e.keyOff();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>5::ms =&gt; now;</div><div>}</div><div>//spork away and make lots of overlapping SndBufs</div><div>while (15::ms =&gt; now){</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> spork ~ voice();</div>
<div>}</div><div>//&lt;--END CODE</div><div><br></div><div>I guess I am wondering if there is a way to release Ugen references or do I need to wait for garbage collection to liberally spork Ugens? </div><div>I have looked over these threads...</div>
<div><br></div><div>garbage collection:<br></div><div><a href="https://lists.cs.princeton.edu/pipermail/chuck-users/2009-March/003978.html">https://lists.cs.princeton.edu/pipermail/chuck-users/2009-March/003978.html</a></div>
<div><a href="https://lists.cs.princeton.edu/pipermail/chuck-users/2009-July/004473.html">https://lists.cs.princeton.edu/pipermail/chuck-users/2009-July/004473.html</a></div><div><br></div><div>granular:</div><div><a href="https://lists.cs.princeton.edu/pipermail/chuck-users/2008-May/002917.html">https://lists.cs.princeton.edu/pipermail/chuck-users/2008-May/002917.html</a></div>
<div><br></div><div>...and they seem to indicate that i should declare a finite number of Ugens and juggle them somehow (not as cool as my RAM hungry example). The ability release unreferenced Ugens would facilitate the easy polyphony one gets when using Csound and really make ChucK awesomer (fingers crossed).</div>
<div>Thanks ahead of time for any input.</div><div>Kurt</div><div><br></div>