// patch SndBuf buffy; //buffy => Gain g2 => dac; .9 => buffy.gain; "chuckpong.wav" => buffy.read; // lowpass LPF lpf => Gain gl => Gain ggl => OnePole low => blackhole; // "quart" the input lpf => gl; gl => ggl; 500 => lpf.freq; // multiply 3 => gl.op; 3 => ggl.op; // fudge factor 10 => ggl.gain; // set pole position (how closely it "hugs" the waveform) 0.9 => low.pole; // highpass Delay hack => HPF hpf => Gain gh => Gain ggh => OnePole high => blackhole; // "quart" the input hpf => gh; gh => ggh; 1000 => hpf.freq; // multiply 3 => gh.op; 3 => ggh.op; // fudge factor 10 => ggh.gain; // set pole position (how closely it "hugs" the waveform) 0.9 => high.pole; buffy => lpf; buffy => hack; 10::ms => hack.delay; // output sounds SndBuf table => dac; SndBuf paddle => dac; SndBuf whooshes[3]; // define "whooshes" array for( 0 => int i; i < whooshes.cap(); i++ ) { whooshes[i] => dac; 0 => whooshes[i].gain; } // read sounds "table.wav" => table.read; "paddle.wav" => paddle.read; "whoosh1.wav" => whooshes[0].read; "whoosh2.wav" => whooshes[1].read; "whoosh3.wav" => whooshes[2].read; 0 => table.gain; 0 => paddle.gain; int count; // loop on while( true ) { if( low.last() > .95 ) { // threshold count++; <<< "TABLE!!", low.last(), high.last(), count >>>; 0 => table.pos; low.last() => table.gain; // stop whooshes when ball bounces on table for( 0 => int i; i < whooshes.cap(); i++ ) 0 => whooshes[i].gain; 60::ms => now; } else if( high.last() > .95 ) { // threshold count++; <<< "PADDLE!!", low.last(), high.last(), count >>>; 0 => paddle.pos; high.last() => paddle.gain; // play whooshes when paddle hits ball whooshes[Std.rand2(0,whooshes.cap()-1)] @=> SndBuf @ buf; 0 => buf.pos; high.last() => buf.gain; 60::ms => now; } // update time of envelope-follower 1::samp => now; }