// Feedback instrument for use with an apple laptop and an electric guitar amp //Patch me here adc => ResonZ r => dac; // Set this higher than one to use without an amp... //1.1 => r.gain; // instantiate a HidIn object HidIn hi; HidMsg msg; // open tilt sensor if( !hi.openTiltSensor() ) { <<< "tilt sensor unavailable", "" >>>; me.exit(); } // print <<< "tilt sensor ready", "" >>>; // infinite while loop while( true ) { // poll the tilt sensor, expect to get back 3 element array of ints // (9 for now means accelerometer, 0 selects 0th accelerometer) hi.read( 9, 0, msg ); // print results, note these are "absolute" tilt in each axis //<<< msg.x, msg.y, msg.z >>>; // Exponential scale for the filter frequency, where even is around 440 and around 10k is the max 20 + Math.pow(2, ((msg.x $ float + 256) * 16.6 / 512)) => r.freq; // And now for filter Q if (msg.y < 0) { Math.pow(10, (msg.y $ float / 256)) => r.Q; } else { msg.y => r.Q; } <<< r.freq(), r.Q() >>>; // advance time 30::ms => now; }