[chuck-users] Grains make garbage:(

kurt sobrilliant at gmail.com
Wed Sep 23 16:12:00 EDT 2009

Hello all-
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).

//use your own file here...
Std.getenv("SSDIR")+"/"+"Percussion"+"/"+"snare.wav" => string filename;

fun void voice(){
SndBuf s => Envelope e => dac;
filename => s.read;
 .5 => s.gain;
s.pos(Std.rand2(0, s.samples()));
5::ms => e.duration;
45::ms => now;
5::ms => now;
//spork away and make lots of overlapping SndBufs
while (15::ms => now){
 spork ~ voice();

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?
I have looked over these threads...

garbage collection:


...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).
Thanks ahead of time for any input.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20090923/4f674f03/attachment.html>

More information about the chuck-users mailing list