滤波器相位补偿

概要

滤波器使用的过程中都会产生相位的改变。有时,相位的改变并不是我们想要的。例如,笔者在做Dolby Atmos的bass management的时候。希望将顶置的低频成分分割到左右通道或环绕通道。因为相位的缘故,叠加之前,左右通道或环绕通道需要做相位补偿。

一般来说,推荐用全通滤波器来做相位补偿。用全通滤波器来做相位补偿,一般2阶的滤波器(高低通)则用1阶的全通来补偿。可以调整Q值来拟合。

Octave仿真

其实Matlab更好,但是很贵。不鼓励盗版。还是用Octave吧。

请注意,Octave需要提前装载signal包。

pkg load signal

代码

% Sample Rate
Fs = 48000;

% Corner Frequency
Fc = 180;

% clear figure
% clf;
% figure(1);

% Generate highpass filter coefficients
[B_HP, A_HP] = butter(2, Fc/(Fs/2), 'high');
[H_HP, w_HP] = freqz(B_HP, A_HP, 1024)
Hf_HP = abs(H_HP);
Hx_HP = angle(H_HP);
subplot(3, 2, 1);
plot(w_HP, Hf_HP);
subplot(3, 2, 2);
plot(w_HP, Hx_HP);

% Generate lowpass filter coefficients
[B_LP, A_LP] = butter(2, Fc/(Fs/2));
[H_LP, w_LP] = freqz(B_LP, A_LP, 1024)
Hf_LP = abs(H_LP);
Hx_LP = angle(H_LP);
subplot(3, 2, 3);
plot(w_LP, Hf_LP);
subplot(3, 2, 4);
plot(w_LP, Hx_LP);

% Generate allpass filter coefficients
[~,A_AP] = butter(1, Fc/(Fs/2));
B_AP = fliplr(A_AP);     % Flip coefficients for allpass denominator
[H_AP, w_AP] = freqz(B_AP, A_AP, 1024)
Hf_AP = abs(H_AP);
Hx_AP = angle(H_AP);
subplot(3, 2, 5);
plot(w_AP, Hf_AP);
subplot(3, 2, 6);
plot(w_AP, Hx_AP);

结果
滤波器相位补偿_第1张图片上图,左列是幅频响应;右列是相频响应。幅频响应纵坐标是倍数,相频响应纵坐标是角频率(0 ~ Pi)。两者横坐标都是角频率(0 ~ Pi)。

你可能感兴趣的:(DSP学习笔记锦集)