//Cross synthesize mic and noise //FFT for mic input adc => Gain g => FFT fftx => blackhole; // pump up gain for headset mic //2 => g.gain; //FFT for sound buffer FFT ffty => blackhole; // ifft transforms back into audio IFFT ifft => JCRev j => dac; .00 => j.mix; // set FFT size 2048 => fftx.size => ffty.size => int FFT_SIZE; // desired hop size FFT_SIZE / 8 => int HOP_SIZE; // set window and window size Windowing.hann(512) => fftx.window; Windowing.hann(512) => ffty.window; //Create noise Noise n => BiQuad f => ffty; // set biquad pole radius .98 => f.prad; // set biquad gain 1 => f.gain; // set equal zeros 1 => f.eqzs; // our float 0.0 => float t; //spork ~ filter_mod(); .1 => j.gain; // use this to hold contents of spectral computation complex Z[FFT_SIZE/2]; // control loop while( true ) { // take fft fftx.upchuck() @=> UAnaBlob X; //spectrum from adc ffty.upchuck() @=> UAnaBlob Y; //spectrum from buffer // bin by bin: for( int i; i < FFT_SIZE/2; i++ ) { (X.cval(i)$polar).mag => float m; if (m > .00001) Math.pow((X.cval(i)$polar).mag, .4) * Y.cval(i) => Z[i]; else 0 * Y.cval(i) => Z[i]; } // take ifft ifft.transform( Z ); // advance time HOP_SIZE::samp => now; } function void filter_mod() { // infinite time-loop while( true ) { // sweep the filter resonant frequency 100.0 + Std.fabs(Math.sin(t)) * 1000.0 => f.pfreq; t + .1 => t; // advance time 100::ms => now; } }