IIR digital filter design experiment

1. Experimental purpose:

Through computer experiments, master the method of using filters to filter out noise signals.

2. Experimental equipment and experimental environment

Operating system: Windows

Software: Matlab

3. Experiment content and requirements

1. Use the designed digital filter to filter the noisy speech signal;

2. Compare the spectrum of the speech signal before and after the filter, and observe whether the designed filter can effectively suppress the noise in the speech signal.

4. Experimental procedures and result analysis

4.1 Description of experimental process

(1) Collect voice signals

Use the audio recorder device under Windows to record a piece of voice for about 10 seconds. Then, under the Matlab software platform, use the function audioread to sample the speech signal to obtain the sound data variable x and sampling frequency fs. The interference signal is constructed as follows:

c1=10*sin(2*pi*2000*t);

Add the sound data variable x and the interference signal variable c1 to obtain a noisy voice signal x1 and play it. The voice signal accompanied by a sharp interference howling sound can be obviously heard through the speaker.

(2) Design digital filter

      According to the characteristics of the speech signal x1 to be processed, a digital band-stop filter should be designed for filtering processing. The third experiment designed a FIR band-stop filter to filter the noisy speech signal. This experiment designed an IIR band-stop filter. The filter designed in Experiment 3 has been improved. The normalized performance indicators of the designed digital band stop filter are given:

     f0=2000/4000; fc=100/4000;

     ws=[f0-0.5*fc f0+0.5*fc];wp=[f0-fc f0+fc];

     rp=1;rs=30;

      Using Matlab software and the IIR digital filter design method, the design of the band stop filter is realized. The design code is as follows:

      [N,wc]=buttord(wp,ws,rp,rs);% Find the order frequency parameters of Butterworth digital filter

      [b,a]=butter(N,wc,'stop'); % Design the coefficients of the band stop filter

      [h,w]=freqz(b,a,fs);

    (3) Use a filter to filter the noisy speech signal

      Use the designed band stop filter to filter the collected speech signal x1 and perform FFT transformation:

      x2=filter(b,a,x1);

     X2=fft(x2,fs);

     sound(x2,fs);

      The filtered speech signal is replayed through the loudspeaker, and the noise-free speech signal can be heard.

4.2 Matlab source program

clear 
speech='D:\yinpin\luyin1.wav';
[x,fs]=audioread(speech);
x=downsample(x(:,1),8);
N=length(x);
t=(0:N-1)/fs;

X=fft(x,fs);%原始语音信号频谱
X=abs(X);
f=0:length(X)-1;
subplot(221)
plot(f,X);grid on;
title('原始语音信号频谱');
axis([0,8000,0,500]);

c1=sin(2*pi*2000*t);%干扰信号
x1=x'+c1;%加噪语音信号
sound(x1,fs);
% figure(3)
% plot(time,x1);grid on;
% title('含噪语音信号');
X1=fft(x1,fs);%加噪语音信号频谱
X1=abs(X1);
f=0:length(X1)-1;
subplot(222)
plot(f,X1);grid on;
title('加噪语音信号频谱');
axis([0,8000,0,500]);

%设计数字滤波器
%带阻滤波器归一化的性能指标
f0=2000/4000;fc=100/4000;
ws=[f0-0.5*fc f0+0.5*fc];wp=[f0-fc f0+fc];
rp=1;rs=30;
%采样IIR数字滤波器设计方法,实现带阻滤波器的设计
[N,wc]=buttord(wp,ws,rp,rs);%求出巴特沃斯数字滤波器的阶数频率参数
[b,a]=butter(N,wc,'stop');%设计带阻滤波器的系数
[h,w]=freqz(b,a,fs);
subplot(223)
plot(w/pi,abs(h));grid on;
axis([0,1,0,1.5]);
title('带阻滤波器幅频特性')

%用滤波器对含噪对含噪语音信号进行滤波
x2=filter(b,a,x1);
X2=fft(x2,fs);
sound(x2,fs);
subplot(224)
plot(f,abs(X2));grid on;
title('滤波后的语音信号频谱');
axis([0,8000,0,500]);

4.3 Analysis of experimental results

      The original speech signal spectrogram, noisy speech signal spectrogram, filtered speech signal spectrogram and band-stop filter amplitude-frequency characteristic diagram obtained in the experiment are as follows:

 

      It can be seen from the experimental results that the spectrum of the speech signal after adding noise has a peak at 2000Hz and 6000Hz, which is caused by adding interference signals. Comparing the spectrum diagrams before and after filtering, it can be seen that the filter successfully suppresses the interference of noise in the speech signal and achieves the purpose of removing noise.

5. Experience

    By thinking about the collection of speech signals in this experiment, the design of filters, the changes in spectrum before and after filtering, and the filtering effects, I have a more systematic grasp and understanding of signal collection, processing, transmission, display, and storage. , deepened the understanding of abstract knowledge in the classroom and consolidated the theoretical knowledge of digital signal processing.

Guess you like

Origin blog.csdn.net/qq_46035929/article/details/131008735