// patch adc => Gain g => OnePole p => blackhole; // square the input, by chucking adc to g a second time adc => g; // set g to multiply its inputs 3 => g.op; // threshold .05 => float threshold; // set pole position, influences how closely the envelope follows the input // : pole = 0 -> output == input; // : as pole position approaches 1, follower will respond more slowly to input 0.999 => p.pole; // duration between successive polling 20::ms => dur pollDur; // duration to pause when onset detected 100::ms => dur pauseDur; // time before which to not check for threshold time notBefore; //set up LED MAUI_LED b; MAUI_LED r; MAUI_View v; v.size( 100, 50 ); b.color( b.blue ); b.size( 50, 50 ); b.position( 0, 0 ); b.unlight(); r.color( r.red ); r.size( 50, 50 ); r.position( 50, 0 ); r.unlight(); v.addElement( r ); v.addElement( b ); v.display(); //sarah time x; time y; dur z; float c; float d; 0 => c; 0 => d; //why does "while" statement fuck it up? while (c == 0) { if( now > notBefore && p.last() > threshold ) { now => x; <<< "hi" >>>; // compute time to resume checking now + pauseDur => notBefore; 1 => c; } now + 1::ms => now; } while (d == 0) { if( now > notBefore && p.last() > threshold ) { now => y; // compute time to resume checking now + pauseDur => notBefore; 1 => d; } now + 1::ms => now; } //gets time difference y - x => z; <<<"duration:", z >>>; // infinite time loop 0 => float a; time beat; float totalPoints; float points; 1 => int f; while( a < 15 ) { //time of next beat a*z + y => beat; //get LED to light up with tempo if (beat + 10::ms > now && now > beat - 10::ms) { b.light(); a + 1 => a; now + 10::ms => now; } else { b.unlight(); } //printing points (2 circumstances - human hits before beat and human hits after if( now > notBefore && p.last() > threshold && f < 15 && 1000*(beat - now)/z < 500) //need f to make sure only get 16 tries to get 16 beats { 1000 - Std.fabs(1000*(beat - now)/(z)) => points; totalPoints + points => totalPoints; <<< f, ". points:", points >>>; <<< "total points:", totalPoints >>>; // compute time to resume checking now + pauseDur => notBefore; f + 1 => f; r.light(); now + 10::ms => now; } else { r.unlight(); } if( now > notBefore && p.last() > threshold && f < 15 && 1000*(beat - now)/z > 500) { 1000 - Std.fabs(1000*(beat - now - z)/(z)) => points; totalPoints + points => totalPoints; <<< f, ". points:", points >>>; <<< "total points:", totalPoints >>>; // compute time to resume checking now + pauseDur => notBefore; f + 1 => f; r.light(); now + 10::ms => now; } else { r.unlight(); } now + 1::ms => now; } <<< "Game over, total points:", totalPoints >>>; // determines poll rate pollDur => now;