Step s => dac; .5 => s.gain; float vx, ex; 200 => float x; .05 => float elasticity; .005 => float friction; x$int => int length; 0 => int i; -1 => float n; while (1::samp => now) { if (Std.randf() > .999999) { 300 => x; } if (i < length) { cosine_interpolation(n, -n, i$float/length) => s.next; i++; } else { 0 => i; elasticity * (x - 100) => ex; (1 - friction) * (ex + vx) => vx; x - vx => x; x$int => length; -n => n; } } 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; }