function [Bp,Ap] = boost3a(fs, fc, bw, gain, P); %BOOST - Design a boost filter at given gain, center % frequency fc, bandwidth bw, and sampling rate fs % (default = 1). % % Cookbook formulae for audio EQ biquad filter coefficients % by Robert Bristow-Johnson Q = bw/fs; Bp = zeros(P, 3); Ap = zeros(P, 3); for p=1:P, kp = IIRCalcQp(p, P); [Bp(p,:),Ap(p,:)] = peaking(fs, fc, kp*Q, gain); endfor B = Bp(1,:); A = Ap(1,:); if nargout==0 close freqz(B,A); title('Boost Frequency Response') end endfunction function [B,A] = peaking(fs, fc, Q, K) k1=-cos(2*pi*fc/fs); k2=(1-tan(Q/2))/(1+tan(Q/2)); Pz = [1 k1*(1+k2) k2]; % define denominator coefficients Qz = [k2 k1*(1+k2) 1]; % define numerator coefficients Num = (Pz*(1+K) + Qz*(1-K))/2; Den = Pz; B = Num; A = Den; endfunction function kp = IIRCalcQp(p, P) kp = 1.0/(2*sin(pi*(2*p-1)/(2*P))); endfunction