# Filter Design Using Second-Order Peaking and Shelving Sections

Skip other details (including permanent urls, DOI, citation information)This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 3.0 License. Please contact mpub-help@umich.edu to use this work in a way not covered by the license. :

For more information, read Michigan Publishing's access and usage policy.

Page 00000001 Filter Design Using Second-Order Peaking and Shelving Sections Jonathan S. Abel and David P. Berners Universal Audio, Inc., Santa Cruz, CA 95063, USA - {abel, dpberner}@uaudio. com, www.uaudio. com Abstract traditional and novel graphic equalizers A method for designing audio filters is developed based on the observation that second-order peaking and shelving filters can be made nearly self-similar on a log magnitude scale with respect to peak and shelf gain changes. By cascading such second-order sections, filters are formed which may be fit to dB magnitude characteristics via linear least-squares techniques. A graphic equalizer interpolating prescribed band gains is presented, along with a filter minimizing the Barkweighted mean square dB difference between modeled and desired transfer function magnitudes. It is noted that using second-order sections parameterized by transition frequency and gain provides a natural mechanism for slewing and interpolation between tabulated designs. 1 Introduction In a traditional graphic equalizer for audio, the transfer function is controlled by specifying the gains for each of a set of cascaded peaking and shelving filters (Bohn ). While it is desired that the transfer function magnitude smoothly interpolate the given gains, this is not always the case. As seen in Fig. 1, if the filter bandwidths are small, the transfer function will exhibit ripples, heading to unity gain at frequencies between the band centers. On the other hand (also shown in Fig. 1), if the component filter bandwidths are sufficiently broad that the transfer function magnitude is smooth, the transfer function will often overshoot the desired gain due to contributions from adjacent bands. Other filter design methods, such as Prony or Hankel methods (Smith), can closely match a given transfer function magnitude. They, however, are not easily adapted to psychoacoustically meaningful goodness-of-fit measures, which involve minimizing dB differences in transfer function magnitude over a Bark or ERB frequency scaling. Those methods that apply psychoacoustic measures in designing filters can be II..' I ^ - ^ ^ ^ ^ i i i i i 'i i i i i i i iii........."\i I,..:j:::.:.::\ / 4.i: i \ \ i i i\ \ ii ^ r 4 841 10r frequency- kHz Figure 1: Graphic Equalizer Transfer function magnitudes for graphic equalizers with band gains set at +5.0 dB, and using traditional narrow (dash-dotted) and wide (dashed) bandwidth component filters, and using novel gain computation described here (solid). computationally cumbersome due to the nonlinear optimization involved (Smith). In any event, these design approaches are generally not useful for applications such as HRTF filtering (Wenzel), where the resulting filter needs to be slewed or interpolated between tabulated designs. The reason is that the poles and zeros maximizing a goodness of fit rarely can be related to particular features in the desired transfer function magnitude. As a result, there is often no clear way to process sets of tabulated filter coefficients that leads to a meaningful filter intermediate between table entries. In this paper, we present a filter design method which circumvents many of these difficulties. As we show later, second-order peaking and shelving filters can be constructed to have the property that, as a function of section gain, they possess approximately self-similar dB transfer-function magnitudes. This property enables the use of linear least-squares techniques to optimize the gains in a cascade of filter sections to match a desired dB transfer-function magnitude. Proceedings ICMC 2004

Page 00000002 Second-order peak and shelf filters and their properties are discussed in ~2 and the Appendix, a graphic equalizer design described in ~3, and a transfer function modeling method presented in ~4. 2 Peaking and Shelving Filters The peak filter p(w; A, (p~) used here is characterized by a maximum dB gain A, achieved somewhere between two transition frequencies (_ and (pt, at which the dB gain is A/2. The filter takes on a gain of one at DC and the band edge. (Formulas for computing the coefficients of the second-order digital filter meeting these constraints are given in the Appendix.) By parameterizing the peak filter in this way, note that it is approximately self similar on a log magnitude scale, as illustrated in Fig. 2 and Fig. 3. Put differently, the scaled log magnitude transfer function approximates the log magnitude of the transfer function of the peak filter generated using a scaled dB gain: normalized peak filter transfer function magnitudes, gain = [2:2:20] 0.6 04 0)2 10nkHz Figure 3: Normalized Peak Filters. The set of example peakfilter transfer functions shown in Fig. 2, with each filter's dB magnitude scaled to have 1.0 dB maximum gain. Note the self similarity. A high shelf filter taking on a dB gain A at the band edge, with a DC gain of one is easily generated, and shares the approximate self similarity property. Formulas for first-order and second-order digital shelf filters are given in the Appendix. a log |p(w; A, (p~) I log |p(w; a - A, p~). (1) second-order shelf filter transfer function magnitudes, gain = [2:2:20] second-order peak filter transfer function magnitudes, gain = [2:2:20] 15 -(D -010 -cl E f 10 frequency -kHz 10r frequency-kHz Figure 2: Peak Filter, Various Gains. An example peak filter transfer function is shown with transition frequencies of 0.5 kHz and 2.0 kHz, and filter gains in the range [2.0, 20.0] dB. Similarly, the low shelf filter s(w; A, (p) takes on a dB gain A at DC, a dB gain A/2 at the specified transition frequency (p, and a gain of one at the band edge. As seen in Fig. 4 and Fig. 5, the shelf filter also is approximately self similar. Figure 4: Shelf Filter, Various Gains. An example shelf filter transfer function is shown with a transition frequency of 1.0 kHz, and filter gains in the range [ 2.0, 20.0] dB. 3 Graphic Equalizer Design The self similarity of second-order peaking and shelving filters enables linear least-squares fitting of a cascade of such filters to a desired log magnitude transfer function. Consider a cascade of K peak and shelf filters g(w; 0) having gains Ak, k = 1,..., K and transition frequencies (pk, k = 17...7., K - 1 stacked in the column 0, a log s(w; A, p) |Mlog s(w; a -A, p)|. (2) Proceedings ICMC 2004

Page 00000003 normalized shelf filter transfer function magnitudes, gain = [2:2:20] For a graphic equalizer with K - 1 fixed band edges, the frequencies wi can be chosen as the K band centers, and the gains A simply computed as the control gains r scaled by the basis inverse, 0.8 0.6 - c E '0.4 -0.2 - A = B-7. (8) Such a gain computation was used to produce the equalizations shown in Fig. 1 and Fig. 6, which are seen to smoothly interpolate the desired gains at the band center frequencies. Note that applying the desired gains to the same second-order filters (or to narrower-bandwidth filters) as is traditional results in a transfer function which is either excessively rippled or is not near the desired levels at the band center frequencies. traditional and novel graphic equalizers 10H frequency- kHz Figure 5: Normalized Shelf Filters. The set of example shelf filter transfer functions shown in Fig. 4, with each filter's dB magnitude scaled to have 1.0 dB maximum gain. Note the self similarity. g(CJ;O) = s(w;Ai,pi). S(W;AK,(PK-1) K-1 SJ p(WI;Ak,pk1,pk). (3) k=2 Because of the self similarity property, the dB magnitude of the cascade, denoted by 7(w; 0), 7(; 0) =2 20logo {g(w; 0)}, (4) f 10 frequency - kHz is approximately linear in the filter gains. Stacking instances of 7(w; 0) evaluated at a set of frequencies wi to form the column y, we have 7 BA, (5) B = [oi OK 72 2 "K-. T-1], (6) where the shelf and peak filter transfer function log magnitudes o7(w; 1.0dB, pk) and 7r(w; 1.0dB, Ok-1, 0k) are evaluated using gains of 1.0 dB at frequencies wi, and stacked to form the basis matrix B. Therefore, given a set of shelf and peak filters having specified transition frequencies, and positive definite weighting matrix W, the gains A = (BTWB)-IBTWrl (7) will approximately minimize the weighted mean square difference between a desired dB magnitude response r and the shelf and peak filter cascade dB magnitude at frequencies wi, y. (To account for any discrepancies in the self similarity property, (7) may be solved iteratively, forming B using the gains from the previous solution.) Figure 6: Graphic Equalizer Example. Transfer function magnitudes for equalizers with desired band gains shown (o marks), and using traditional (dashed) and novel (solid) gain computations. 4 Transfer Function Modelling The design method of ~3 can be extended to modelling of arbitrary transfer functions if coupled with a technique for determining the required number of filter sections, and a basis for fixing the transition frequencies of those sections. To enable feature extraction from the transfer function to be modelled, critical-band smoothing can first be applied (Smith ). If the extrema of the smoothed magnitude transfer function are tabulated, transition frequencies for the shelf and peak filters can be computed as the geometric means of those extrema frequencies. Alternatively, the transition frequencies can be assigned at points where the smoothed magnitude transfer function has second-derivative zeros, i.e. inflection points. Proceedings ICMC 2004

Page 00000004 Once the transition frequencies are determined, the gains A can be computed using (7). Here, however, a dense sampling of frequencies wi should be used (say spaced according to a Bark or ERB frequency scale) to produce the desired dB magnitude 17 so as to ensure a good match across the entire audio band. The dimension of q will greatly exceed the number of filter sections, and we will have an overdetermined least-squares problem. In this case, the resulting transfer function magnitude will approximate rather than interpolate the desired magnitudes at the sampled frequencies, minimizing the mean square dB difference. Shown in Fig. 7 is an HRTF with approximately six major peaks and valleys in its magnitude transfer function. Plotted along with the HRTF is a fit based on the model described above. In terms of closeness-of-fit, this model requires a higher filter order (one second-order section per modeled peak or notch) than a warped Prony or Hankel norm method (Smith ) (typically, a little more than a second-order section per modeled peak and notch) to achieve the same quality. However, the parametric representation given by this model allows interpolation between related filters with ease, while interpolation using Hankel, Prony or like methods is difficult at best. desired and modeled transfer function magnitudes The second-order digital filter bo + biz1 + b2z2 1 + aiz-1 + a2z-2 with coefficients given by 2Q - sin lpc a2 - 2Q + sin pc, (9) (10) a = b= -(1 + a2) COSý (11 1 1 bo= (1+a2)+-(1-a2)v, (12) 2 2 1 1 b2 (1+a2)--(1-a2) v, (13) 2 2 implements a peak (or notch) filter with maximum (or minimum) gain v = 10A/20 at a center frequency cp between the specified transition frequencies p~, at which the filter takes on magnitude ý/ii. The center frequency pc and the inverse bandwidth Q may be written in terms of the transition frequencies (p~ and dB peak gain A, (C =acos I r,- signf } (r,2 -1), S= ~ 1c + Cos ( Cos P~ COS (p + COS ýP~.2_ 1 v - sin 2c (cos 0 + cos p~) 2 2 2 coscp, - cos p- - cos p~ (14) (15) (16) In the case that p+ + (p_ = 7, where n becomes infinite, (D -0-10 cl E _15 Pc = w/2, Q = cot6 6=-(_-p~). 2 2 (17) (18) References 10H frequency-kHz Figure 7: HRTF Modelling. A smoothed measured HRTF magnitude (dashed) is shown with extrema (o marks) and the magnitude of the peak and shelffilter cascade fit to the smoothed HRTF (solid). 5 Appendix In this appendix, formulas are presented for the coefficients of second-order digital peaking filters. A design method for second-order shelving filters is presented in (Berners and Abel ). Berners, D. P. and J. S. Abel (2003). Discrete-time shelf filter design for analog modeling. In Audio Engineering Society 115th Convention, preprint 5939. Audio Engineering Society. Bohn, D. A. (1986). Constant-Q graphic equalizers. The Journal of the Audio Engineering Society 34, 611-626. Smith, J. 0. III (1983). Techniques for Digital Filter Design and System Identification with Application to the Violin. Ph. D. thesis, Stanford University. Wenzel, E. M. (1992). Localization in virtual acoustic displays. Presence 1. 80-107. Proceedings ICMC 2004