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).
//BEGIN CODE -->
//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;
e.keyOn();
45::ms => now;
e.keyOff();
5::ms => now;
}
//spork away and make lots of overlapping SndBufs
while (15::ms => now){
spork ~ voice();
}
//<--END CODE
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:
granular:
...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.
Kurt