Demo entry 6687324

FIR_Filter_TheNoise_of_Sound

   

Submitted by qiu_dao_zhe on Dec 28, 2017 at 02:46
Language: Matlab. Code size: 1.6 kB.

%GUI界面
screen=get(0,'ScreenSize');
W=screen(3);H=screen(4);
figure('Color','w','Position',[0.2*H,0.2*H,0.7*W,0.5*H],...
    'Name','语音信号去噪实验','NumberTitle','off','MenuBar','none');
play=uimenu(gcf,'Label','播放');
uimenu(play,'Label','播放原录音','Call','sound(s,fs);');
uimenu(play,'Label','播放加噪后的录音','Call','sound(sn,fs);');
uimenu(play,'Label','播放去噪后的录音','Call','sound(o,fs);');
uimenu(gcf,'Label','退出','Call','close(gcf)');

%语音信号加噪
[y,fs]=audioread('Ugly.wav');
s=y(:,1)';
L=length(s);
t=(0:L-1)/fs;f=fs*(0:L/2-1)/L;
FFT_s=fft(s);
n=0.3*sin(2*pi*t)+0.2*cos(2*pi*15000*t);
FFT_n=fft(n);
sn=s+n;
FFT_sn=fft(sn);
subplot(231);plot(t,s);title('语音信号的波形');axis([0 4 -2 2]);
xlabel('t(s)');ylabel('s');
subplot(234);plot(f,abs(FFT_s(1:L/2)));title('语音信号的频谱');axis([0 20000 0 100]);
xlabel('f(HZ)');ylabel('幅度');
subplot(232);plot(t,n);title('噪声的波形');axis([0 4 -2 2]);
xlabel('t(s)');ylabel('n');
subplot(235);plot(f,abs(FFT_n(1:L/2)));title('噪声的频谱');axis([0 20000 0 100]);
xlabel('f(HZ)');ylabel('幅度');
subplot(233);plot(t,sn);title('加噪语音信号的波形');axis([0 4 -2 2]);
xlabel('t(s)');ylabel('sn');
subplot(236);plot(f,abs(FFT_sn(1:L/2)));title('加噪语音信号的频谱');axis([0 20000 0 100]);
xlabel('f(HZ)');ylabel('幅度');

%FIR低通滤波器的设计
M=15;Wp=2*pi*9000/fs;Wc=2*pi*9500/fs;
m=0:(M+1)/2;
Wm=2*pi*m./(M+1);
mtr=floor(Wp*(M+1)/(2*pi))+2;
Ad=double([Wm<=Wp]);
Ad(mtr)=0.38;
Hd=Ad.*exp(-j*0.5*M*Wm);
Hd=[Hd conj(fliplr(Hd(2:(M+1)/2)))];
h=real(ifft(Hd));
w=linspace(0,pi,1000);
o=fftfilt(h,sn);
H=freqz(h,[1],w);
figure('Name','低通滤波器的相关指标');
plot(w*fs/(2*pi),abs(H));title('低通滤波器的频率响应');
xlabel('f(HZ)');ylabel('幅度');

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).