// move mouse left & right to modify elasticity // move up & down to modify friction // left button to send a new impulse 0 => int deviceNum; Hid hi; HidMsg msg; if( !hi.openMouse( deviceNum ) ) me.exit(); 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; fun void sound() { while (1::samp => now) { 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; } spork ~ sound(); while(true) { hi => now; while( hi.recv( msg ) ) { if( msg.isMouseMotion() ) { if( msg.deltaX ) { elasticity + msg.deltaX$float/1000 => elasticity; if (elasticity < .005) .005 => elasticity; if (elasticity > 1) 1 => elasticity; <<<"elasticity", elasticity>>>; } else if ( msg.deltaY ) { friction + msg.deltaY$float/2000 => friction; if (friction < .005) .005 => friction; if (friction > .05) .05 => friction; <<<"friction : ", friction>>>; } } else if( msg.isButtonDown() ) { if (msg.which == 0) 300 => x; } } }