Step s => dac; 1 => s.gain; 50 => int length; // length of a segment 0 => int i; Std.rand2f(-1,1) => float n; Std.rand2f(-1,1) => float n1; while (1::samp => now) { if (i < length) { cosine_interpolation(n, n1, i$float/length) => s.next; i++; } else { 0 => i; Std.rand2(40,200) => length; // reset length n1 => n; Std.rand2f(-1,1) => n1; } } fun float cosine_interpolation(float a, float b, float x) { (1 - Math.cos(x * 3.1415927)) * .5 => float f; return a*(1-f) + b*f; }