Golf Filter.ck
From CSWiki
// make HidIn and HidMsg Hid hi; HidMsg msg; // which joystick 1 => int device; // get from command line if( me.args() ) me.arg(0) => Std.atoi => device; adc => Envelope e => dac; adc => HPF f => Envelope ef => dac; adc => LPF r => ef => dac; int filterstate; 0 => filterstate; e.keyOn(); ef.keyOff(); // open joystick 0, exit on fail if( !hi.openJoystick( device ) ) me.exit(); <<< "Game Controller'" + hi.name() + "' ready", "" >>>; // infinite event loop while( true ) { // wait on HidIn as event hi => now; // messages received while( hi.recv( msg ) ) { if(msg.isButtonDown() ){ <<< "filter on" >>>; 1 => filterstate; ef.keyOn(); e.keyOff(); } if(msg.isButtonUp() ) { <<< "filter off" >>>; 0 => filterstate; e.keyOn(); ef.keyOff(); } // joystick axis motion if( msg.isAxisMotion() ) { if (msg.which == 0) { (msg.axisPosition + 1.01)*800 => f.freq; } else if (msg.which == 2) { (msg.axisPosition + 1.2) * 3 => f.Q; } else if (msg.which == 3) { (msg.axisPosition + 1.01)*250 => r.freq; } else if (msg.which == 4) { (msg.axisPosition + 1.2)*3 => r.Q; } } } }