L. Vandenberghe EE236A (Fall 2013-14) Lecture 10 FIR filter design • linear phase filter design • magnitude filter design • equalizer design 10–1 Finite impulse response (FIR) filter y(t) = n−1 X τ =0 hτ u(t − τ ) • u : Z → R is input signal; y : Z → R is output signal • hi ∈ R are filter coefficients; n is filter order or length frequency response: a function H : R → C defined as H(ω) = h0 + h1e = n−1 X t=0 −jω + · · · + hn−1e ht cos tω − j n−1 X −j(n−1)ω (with j = √ −1) ht sin tω t=0 periodic and conjugate symmetric; we only need to consider ω ∈ [0, π] design problem: choose hi so that H satisfies/optimizes specifications FIR filter design 10–2 Example: lowpass FIR filter impulse response (order n = 21) h(t) 0.2 0.1 0 −0.1 −0.2 0 2 4 6 8 10 12 14 16 18 20 t frequency response: magnitude |H(ω)| and phase 6 H(ω) 1 3 2 H(ω) 0 10 −1 10 1 0 −1 −2 10 6 |H(ω)| 10 −2 −3 10 0 0.5 1 1.5 ω FIR filter design 2 2.5 3 −3 0 0.5 1 1.5 2 2.5 3 ω 10–3 Linear-phase filters suppose n = 2N + 1 is odd and impulse response is symmetric about hN : ht = hn−1−t, t = 0, . . . , n − 1 frequency response H(ω) = h0 + h1e−jω + · · · + hn−1e−j(n−1)ω = e−jN ω (2h0 cos N ω + 2h1 cos(N −1)ω + · · · + hN ) = e−jN ω G(ω) • term e−jN ω represents N -sample delay • G(ω) is real-valued and |H(ω)| = |G(ω)| • ‘linear phase’: FIR filter design 6 H(ω) is linear except for jumps of ±π 10–4 Lowpass filter specifications δ1 1/δ1 δ2 ωp ωs π ω • maximum passband ripple (±20 log10 δ1 in dB): 1/δ1 ≤ |H(ω)| ≤ δ1 for ω ∈ [0, ωp] • minimum stopband attenuation (−20 log10 δ2 in dB): |H(ω)| ≤ δ2 FIR filter design for ω ∈ [ωs, π] 10–5 Linear-phase lowpass filter design • sample the frequency axis: ωk = kπ/K, k = 0, . . . , K − 1 • assume without loss of generality that G(0) > 0, so ripple spec. is 1/δ1 ≤ G(ωk ) ≤ δ1 maximum stopband attenuation (for given passband ripple δ1) minimize δ2 subject to 1/δ1 ≤ G(ωk ) ≤ δ1 for ωk ∈ [0, ωp] −δ2 ≤ G(ωk ) ≤ δ2 for ωk ∈ [ωs, π] • a linear program in variables hi, δ2 • known and used since 1960’s • can add other constraints, e.g., |hi| ≤ α FIR filter design 10–6 Example • linear-phase filter of order n = 31 • passband [0, 0.12π]; stopband [0.24π, π] • maximum ripple δ1 = 1.059 (±0.5dB) 0.2 0.15 h(t) 0.1 0.05 0 −0.05 −0.1 0 5 10 15 20 25 30 t 1 10 0 |H(ω)| 10 −1 10 −2 10 −3 10 −4 10 0 0.5 1 1.5 2 2.5 3 ω FIR filter design 10–7 Variations minimize passband ripple (variables δ1, h) minimize δ1 subject to 1/δ1 ≤ G(ωk ) ≤ δ1 for ωk ∈ [0, ωp] −δ2 ≤ G(ωk ) ≤ δ2 for ωk ∈ [ωs, π] minimize transition bandwidth (variables ωs, h) minimize ωs subject to 1/δ1 ≤ G(ωk ) ≤ δ1 for ωk ∈ [0, ωp] −δ2 ≤ G(ωk ) ≤ δ2 for ωk ∈ [ωs, π] minimize filter order (variables N , h) minimize N subject to 1/δ1 ≤ G(ωk ) ≤ δ1 for ωk ∈ [0, ωp] −δ2 ≤ G(ωk ) ≤ δ2 for ωk ∈ [ωs, π] not LPs, but can be solved by bisection/LP feasibility problems FIR filter design 10–8 Outline • linear phase filter design • magnitude filter design • equalizer design Filter magnitude specifications magnitude specification: a constraint L(ω) ≤ |H(ω)| ≤ U (ω) ∀ω L, U : R → R+ are given and H(ω) = n−1 X t=0 ht cos tω − j n−1 X ht sin tω t=0 • arises in many applications, e.g., audio, spectrum shaping • not equivalent to linear inequalities in hi (linear inequalities can not express the lower bound on absolute value) • can change variables and convert to set of linear inequalities FIR filter design 10–9 Autocorrelation coefficients definition: autocorrelation coefficients of h = (h0, . . . , hn−1) ∈ Rn rt = n−1−t X hτ hτ +t τ =0 (with hk = 0 for k < 0 or k ≥ n) rt = r−t and rt = 0 for |t| ≥ n; hence suffices to specify r = (r0, . . . , rn−1) Fourier transform of autocorrelation coefficients: R(ω) = X τ e−jωτ rτ = r0 + n−1 X t=1 2rt cos ωt = |H(ω)|2 magnitude specifications are linear inequalities in coefficients rt: L(ω)2 ≤ R(ω) ≤ U (ω)2 FIR filter design for ω ∈ [0, π] 10–10 Spectral factorization when is r ∈ Rn the vector of autocorrelation coefficients of some h ∈ Rn? spectral factorization theorem: if and only if R(ω) ≥ 0 for all ω • condition is an infinite set of linear inequalities in r • many algorithms for spectral factorization (find h s.t. R(ω) = |H(ω)|2) consequence: to cast magnitude design problem as an LP, • use r = (r0, . . . , rn−1) as variable instead of h = (h0, . . . , hn−1) • add spectral factorization condition as constraint: R(ω) ≥ 0 for all ω • discretize the frequency axis • optimize over r and use spectral factorization to recover h FIR filter design 10–11 Magnitude lowpass filter design maximum stopband attenuation design (with variables r) minimize γ2 subject to 1/γ1 ≤ R(ω) ≤ γ1 for ω ∈ [0, ωp] R(ω) ≤ γ2 for ω ∈ [ωs, π] R(ω) ≥ 0 for ω ∈ [0, π] (γi corresponds to δi2 in original problem) discretization: impose constraints at finite set of frequencies ωk minimize γ2 subject to 1/γ1 ≤ R(ωk ) ≤ γ1 for ωk ∈ [0, ωp] R(ωk ) ≤ γ2 for ωk ∈ [ωs, π] R(ωk ) ≥ 0 for ωk ∈ [0, π] this is a linear program in r, γ2 FIR filter design 10–12 Outline • linear phase filter design • magnitude filter design • equalizer design Equalizer design g(t) h(t) (time-domain) equalization • given g (unequalized impulse response), gdes (desired impulse response) • design FIR equalizer h so that convolution g̃ = h ∗ g approximates gdes example • gdes is pure delay D: gdes(t) = 1 t=D 0 t= 6 D • find equalizer h by solving minimize max |g̃(t)| t6=D subject to g̃(D) = 1 this can be cast as an LP in the coefficients hi FIR filter design 10–13 Example unequalized system (10th order FIR) • impulse response 1 0.8 g(t) 0.6 0.4 0.2 0 −0.2 −0.4 0 1 2 3 4 5 6 7 8 9 t • frequency response magnitude 1 10 3 G(ω) 0 10 1 0 −1 6 |G(ω)| 2 −2 −1 10 0 0.5 1 1.5 ω FIR filter design 2 2.5 3 −3 0 0.5 1 1.5 2 2.5 3 ω 10–14 time-domain equalization (30th order FIR, D = 10) minimize max |g̃(t)| t6=10 • equalized system impulse response 1 g̃(t) 0.8 0.6 0.4 0.2 0 −0.2 0 5 10 15 20 25 30 35 t • equalized frequency response 1 10 3 e G(ω) 0 10 1 0 −1 6 e |G(ω)| 2 −2 −1 10 0 0.5 1 1.5 ω FIR filter design 2 2.5 3 −3 0 0.5 1 1.5 2 2.5 3 ω 10–15 Magnitude equalizer design H(ω) G(ω) problem • given system frequency response G : [0, π] → C • design FIR equalizer H so that |G(ω)H(ω)| ≈ 1: minimize 2 max |G(ω)H(ω)| − 1 ω∈[0,π] LP formulation: use autocorrelation coefficients as variables minimize α 2 subject to |G(ω)| R(ω) − 1 ≤ α for ω ∈ [0, π] R(ω) ≥ 0 for ω ∈ [0, π] after discretizing the frequency axis, we obtain an LP in r and α FIR filter design 10–16 Multi-system magnitude equalization problem • we are given M frequency responses Gk : [0, π] → C • design FIR equalizer H so that |Gk (ω)H(ω)| ≈ constant: minimize max 2 max |Gk (ω)H(ω)| − γk k=1,...,M ω∈[0,π] subject to γk ≥ 1, k = 1, . . . , M LP formulation: use autocorrelation coefficients as variables minimize α 2 subject to |Gk (ω)| R(ω) − γk ≤ α R(ω) ≥ 0 for ω ∈ [0, π] γk ≥ 1, k = 1, . . . , M for ω ∈ [0, π], k = 1, . . . , M after discretizing the frequency axis, we obtain an LP in γk , r, α FIR filter design 10–17 Example • M = 2 systems, equalizer of order n = 25 2.5 2.5 2 2 |Gk (ω)H(ω)|2 |Gk (ω)|2 • unequalized and equalized frequency responses 1.5 1 0.5 0 0 0.5 1 1.5 ω FIR filter design 2 2.5 3 1.5 1 0.5 0 0 0.5 1 1.5 2 2.5 3 ω 10–18