function [num,den] = iirpeak(Wo,BW,varargin)
%IIRPEAK Second-order IIR peaking (resonator) digital filter design.

%   References:
%     [1] Sophocles J. Orfanidis, Introduction To Signal Processing
%         Prentice-Hall 1996.

%   Copyright 1999-2023 The MathWorks, Inc.

%#codegen

narginchk(2,3);

% Validate input arguments.
Ab = notchpeakargchk(Wo,BW,varargin,'iirpeak');

% Design a peaking filter.
[num,den] = secondorderPeak(Wo,BW,Ab);

%------------------------------------------------------------------------
function [num,den] = secondorderPeak(Wo,BW,Ab)
% Design a 2nd order IIR peaking (resonator) digital filter.

% Inputs are normalized by pi.
BW = BW*pi;
Wo = Wo*pi;

Gb   = 10^(-Ab/20);
beta = (Gb/sqrt(1-Gb.^2))*tan(BW/2);
gain = 1/(1+beta);

num  = (1-gain)*[1 0 -1];
den  = [1 -2*gain*cos(Wo) (2*gain-1)];


% [EOF]
