adc => Gain g => FFT fftx => blackhole; //FFT for sound buffer FFT ffty => blackhole; // ifft transforms back into audio IFFT ifft => dac; 2048 => fftx.size => ffty.size => int FFT_SIZE; FFT_SIZE / 8 => int HOP_SIZE; Windowing.hann(512) => fftx.window; Windowing.hann(512) => ffty.window; //source is "robot" saw waves BlitSaw b => ffty; 0 => b.harmonics; 1 => b.gain; //starting frequencies, in MIDI #s 330 => b.freq; // 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 > .0001) { //Magnitude of bin is pretty small, so take the square root Math.pow((X.cval(i)$polar).mag, .5) * Y.cval(i) => Z[i]; } else 0 * Y.cval(i) => Z[i]; } // take ifft ifft.transform( Z ); // advance time HOP_SIZE::samp => now; }