滤波器设计

Peak

code

% Loader Octave packages
pkg load signal

% Sample Rate
Fs = 48000;

% Designed by personal tool Math.exe
% Math.exe filter --design -t 3 -w 1000 -f 48000 -b 10.0 -g 0.0 -s 8.0
% Fs       : 48000
% Fc       : 1000
% Boost    : 10.0
% Gain     : 0.0
% Slope    : 8.0
A_PEAK = [+1.000000, -1.973835, +0.990867];
B_PEAK = [+1.009874, -1.973835, +0.980993];

% Generate response matrix that size is Fs.
[H_PEAK, w_PEAK] = freqz(B_PEAK, A_PEAK, Fs);

% Transfer from Rad to Hz.
F_PEAK = (w_PEAK / (2 * pi)) * Fs;

% Transfer from Magnitude to DB
Hf_PEAK = mag2db(abs(H_PEAK));
Hx_PEAK = angle(H_PEAK);

clear figure
clf;
figure(1);

% Plot Magnitude VS Frequency
% Range: 1 ~ (Fs / 6) / 2 = 1 ~ 4000
% Because Freqz only return half result (1, +pi) rather than (-pi, +pi),
% So divided by 2.
subplot(2, 1, 1);
plot(F_PEAK(1:Fs/6,1), Hf_PEAK(1:Fs/6,1));

% Plot Phase VS Frequency
subplot(2, 1, 2);
plot(F_PEAK(1:Fs/6,1), Hx_PEAK(1:Fs/6,1));

plot

在这里插入图片描述

DF_I

  • 生成一个白噪音信号
  • 进行Direct formal I Biquad处理
  • 利用Audacity分析

注:
左图为经过处理的信号和源信号。
中图为经过处理的信号的频谱分析(FFT分析)
右图为经过源信号的频谱分析
在这里插入图片描述通过上图,可以明显看见,滤波效果非常显著。

Pass

code

% Loader Octave packages
pkg load signal

% Sample Rate
Fs = 48000;

% Corner Frequency
F0 = 1000;
Wn = [(F0-100)/(Fs/2), (F0+100)/(Fs/2)];

[B_PASS, A_PASS] = butter(2, Wn, 'pass');
% Generate response matrix that size is Fs.
[H_PASS, w_PASS] = freqz(B_PASS, A_PASS, Fs);

% Transfer from Rad to Hz.
F_PASS = (w_PASS / (2 * pi)) * Fs;

% Transfer from Magnitude to DB
Hf_PASS = mag2db(abs(H_PASS));
Hx_PASS = angle(H_PASS);

clear figure
clf;
figure(1);

% Plot Magnitude VS Frequency
% Range: 1 ~ (Fs / 6) / 2 = 1 ~ 4000
% Because Freqz only return half result (1, +pi) rather than (-pi, +pi),
% So divided by 2.
subplot(2, 1, 1);
plot(F_PASS(1:Fs/6,1), Hf_PASS(1:Fs/6,1));

% Plot Phase VS Frequency
subplot(2, 1, 2);
plot(F_PASS(1:Fs/6,1), Hx_PASS(1:Fs/6,1));

plot

在这里插入图片描述

Stop

code

% Loader Octave packages
pkg load signal

% Sample Rate
Fs = 48000;

% Corner Frequency
F0 = 1000;
Wn = [(F0-100)/(Fs/2), (F0+100)/(Fs/2)];

[B_STOP, A_STOP] = butter(2, Wn, 'stop');
% Generate response matrix that size is Fs.
[H_STOP, w_STOP] = freqz(B_STOP, A_STOP, Fs);

% Transfer from Rad to Hz.
F_STOP = (w_STOP / (2 * pi)) * Fs;

% Transfer from Magnitude to DB
Hf_STOP = mag2db(abs(H_STOP));
Hx_STOP = angle(H_STOP);

clear figure
clf;
figure(1);

% Plot Magnitude VS Frequency
% Range: 1 ~ (Fs / 6) / 2 = 1 ~ 4000
% Because Freqz only return half result (1, +pi) rather than (-pi, +pi),
% So divided by 2.
subplot(2, 1, 1);
plot(F_STOP(1:Fs/6,1), Hf_STOP(1:Fs/6,1));

% Plot Phase VS Frequency
subplot(2, 1, 2);
plot(F_STOP(1:Fs/6,1), Hx_STOP(1:Fs/6,1));

plot

在这里插入图片描述

Cascaded

滤波器设计的关键一环就是就是级联。本例程将一个1000Hz的Peak filter和100Hz的Peak filter级联在一起。通过对比级联之后的频响曲线,评估级联滤波器的整体特征。

code

% Loader Octave packages
pkg load signal

% Sample Rate
Fs = 48000;

BIQUAD_0_A = [+1.000000, -1.973835, +0.990867];
BIQUAD_0_B = [+1.009874, -1.973835, +0.980993];

BIQUAD_1_A = [+1.000000, -1.998909, +0.999080];
BIQUAD_1_B = [+1.000994, -1.998909, +0.998086];

BIQUAD_CASCADED_A = conv (BIQUAD_0_A, BIQUAD_1_A);
BIQUAD_CASCADED_B = conv (BIQUAD_0_B, BIQUAD_1_B);

% Generate response matrix that size is Fs.
[H_BIQUAD_0, w_BIQUAD_0] = freqz(BIQUAD_0_B, BIQUAD_0_A, Fs);
[H_BIQUAD_1, w_BIQUAD_1] = freqz(BIQUAD_1_B, BIQUAD_1_A, Fs);
[H_CASCADED, w_CASCADED] = freqz(BIQUAD_CASCADED_B, BIQUAD_CASCADED_A, Fs);

% Transfer from Rad to Hz.
F_BIQUAD_0 = (w_BIQUAD_0 / (2 * pi)) * Fs;
F_BIQUAD_1 = (w_BIQUAD_1 / (2 * pi)) * Fs;
F_CASCADED = (w_CASCADED / (2 * pi)) * Fs;

% Transfer from Magnitude to DB
Hf_BIQUAD_0 = mag2db(abs(H_BIQUAD_0));
Hx_BIQUAD_0 = angle(H_BIQUAD_0);
Hf_BIQUAD_1 = mag2db(abs(H_BIQUAD_1));
Hx_BIQUAD_1 = angle(H_BIQUAD_1);
Hf_CASCADED = mag2db(abs(H_CASCADED));
Hx_CASCADED = angle(H_CASCADED);

clear figure
clf;
figure(1);

% Plot Magnitude VS Frequency
% Range: 1 ~ (Fs / 6) / 2 = 1 ~ 4000
% Because Freqz only return half result (1, +pi) rather than (-pi, +pi),
% So divided by 2.
subplot(3, 2, 1);
plot(F_BIQUAD_0(1:Fs/6,1), Hf_BIQUAD_0(1:Fs/6,1));
subplot(3, 2, 3);
plot(F_BIQUAD_1(1:Fs/6,1), Hf_BIQUAD_1(1:Fs/6,1));
subplot(3, 2, 5);
plot(F_CASCADED(1:Fs/6,1), Hf_CASCADED(1:Fs/6,1));

% Plot Phase VS Frequency
subplot(3, 2, 2);
plot(F_BIQUAD_0(1:Fs/6,1), Hx_BIQUAD_0(1:Fs/6,1));
subplot(3, 2, 4);
plot(F_BIQUAD_1(1:Fs/6,1), Hx_BIQUAD_1(1:Fs/6,1));
subplot(3, 2, 6);
plot(F_CASCADED(1:Fs/6,1), Hx_CASCADED(1:Fs/6,1));

plot

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值