clc;
clear;
close all
fs=20000
t=0:1/fs:.04;
x=4*sin(2*pi*2000*t)+4*sin(2*pi*1500*t)+10*sin(2*pi*6000*t)+6*sin(2*pi*200*t);
y=fft(x);
l=length(y);
Y=y(1:(l-1)/2);
r=1/((l-1)/2);
n=0:r:1-r;
plot(n,abs(Y)), xlabel('Normalized frq- 0 to corresponding for sampling rate 20KHz & 1rad=10KHz')
% speech_dft.wav
% toilet.wav
clc
clear
[Y,FS,NBITS]=wavread('speech_dft.wav');
x=fft(Y);
l=length(x);
X=x(1:(l-1)/2);
r=1/((l-1)/2);
n=0:r:1-r;
subplot 211, plot(Y); subplot 212, plot(n,abs(X))
pause
% ½ of FS Hz corresponds to normalized 1 rad
%To remove 200Hz to 300Hz freq range % 2KHz is (2/FS)*200 rad % & 3KHz is (2/FS)*300 rad
rad_start=(2/FS)*200;
rad_stop=(2/FS)*300;
p_start=0;
for j=1:length(n)
if rad_start>=n(j)
p_start=j;
end
end
p_stop=0;
for j=1:length(n)
if rad_stop>=n(j)
p_stop=j;
end
end
Z=x;
for j=p_start:p_stop
Z(j)=0;
end
for j=l-p_stop:l-p_start
Z(j)=0;
end
subplot 211, plot(abs(x)); subplot 212, plot(abs(Z))
pause
y=ifft(Z);
subplot 211, plot(abs(Y));subplot 212, plot(abs(y))
wavwrite(y,FS,16,'processed_signal.wav');
wavwrite(y,FS,16,'original_signal.wav');
No comments:
Post a Comment