EEL335: Discrete-Time Sigals ad Systems. Itroductio I this set of otes, we cosider how we might go about desigig FIR filters with arbitrary frequecy resposes, through compositio of multiple sigle-peak geeral filters. 2. Geeral FIR filter A. Itroductio Cosider the frequecy respose H g ( e j plotted i Figure below. This filter passes through all ormalized frequecies without modificatio, but amplifies ( a > or atteuates ( a < frequecies i the rage [ c, c2 ]; also, there is a fiite-width trasitio regio of width from H g ( e j = to H g ( e j = a. As we will show below, assumig that we kow the impulse respose h g [ ] of this filter i terms of a, c, ad, we ca easily costruct filters that have more complex frequecy resposes. c2 H g ( e j a π c2 c c c2 π Figure B. Derivatio of ifiite impulse respose Below, we will use the iverse DTFT to determie the time-domai impulse respose h [ ] of the above filter, assumig o delay. For this filter, the iverse DTFT is give by, h g [ ] h g [ ] = = π ----- H 2π g ( e j e j d π ( c2 + ----- e 2π j c2 a d + ----- ----------- ( + π 2π c2 + a e j d + ( + c2 ----- c 2π aej ( d c a + ----- ----------- ( + c2 2π c + a e j d + c ( c ----- e 2π j d + ( c c a ----- ----------- 2π ( + a ejd ( c + ----- 2π aej d + c c c2 ( (2 ----- 2π ( c2 + c2 a ----------- ( c2 + a e j π d + ----- e 2π j d ( + c2 - -
EEL335: Discrete-Time Sigals ad Systems The itegral i equatio (2 is tedious to compute ad simplify; therefore, we solve the itegratio usig Mathematica (see fir_filter_desig_part2.b ad arrive at the followig expressio for h [ ]: h g [ ] = ( a cos( ( c + cos( ( c2 + cos( c cos( c2 si( π -------------------------------------------------------------------------------------------------------------------------------------------------, 2 + ------------------ π π < <. (3 Note that equatio (3 ca be further simplified, sice, si( π ------------------ = δ[ ] π for iteger. Therefore, (4 cos( ( c + cos( ( c2 + cos( c cos( c2 h g [ ] = ( a -------------------------------------------------------------------------------------------------------------------------------------------------,. (5 2 + δ[ ] < < π Note that, although h g [ ] is ifiite i legth, both forwards ad backwards i time, the impulse respose does decay to zero as. Figure 2 below, for example, plots h g [ ], 5 5, for c =, c2 = 3 2, = ad a = 2. 2.5 h g [ ].2..5 H g ( e j -3-2 - 2 3 + -------- 2π -. -.2-4 -2 2 4 Figure 2 C. Approximatig of ifiite impulse respose with a causal FIR filter Now, we will try to approximate the ifiite impulse respose i equatio (5 with a causal FIR filter usig the same procedure as we have used before: First, we will retai values for h g [ ] oly for a limited rage of, max max (6 sice values of h g [ ] approach zero as. Let us deote this fiite impulse respose as h g [ ], such that, h g [ ] = h g [ ] max max elsewhere (7 Secod, we will shift h g [ ] to be causal; let us deote the resultig impulse respose as ĥ g [ ] such that, ĥ g [ ] = h g [ max ]. (8-2 -
EEL335: Discrete-Time Sigals ad Systems Note that this shift will ot chage the steady-state frequecy respose of the resultig system, except to itroduce a delay at the output. Thus, the differece equatio correspodig to ĥ g [ ] ca be writte as: y [ ] = b k x [ k] where, 2 max k = (9 b k = ĥ g [ ] = h g [ max + k], k {,,, 2 max }. ( 3. Composite filter example A. Itroductio Give that we have computed the impulse respose h g [ ] for the filter i Figure, we are ow i positio to costruct filters with more complex frequecy resposes. Suppose, for example, we wated to costruct a filter with the idealized frequecy respose H c ( e j plotted i Figure 3 below for [, π]. (Sice He ( j is a eve fuctio, we do ot eed to explicitly plot it for = [ π,. We could, of course, derive the impulse respose h c [ ] of this filter by breakig up the iverse DTFT ito piecewise-cotiuous itegrals (as we did, for example, i equatio (2 above ad solvig the resultig expressio. Give that we have already compute h g [ ] [equatio (5], this difficult ad tedious procedure is ot ecessary, however. Istead, we ca treat H c ( e j as a composite filter cosistig of two differet H g ( e j filters coected i series. H c ( e j a 2 2 a 2 2 3 4 Figure 3 π Let, H ( e j = H g ( e j a a, c, c2 2, ad H 2 ( e j = H g ( e j a a2, c 3, c2 4, 2 where H g ( e j deotes the filter i Figure. The, we ca represet H c ( e j i Figure 3 as, H c ( e j = H ( e j H 2 ( e j or, i the time domai as, ( (2 (3-3 -
EEL335: Discrete-Time Sigals ad Systems h c [ ] ĥ [ ] * ĥ 2 [ ] (4 where ĥ [ ] ad ĥ 2 [ ] deote the causal FIR approximatios of the ifiite impulse respose of filters H ( e j ad H 2 ( e j, respectively. Below, we give oe example of such a composite filter. B. Example Let us assume that we wat to filter a piece of music, sampled at show i Figure 3 ad the followig umeric values: f s = 32 khz, with the composite filter a = ( 2 2 3.98. f = 375 Hz, f 2 = 5 Hz, (5 a 2 = ( 2 2.252, f 3 = 6 khz, f 4 = 5 khz, (6 ad f = Hz for both segmets. Note that the value of a correspods to +2dB (decibels, while the value of a correspods to -2dB. 2 First, we eed to covert the frequecy values above to ormalized frequecy values usig the coversio formula: = 2πf ------- f s (7 Applyig equatio (7, we get the followig values i terms of ormalized frequecy for f s = 32 = 3π 28, 2 = 3π 32, 3 = 3π 8, 4 = 5π 6 ad = 2 = 2π f f s = π 6. (8 The composite filter trasfer fuctio H c ( e j for the umeric values i (8 is plotted i Figure 4 below, i terms of ormal amplitude, ad decibel amplitude. khz: 4 3 2 H c ( e j 2log H c ( e j 5-5 -3-2 - 2 3 - Figure 4-3 -2-2 3 The FIR impulse-fuctio approximatios ĥ [ ] ad ĥ 2 [ ], correspodig to the filters defied by ( ad (2, respectively, are plotted i Figure 5 below for max = 5. Note that max was chose such that the h [ ] coefficiets ear = ad = 2 max are very close to zero i value. Now, we compute h c [ ], the composite-filter FIR impulse-fuctio approximatio, by covolvig ĥ [ ] ad ĥ 2 [ ] [see equatio (4 above]; h c [ ] is plotted i Figure 6. Observe from Figure 6, that h c [ ] is approximately twice as log as ĥ [ ]' ad ĥ 2 [ ] (2 vs. as should be expected from the covolutio operator. Also ote that may of the h c [ ] coefficiets are very close to zero i value; hece, we ca derive a shorter FIR filter by retaiig oly h c [ ] values i the rage [ 2, + 2 ], ad shiftig the resultig impulse respose to start at =. From Figure 6, we suggest that a value of 2 = 3 seems appropriate sice h c [ ] values for < 7 ad > 3 appear egligibly small. Let us deote the shorteed FIR filter as ĥ c [ ] : ĥ c [ ] = h c [ + 2 ], {,,, 2 2 }, 2 = 3. (9. For a amplitude A, the correspodig db value is give by 2log A. - 4 -
EEL335: Discrete-Time Sigals ad Systems.3.2 ĥ [ ]. -. -.2.3.2 2 4 6 8 ĥ 2 [ ]. -. -.2 2 4 6 8 Figure 5.4 h c [ ].2 -.2 -.4 5 5 2 Figure 6 This impulse respose ( ĥ c [ ] is plotted i Figure 7 below. Therefore, the differece equatio correspodig to this impulse fuctio is give by, 2 2 y [ ] = b k x [ k] k = (2 where, b k = ĥ c [ k], k {,,, 2 2 }, 2 = 3. (2 I Figure 8, we plot the magitude frequecy respose Ĥ c ( e j of system (2 give by, - 5 -
EEL335: Discrete-Time Sigals ad Systems.4 ĥ c [ ].2 -.2 -.4 2 3 4 5 6 Figure 7 6 Ĥ c ( e j = ĥ c [ ]e j = (22 both as a fuctio of ormalized frequecy ad real frequecy f. Note how closely we are able to approximate our desired frequecy respose (see Figure 4 with this FIR filter of legth 6; also ote that we ever had to compute h c [ ] usig the iverse DTFT, but rather computed it through time-domai covolutio of ĥ [ ] ad ĥ 2 [ ]. 4 3 Ĥ c ( e j 4 3 Ĥ c ( e j 2πf fs 2 2-3 -2-2 3-5 - -5 5 5 fkhz ( Figure 8 To see this filter i actio, we covolve ĥ with a sampled music file c [ ] x m [ ], ad compare the frequecy cotet of the origial music file x m [ ] ad the filtered music file y m [ ] where, y m [ ] = x m [ ] * ĥ c [ ]. (23 I Figure 9 below, we plot the spectrograms 2 of x m [ ] ad y m [ ], where we aalyze frequecy cotet i oe-secod log segmets with a 5% overlap. We also plot oe colum of both spectrograms (the magitude FFT for oe of the oe-secod segmets of x m [ ] ad y m [ ] i Figure below. Note, how the frequecy cotet i the rage f [ 375Hz, 5Hz] has bee amplified, while the frequecy cotet i the rage f [ 6kHz, 5kHz] has bee sigificatly atteuated, as we should expect from the frequecy respose of ĥ c [ ].. See the web page for this music file a 23.6 secod segmet of Key Roger s The Gambler, sampled at f s = 32 khz. 2. Recall from previous otes that the spectrogram gives us the magitude frequecy cotet of a sigal for short segmets of a log discrete-time sequece. - 6 -
EEL335: Discrete-Time Sigals ad Systems 5 Spectrogram ( x m [ ] 25 f ( Hz 75 5 25 5 5 2 t( sec 5 Spectrogram ( y m [ ] 25 f ( Hz 75 5 25 5 5 2 t( sec Figure 9-7 -
EEL335: Discrete-Time Sigals ad Systems 7 8 6 FFT ( x m [ ] 6 6 4 6 2 6 7 8 6 fkhz ( 5 5 FFT ( y m [ ] 6 6 4 6 2 6 fkhz ( 5 5 4. Coclusio Figure The Mathematica otebook fir_filter_desig_part2.b was used to geerate the detailed filterig example i this set of otes; that otebook also cotais a secod composite filter example for the same piece of music, where all the desig values (i.e., 2,, 3, 4 ad 2 are the same, except the values for a ad a 2 are reversed; that is, a = ( 2 2 ad a 2 = ( 2 2. (24 The filtered ad ufiltered music segmets referred to i these otes is available i mp3 ad wav formats o the course web site. - 8 -