-
Notifications
You must be signed in to change notification settings - Fork 1
/
pareq.m
29 lines (28 loc) · 840 Bytes
/
pareq.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [num, den] = pareq(G, GB, w0, B)
% [num, den] = pareq(G, GB, w0, B)
% Second-order parametric equalizing filter design
% with adjustable bandwidth gain
%
% [num, den] = pareq(G, GB, w0, B)
%
% Parameters
% G = peak gain (linear)
% GB = bandwidth gain (linear)
% w0 = center frequency (rads/sample)
% B = bandwidth (rads/sample)
%
% Output
% num = [b0, b1, b2] = numerator coefficients
% den = [1, a1, a2] = denominator coefficients
%
% Written by Vesa Valimaki, August 24, 2016
%
% Ref. S. Orfanidis, Introduction to Signal Processing, p. 594
% We have set the dc gain to G0 = 1.
if G==1,
beta = tan(B/2); % To avoid division by zero, when G=1
else
beta = sqrt(abs(GB^2 - 1)/abs(G^2 - GB^2)) * tan(B/2);
end
num = [(1 + G*beta), -2*cos(w0), (1 - G*beta)] / (1+beta);
den = [1, -2*cos(w0)/(1+beta), (1-beta)/(1+beta)];