How can I boost audio with a peak filter?

6 views (last 30 days)
yyyo
yyyo on 14 Nov 2022
Edited: Mathieu NOE on 14 Nov 2022
I want to boost the sound signal properly using the peak filter in Simulink. However, the peak filter has a frequency response below 0 dB. Is it appropriate to add it to the original signal? I often see peak filters with a frequency response above 0 dB as shown in the attached image. Can't this be reproduced using the notch-peak filter block in the DSP system toolbox?

Answers (1)

Mathieu NOE
Mathieu NOE on 14 Nov 2022
Edited: Mathieu NOE on 14 Nov 2022
hello
according to the doc
this is wha this block is doing :
IMHO this is more a passband / notch but not a audio peaking filter
the "real" audio peaking filter is given by this code below
simply export B and A arrays to a IIR simulink block and you're done !
G , gain in dB can be positive or negative as in your picture !
% demo peaking filter
% G is the logarithmic gain (in dB)
% FC is the center frequency
% Q is Q-term equating to (Fb / Fc)
% Fs is the sampling rate
fs = 44.1e3;
fc = 500;
Q = 3;
G_pos = 10; % positive dB gain
G_neg = -20; % negative dB gain
[B_pos, A_pos] = peaking(G_pos, fc, Q, fs); % put B and A in IIR simulink block
[B_neg, A_neg] = peaking(G_neg, fc, Q, fs); % put B and A in IIR simulink block
freq = logspace(1,4,300);
[g_pos,p_pos] = dbode(B_pos,A_pos,1/fs,2*pi*freq);
[g_neg,p_neg] = dbode(B_neg,A_neg,1/fs,2*pi*freq);
figure(1)
subplot(2,1,1),semilogx(freq,20*log10(g_pos),'b',freq,20*log10(g_neg),'r');
ylabel('Gain (dB)')
subplot(2,1,2),semilogx(freq,p_pos,'b',freq,p_neg,'r');
xlabel('Freq (Hz)')
ylabel('Phase (°)')
function [B, A] = peaking(G, fc, Q, fs)
% Derive coefficients for a peaking filter with a given amplitude and
% bandwidth. All coefficients are calculated as described in Zolzer's
% DAFX book (p. 50 - 55). This algorithm assumes a constant Q-term
% is used through the equation.
%
% Usage: [B,A] = peaking(G, Fc, Q, Fs);
%
% G is the logarithmic gain (in dB)
% FC is the center frequency
% Q is Q-term equating to (Fb / Fc)
% Fs is the sampling rate
%
K = tan((pi * fc)/fs);
V0 = 10^(G/20);
%Invert gain if a cut
if(V0 < 1)
V0 = 1/V0;
end
%%%%%%%%%%%%%%
% BOOST
%%%%%%%%%%%%%%
if( G > 0 )
b0 = (1 + ((V0/Q)*K) + K^2) / (1 + ((1/Q)*K) + K^2);
b1 = (2 * (K^2 - 1)) / (1 + ((1/Q)*K) + K^2);
b2 = (1 - ((V0/Q)*K) + K^2) / (1 + ((1/Q)*K) + K^2);
a1 = b1;
a2 = (1 - ((1/Q)*K) + K^2) / (1 + ((1/Q)*K) + K^2);
%%%%%%%%%%%%%%
% CUT
%%%%%%%%%%%%%%
else
b0 = (1 + ((1/Q)*K) + K^2) / (1 + ((V0/Q)*K) + K^2);
b1 = (2 * (K^2 - 1)) / (1 + ((V0/Q)*K) + K^2);
b2 = (1 - ((1/Q)*K) + K^2) / (1 + ((V0/Q)*K) + K^2);
a1 = b1;
a2 = (1 - ((V0/Q)*K) + K^2) / (1 + ((V0/Q)*K) + K^2);
end
%return values
A = [ 1, a1, a2];
B = [ b0, b1, b2];
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!