% fft_wav.m  reads file  ok.wav, takes FFT, IFFT, writes junkm.wav
function fft_wav(input_name, output_name)
  format compact
  if nargin<2
    output_name='junkm.wav'
  end
  if nargin<1
    input_name='ok.wav'
  end
  
  sprintf('reading wave file %s \n',input_name)
  [y,Fs,bits] = wavread(input_name);
  wavplay(y,Fs);
  'Fs sample frequency in Hz '
  Fs
  'number of samples '
  size(y)
  'maximum value in y '
  max(y)
  'minimum value in y '
  min(y)
  z=fft(y);
  n=length(z);
  plot(1:n,abs(z));
  grid on;
  axis tight;
  xlabel('frequency bin');
  ylabel('amplitude');
  title(['raw FFT of input ' input_name]);
  % modify spectrum in  z  as desired



  yz = ifft(z);
  wavwrite(yz, Fs, output_name);
  [y,Fs,bits] = wavread(output_name);
  wavplay(y,Fs);
end % fft_wav.m
