[chuck-users] solving FFT artifacts (vocoder example)

eduard aylon eduard.aylon at gmail.com
Sat Oct 13 14:37:18 EDT 2007

Hi list,

On the same direction as my previous posts from yesterday, I'd like  
to know if anyone has a good tip (i.e. articles, pdfs, books,  
personal experience)  for spectral transformations. Not only what you  
can do with spectrums but more in the direction of what could happen  
when you alter the mag-spectrum or phase-spectrum or both and how to  
solve possible problems (i.e. artifacts).
Below I have attached a quick vocoder example written in chuck. So  
for those who want to enjoy it, just set a sustained music file to be  
read by "carrier" and speak thru your computer's mic. Again,  
artifacts will be present and quite noticeable! :-(



SndBuf carrier => FFT fft_c => blackhole; // music signal
"/Volumes/data/samples/music.wav" => carrier.read;
adc => FFT fft_m => blackhole; // voice signal
IFFT ifft => WvOut file => dac;

0.5 => carrier.gain ;
// fft/ifft constants
2048 => int FFT_SIZE => fft_c.size => fft_m.size => ifft.size;

// windowing:
Windowing.blackmanHarris( WIN_SIZE );

// spectrum array:
complex spectrum_c[WIN_SIZE];
complex spectrum_m[WIN_SIZE];

// temp variables:
polar temp_polar_m, temp_polar_c;

1 => carrier.loop;
while( true )
     // take ffts:

     fft_m.spectrum( spectrum_m );
     fft_c.spectrum( spectrum_c );

     // convert complex form to polar, assign magnitudes & back to  
     for( 0 => int i; i < WIN_SIZE; i++ )
         spectrum_m[i]$polar => temp_polar_m;
         spectrum_c[i]$polar => temp_polar_c;
         temp_polar_m.mag => temp_polar_c.mag;
         // store values. Re-use carrier's spectrum:
         temp_polar_c$complex => spectrum_c[i];

     ifft.transform( spectrum_c );

     HOP_SIZE::samp => now;

More information about the chuck-users mailing list