% Wiener filter

% Read the data from a standard .wav file
fprintf('Reading data...\n')
[y,Fs,nbits] = wavread('curve');
fprintf('The sample rate is %d Hz, ', Fs)
fprintf('and is sampled using %d bits/sample.\n', nbits)
N = length(y);
x = y(1:floor(N/16));
p=1.3;                              % parameter for cutoff
fx=fft(x);sfx=conj(fx).*fx;         % take fft of signal, and
sfcapprox=max(sfx-(p*std(x))^2,0); % apply cutoff
phi=sfcapprox./sfx;                 % define phi as derived
xout=real(ifft(phi.*fx));           % invert the fft
% then compare sound(x,Fs) and sound(xout,Fs)
