I sometimes get this wrong, but I think that this line:

SinOsc s => ADSR e => dac;

will make new connections between s, e and dac each time it's run in the while loop - possibly creating new instances of SinOsc and ADSR each time. Since you never disconnect from dac, this means an increasing load that may explain the breakdown.


Since you want some release on the ADSR, you could make a second shred function that deals with playing a single note, which could make sure to disconnect e from dac one the release time has passed. Trigger the note playing shred from your iGen function.

/Stefan


On Wed, Feb 5, 2014 at 1:11 AM, Philipp Blume <pgbluster@gmail.com> wrote:
Dear all,

Question from a rank ChucK beginner

There's something about envelopes or gain or shreduling that I don't understand.

I created a Cartesian matrix of impulse generators, whose frequencies are given as mx+ny {x,y btw -3 and 3) where the gain & 'tempo' of each generator is correlated with its distance from a line segment (a1,b1 - a2,b2) - later on I will be manipulating x,y,a1,b1,a2, and b2.
 
This code runs well for a while, but within a few seconds or minutes it starts to get overwhelmed. The death is both spectacular and quite moving, but how do I keep it within bounds so it sounds perpetually like it does in the first 5-10 seconds?

550 => float x;
440 => float y;
3 => float a1;
0 => float b1;
0 => float a2;
-2 => float b2;

fun
void iGen(int i1, int j1) {
    while(true) {
        Euclid(i1,j1,a1,b1) + Euclid(i1,j1,a2,b2) => float dist;
        <<< dist >>>;
        SinOsc s => ADSR e => dac;
        e.set(35::ms, 8::ms, .1, 200::ms);
        Math.pow(0.65,(dist)) => s.gain;
        i1*x + j1*y => s.freq;
        e.keyOn();
        (440)::ms => now;
        e.keyOff();
        (440*Math.pow(1.2,dist))::ms => now;
    }
}

fun float Euclid(float p, float q, float r, float s) {
    return Math.sqrt(Math.pow((p-r),2) + Math.pow((q-s),2));
}

for(-3 => int i; i<4; i++) {
    for (-3 => int j; j<4; j++) {
        if (i != 0 && j != 0) {
            spork ~ iGen(i,j);    
        }
    }
}

while (x != y) {
    500::ms=>now;
} 


--
Philipp Blume

_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users




--
Release me, insect, or I will destroy the Cosmos!