Mike;<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
You get a couple more of these trainlets running, and you&#39;ll kill the<br>
VM. &nbsp;I absolutely love ChucK&#39;s concurrency model, but it can&#39;t handle<br>
too much of this kind of thing. &nbsp;The sample-level intervention is also<br>
painful.<br>
<br></blockquote></div>True. Here&#39;s a small mod. the trick is that it only updates the osc&#39;s gain at zerocrossings, making it relatively glitch-free. The price is that CPU cost will now depend on the frequency used. <br>
<br>===========================<br>fun void hannGrain( float f ) {<br>&nbsp;&nbsp; SinOsc s =&gt; dac;<br>&nbsp;&nbsp; f =&gt; s.freq;<br>&nbsp;&nbsp; 0 =&gt; int n;<br>&nbsp;&nbsp; 0. =&gt; float h;<br><br><br>&nbsp;&nbsp;&nbsp; now =&gt; time start;<br>&nbsp;&nbsp;&nbsp; now + N::samp =&gt; time later;<br>
&nbsp;&nbsp; while( now &lt; later ) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; hann( ((now-start)/ samp) $ int ) =&gt; h =&gt; s.gain;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; n++;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;<span style="color: rgb(255, 0, 0);"> .5::s.period() =&gt; now;</span><br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>}<br>=================================<br>
<br>This strategy is not at all perfect but I feel this gives a decent trade between CPU efficiently and sound quality. We can trade those using ChucK&#39;s timing but with clever trading we can get a better deal. Note this only works because we know the phase of the oscilator and we know the rate won&#39;t change. If you need changing frequencies this will have to be extended. <br>
<br>I&#39;d also think about sporking a static number of shreds and re-using those with signalled events as your current strategy is probably generating a lot of garbage.<br><br>Hope that helps. Cool sound!<br><br>Kas.<br>