EE123 Digital Signal Processing
Lecture 16 Resampling
M. Lustig, EECS UC Berkeley Topics • http://rtl-sdr.com • Did you sign up for the ham exam? • Last time – D.T processing of C.T signals – C.T processing of D.T signals (ha?????) • Today – Downsampling – Changing Sampling Rate via DSP – Upsampling – Rational resampling
M. Lustig, EECS UC Berkeley DownSampling • Much like C/D conversion • Expect similar effects: –Aliasing –mitigate by antialiasing filter
• Finely sampled signal ⇒ almost continuous
–Downsample in that case is like sampling!
M. Lustig, EECS UC Berkeley Changing Sampling-rate via D.T Processing Downsampling:
x[n] M xd[n]=x[nM]
= xc(nT ) = xc(nMT) T 0 The DTFT: |{z} j! 1 ! 2⇡ X(e )= Xc j k T T T !! Xk ⌦ ⌦s |{z} |{z} 1 ! 2⇡ X (ej!)= X j k d MT c MT MT Xk ✓ ✓ ◆◆ M. Lustig, EECS UC Berkeley Changing Sampling-rate via D.T Processing The DTFT:
j! 1 ! 2⇡ X(e )= Xc j k T T T !! Xk ⌦ ⌦s 1 |{z}! |{z}2⇡ X (ej!)= X j k d MT c MT MT Xk ✓ ✓ ◆◆ jω jω we would like to bypass Xc and go from X(e )⇒Xd (e ) substitute counter to i=0,1,...,M-1 k = rM + i r=-∞,...,∞ two counters e.g., r: hours, i: minutes
M. Lustig, EECS UC Berkeley Changing Sampling-rate via D.T Processing
1 ! 2⇡ X (ej!)= X j k d MT c MT MT Xk ✓ ✓ ◆◆ M 1 1 1 1 ! 2⇡ 2⇡ = X j i r M T c MT MT T i=0 r= ✓ ✓ ◆◆ X X 1 ! 2⇡ j( M M i) j! 1 ! 2⇡ X(e ) X(e )= Xc j k T T T !! Xk | {z } |{z} |{z} M 1 j! 1 j( ! 2⇡ i) X (e )= X(e M M ) d M i=0 X stretch replicate by M M. Lustig, EECS UC Berkeley Changing Sampling-rate via D.T Processing M 1 j! 1 j( w 2⇡ i) X (e )= X e M M d M i=0 X ⇣ ⌘ X
⇡ ⇡ M=2 Xd ... ⇡ ⇡ Scale by M=2 Shift by (i=1)*2π/(M=2)
M. Lustig, EECS UC Berkeley Changing Sampling-rate via D.T Processing M 1 j! 1 j( w 2⇡ i) X (e )= X e M M d M i=0 X ⇣ ⌘ X
⇡ ⇡ M=3 Xd
⇡ ⇡ Scale by M=3 Shift by (i=1)*2π/(M=3) Shift by (i=2)*2π/(M=3) M. Lustig, EECS UC Berkeley Changing Sampling-rate via D.T Processing M 1 j! 1 j( w 2⇡ i) X (e )= X e M M d M i=0 X ⇣ ⌘ X
⇡ ⇡ M=3 Xd ... ⇡ ⇡
M. Lustig, EECS UC Berkeley Anti-Aliasing
LPF x[n] ⇡/M ↓M x˜[n] x˜d[n] =˜x[nM]
X
⇡ ⇡ M=3 Xd
⇡ ⇡
M. Lustig, EECS UC Berkeley UpSampling • Much like D/C converter • Upsample by A LOT ⇒ almost continuous • Intuition:
– Recall our D/C model: x[n] ⇒ xs(t)⇒xc(t)
– Approximate “xs(t)” by placing zeros between samples
– Convolve with a sinc to obtain “xc(t)”
M. Lustig, EECS UC Berkeley Up-sampling lower x x[n]=Xc(nT ) T xi[n]=Xc(nT 0) where T 0 = L integer L
Obtain xi[n] from x[n] in two steps:
x[n/L] n =0, L, 2L, (1) Generate: x = e 0 otherwise± ± ··· ⇢
x[n] xe[n]
M. Lustig, EECS UC Berkeley Up-Sampling
(2) Obtain xi[n] from xe[n] by bandlimited interpolation:
n xe[0] sinc xe[n] · L ⇣ ⌘ ...... n n x = x [n] sinc i e ⇤ L ⇣ ⌘ xi[n]
...... n M. Lustig, EECS UC Berkeley Up-Sampling x [n]=x [n] sinc(n/L) i e ⇤ 1 x [n]= x[k] [n kL] e k= X 1 1 n kL x [n]= x[k]sinc( ) i L k= X 1
M. Lustig, EECS UC Berkeley Frequency Domain Interpretation
xe[n] LPF x[n] ↑L gain=L xi[n] ⇡/L
L
sinc(n/L) ⇒ DTFT ⇡ ⇡ L L
M. Lustig, EECS UC Berkeley Frequency Domain Interpretation
xe[n] LPF x[n] ↑L gain=L xi[n] ⇡/M L not M
j! 1 j!n Xe(e )= xe[n] e kn= X 1 ≠ 0 only for n=mL (integer m) 1 | {z } j!mL = xe[mL] e = X(ej!L) m= X 1 =x[m]
Compress DTFT by a factor| {z of L!}
M. Lustig, EECS UC Berkeley Example:
Xc(j⌦) 1
⌦N ⌦ sampling T sampling T’=T/L j! j! X(e ) Xi(e )
⇡ ⇡ ⇡ ⇡ expanding L j! Xe(e )
⇡ ⇡ M. Lustig, EECS UC Berkeley Example:
Xc(j⌦) 1
⌦N ⌦ sampling T sampling T’=T/L j! j! X(e ) Xi(e )
1/T
··· ··· ⇡ ⇡ ⇡ ⇡ expanding L j! Xe(e )
⇡ ⇡ M. Lustig, EECS UC Berkeley Example:
Xc(j⌦) 1
⌦N ⌦ sampling T sampling T’=T/L j! j! X(e ) Xi(e ) L/T
1/T ··· ··· ··· ··· ⇡ ⇡ ⇡ ⇡ ⇡ expanding L L j! Xe(e )
⇡ ⇡ M. Lustig, EECS UC Berkeley Example:
Xc(j⌦) 1
⌦N ⌦ sampling T sampling T’=T/L j! j! X(e ) Xi(e ) L/T
1/T ··· ··· ··· ··· ⇡ ⇡ ⇡ ⇡ ⇡ expanding L L j! Xe(e ) 1/T ··· ··· ⇡ ⇡ ⇡ L M. Lustig, EECS UC Berkeley Example:
Xc(j⌦) 1
⌦N ⌦ sampling T sampling T’=T/L j! j! X(e ) Xi(e ) L/T
1/T ··· ··· ··· ··· ⇡ ⇡ ⇡ ⇡ ⇡ expanding L L j! Xe(e ) L 1/T ⇡ ⇡ ··· ··· L L ⇡ ⇡ ⇡ L M. Lustig, EECS UC Berkeley Practical Upsampling
• Can interpolate with simple, practical filters. What’s happening? • Example: L=3, linear interpolation - convolve with triangle x[n]
n ··· periodic sinc2 ideal
1/T ··· ··· ⇡ ⇡ ⇡ M.3 Lustig, EECS UC Berkeley Resampling by non-integer • T’ = TM/L (upsample L, downsample M)
LPF LPF x[n] ↑L gain=L ↓M ⇡/L ⇡/M
Or,
gain L LPF x[n] ↑L ↓M min{ ⇡ /L , ⇡ /M }
• What would happen if change order?
M. Lustig, EECS UC Berkeley Example: • L = 2, M=3, T’=3/2T (fig 4.30)
Xc(j⌦) 1
⌦N ⌦ sampling T X(ej!) Subsampling M=3
⇡ ⇡ ⇡ ⇡ expanding L=2 LP filtering j! ˜ Xe(e ) Xi = HdXe
⇡ ⇡ ⇡ ⇡ M. Lustig, EECS UC Berkeley Example: • L = 2, M=3, T’=3/2T (fig 4.30)
Xc(j⌦) 1
⌦N ⌦ sampling T j! Subsampling M=3 X(e ) 1/T 2/(3T)
⇡ ⇡ ⇡ ⇡ expanding L=2 LP filtering j! 2/T Xe(e ) ˜ 1/T Xi = HdXe
⇡ ⇡ ⇡ ⇡ M. Lustig, EECS UC Berkeley Multi-Rate Signal Processing • What if we want to resample by 1.01T? – Expand by L=100 – Filter π/101 ($$$$$) – Downsample by M=101
• Fortunately there are ways around it! – Called multi-rate – Uses compressors, expanders and filtering
M. Lustig, EECS UC Berkeley