Step s => dac; 1 => s.gain; 300 => int length; // length of a segment length => int maxLength; 0 => int i; -1 => int direction; 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; if (direction == -1) { length - 1 => length; } if (direction == 1) { length + 1 => length; } if (length == 50) { 1 => direction; } if (length == maxLength) { -1 => direction; } 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; }