Digital Signal Processing Discrete Sequences and Systems Moslem Amiri, Václav Přenosil Masaryk University Understanding Digital Signal Processing, Third Edition, Richard Lyons (0-13-261480-4) © Pearson Education, 2011. Discrete Sequences and Their Notation Signal processing ■ Science of analyzing time-varying physical processes ■ Continuous signal ■ Continuous in time ■ Continuous range of amplitude values ■ Analog (continuous) signal processing ■ Discrete-time signal ■ Time variable is quantized ■ Signal amplitude is quantized Because we represent all digital quantities with binary numbers, there's a limit to the resolution ■ Digital signal processing Discrete Sequences and Their Notation ■ Example ■ A continuous sinewave ■ Peak amplitude of 1 ■ Frequency f0 x(t) = sm(27rf0t) m f0 is measured in hertz (Hz) = cycles/second ■ t representing time in seconds ■ f0t has dimensions of cycles ■ 2ixf0t is an angle measured in radians 3 Discrete Sequences and Their Notation Figure 1-1 A time-domain sinewave: (a) continuous waveform representation; (b) discrete sample representation; (c) discrete samples with connecting lines. 4 Discrete Sequences and Their Notation Fig. 1-1 ■ Continuous sinewave sample it once every ts seconds using an analog-to-digital converter ■ Variable f in (a) is continuous ■ Index variable n in (b) is discrete and can have only integer values ■ x(n) is a discrete-time sequence of individual values ■ There is nothing between dots of x(n) x(t) = sin(2nf0t) —> x(n) = s'm(27rf0nt s) m x(t) and x(n) are referred to as time-domain signals Discrete Sequences and Their Notation Discrete system ■ A collection of hardware components, or software routines, that operate on a discrete-time signal sequence y(0),y(1),y(2),y(3),... x(0),x(1),x(2),x(3), (a) Discrete System (b) x(n) Discrete System y(n) Figure 1-2 With an input applied, a discrete system provides an output: (a) the input and output are sequences of individual values; (b) input and output using the abbreviated notation of x(n) and y(n). E.g., y(n) = 2x(n)-l Discrete Sequences and Their Notation i Given samples of a discrete-time sinewave (e.g., Fig. 1 -1 (b)), find frequency of waveform they represent ■ Possible to say sinewave repeats every 20 samples ■ Not possible to find exact sinewave frequency We need sample period ts to determine absolute frequency of discrete sinewave ■ If ts = 0.05 milliseconds/sample . , 20 samples 0.05 milliseconds sinewave period =-x-= 1 milliseconds period sample ■ Sinewave's frequency = 1/(1 ms) = 1 kHz Discrete Sequences and Their Notation Frequency domain ■ To represent frequency content of discrete time-domain signals ■ Called spectrum 8 Discrete Sequences and Their Notation x1 (n) in the time domain 1 ■■ 0.5 ■■ " (a) 0 -1 l l l | I 5 10 15 -0.5 + ^ x2(n) in the time domain 0.5 4 I— ■ ■ ■ 4 tint i ■ ■ (b) o •mi in i 5 10 15 a ^-++++4 ' " 20 -0.5' 25 30 25 ■4-1 AXi(m) amplitude in the frequency domain 0.5 ■■ Time (n) 0 f0 2fQ 3f0 4f0 5f0 Frequency ^ X2(m) amplitude in the 30 1 ■■ 0.5 ■■ Time (n) frequency domain 0.4 0 fQ 2f0 3f0 4f0 5f0 Frequency ^ xsum(n) in the time domain 1.5 ■■ 1 ■■ . 0.5 ■ ■ 20 (C) 0 -0.5 ■ ■ -1 ■■ -1.5 -L 1111' 11' il:-ii+4- 25 <4h 5 10 15 30 4-lH 1 ■■ 0.5 ■■ -*sLim(m) amplitude in the frequency domain Time (n) Q , 0 f0 *o 3/0 4f0 5f0 Frequency Figure 1-3 Time- and frequency-domain graphical representations: (a) sinewave of frequency fQ; (b) reduced amplitude sinewave of frequency 2fQ; (c) sum of the two sinewaves. 9 Discrete Sequences and Their Notation Fig. 1-3 xsum (n) = xi (n) + x2 (n) = ™(2nf0nts) + 0.4 x sin(2x2 f0nts) ■ xsum(n) nas a frequency component of f0 Hz and a reduced-amplitude frequency component of 2f0 Hz ■ Because x^(n) + x2{n) sinewaves have a phase shift of zero degrees relative to each other, no need to depict this phase relationship in Xsum(A7?) In general, phase relationships in frequency-domain sequences are important 10 Signal Amplitude, Magnitude, Power ■ Amplitude of a variable ■ Measure of how far, and in what direction, that variable differs from zero ■ Can be either positive or negative ■ Magnitude of a variable ■ Measure of how far, regardless of direction, its quantity differs from zero ■ Always positive 11 Signal Amplitude, Magnitude, Power ^ \x,(n)\ 1 +- 0.5 -- 0 10 15 20 25 30 Time (n) -0.5 - Figure 1-4 Magnitude samples, | x^(ri) \, of the time waveform in Figure l-3(a). 12 Signal Amplitude, Magnitude, Power ■ In frequency domain, we are often interested in power level of signals ■ Power of a signal is proportional to its amplitude (or magnitude) squared ■ Assuming proportionality constant is one, power of a sequence in time or frequency domains are V (W) =1 X(W) I2' Xpwr (m) =1 X(m) I2 ■ Often we want to know the difference in power levels of two signals in frequency domain ■ Because of squared nature of power, two signals with moderately different amplitudes will have a much larger difference in their relative powers 13 Signal Amplitude, Magnitude, Power 1 -- 0.5 ■■ 0 Xsum(m) amplitude in the frequency domain 0.4 1 ■- 0.5 ■■ 0 Xsum(m) power in the frequency domain 0.16 0 'o 2fo 3fo 4'o 5fo Frequency -I-■—■—"-^-► 0 fo 2fo 3fo 4fo 5fo Frequency Figure 1-5 Frequency-domain amplitude and frequency-domain power of the xsum(n) time waveform in Figure l-3(c). ■ Because of their squared nature, plots of power values often involve showing both very large and very small values on same graph ■ To make these plots easier to generate and evaluate, decibel scale is usually employed 14 Signal Processing Operational Symbols ■ Block diagrams ■ Are used to graphically depict the way digital signal processing operations are implemented ■ Comprise an assortment of fundamental processing symbols 15 Signal Processing Operational Symbols (a) b(n) Addition: -+\ + J-► a(n) a{n) = b{n) + c(n) c(n) (b) Subtraction: -T c(n) a(n) a(n) = b(n) - c(n) (c) n+3 a(n) =}J)(k) k= n = b(n) + b(n+1) + b(n+2) + fo(n+3) bin) (d) Multiplication: -► a(n) c(n) a(n) = b(n)c{n) = b{n)- c(ri) [Sometimes we use a " ■" to signify multiplication.] (e) b{ri) b{n) Unit delay: Delay a(n) a(n) a(n) = to(/>1) Figure 1-6 Terminology and symbols used in digital signal processing block diagrams. 16 Discrete Linear Time-Invariant Systems ■ Linear time-invariant (LTI) systems ■ Vast majority of discrete systems used in practice are LTI systems ■ LTI systems are very accommodating when it comes to their analysis ■ We can use straightforward methods to predict performance of any digital signal processing scheme as long as it's linear and time invariant 17 Discrete Linear Systems Linear ■ A linear system's output resulting from a sum of individual inputs is superposition (sum) of individual outputs z \ results in v / \ ->yM) z \ results in v / \ x2(n)->y2(n) / \ i / \ results in v / \ , / \ xx (n) + x2 (n)-> yx (n) + y2(n) m Also, if inputs are scaled by constant factors c1 and c2, output sequence parts are scaled by those factors too / \ , / \ results in v / \ , / \ cxxx {n) + c2x2 (n)-> c2yx (n) + c2y2 (n) 1 O Discrete Linear Systems (a) Input x(n) Linear Discrete System Output y(n) = -x(n)/2 Figure 1-7 Linear system input-to-output relationships: (a) system block diagram where y(ri) = -x(n)/2; (b) system input and output with a 1 Hz sinewave applied; (c) with a 3 Hz sinewave applied; (d) with the sum of 1 Hz and 3 Hz sinewaves applied. 19 Discrete Linear Systems ■ Linearity in Fig. 1-7(d) ■ x3(n) input sequence is sum of a 1 Hz sinewave and a 3 Hz sinewave ■ Thus y3(n) is sample-for-sample sum of y^(n) and y2(n) m Also output spectrum Y3(at7) is sum of Y^m) and Y2(m) 20 Discrete Linear Systems (a) Input x(n) Nonlinear Discrete System Output y(n) = [x(n)]" Figure 1-8 Nonlinear system input-to-output relationships: (a) system block diagram where y(n) = (x(n))2; (b) system input and output with a 1 Hz sinewave applied; (c) with a 3 Hz sinewave applied; (d) with the sum of 1 Hz and 3 Hz sinewaves applied, 21 Discrete Linear Systems y\ O) = Fig. 1-8(b) xx (n) = sin(27f0nts) = sin(2^ x 1 x nts) yx (n) = [xj (/?)]2 = sin(2^- x 1 x nts) x sin(2^- x 1 x nts) . , x . cos(a-6) cos(a + B) sm(a) x sin(p) =--- 2 2 cos(2;z" x 1 x «^ - 2n x 1 x «^ ) cos(2^ x 1 x nts + 2^ x 1 x nts) 2 2 cos(O) cos(4^xlx^) 1 cos(2^x2x^) 2 2 ~ 2 2 ■ y^n) is a cosine wave of 2 Hz and a peak amplitude of -0.5, added to a constant value (zero Hz) of 1/2 Fig. 1-8(c) ■ Y2(n) contains a zero Hz and a 6 Hz component 22 Discrete Linear Systems Fig. 1-8(d) ■ x3(n) comprises sum of a 1 Hz and a 3 Hz sinewave a = \Hz sinewave, b = 3 Hz sinewave —> (a + b) = a + lab + b a —> zero Hz and 2 Hz b —» zero Hz and 6 i/z 2aZ? = 2 sin(2;z" x 1 x nts) x sin(2^ x 3 x nts) 2 cos(2;r x 1 x «^ - 2n x 3 x nts) 2 cos(2^ x 1 x «^ + 2^ x 3 x nts) 2 2 = cos(2;r x2xnts)- cos(2^ x4x«/J 2aZ? -^2 Hz and 4 #z ■ Two additional sinusoids are present in y3(n) because of system's nonlinearity, a 2 Hz cosine wave (amp=+1), a 4 Hz cosine wave (amp=-1) Time-Invariant Systems Time-invariant system ■ A time delay (or shift) in input sequence causes an equivalent time delay in system's output sequence / \ results in v / \ x(n)->y(n) x (n) = x(n + k)—results in > y (w) = y(n + k) ■ k is some integer representing k sample period time delays ■ For a system to be time invariant, above equation must hold true for any integer value of k and any input sequence 24 Time-Invariant Systems (a) Input x(n) Linear Time-Invariant Discrete System Output y(n) = -x{n)/2 kx(n) (b) 0 -1 4 6 8 10 0 2 12 14 Time 0.5 0 -0.5 iy(n) 12 14. 4 6 8 10 Time A x'(n) (c) 0 -1 ■ . 8 10 12 14 0 2 4 6 Time 0.5* 0 0 2 -0.5 i 4 6 8 10 12 14 Time Figure 1-9 Time-invariant system input/output relationships: (a) system block diagram, y(ri) = -x(n)/2; (b) system input/output with a sinewave input; (c) input/output when a sinewave, delayed by four samples, is the input. 25 Time-Invariant Systems Fig. 1-9 ■ Input sequence x'{n) is equal to sequence x{n) shifted to right by k = -4 samples x (n) = x(n-4) m System is time invariant because y"{n) output sequence is equal to y{n) sequence shifted to right by four samples y\n) = y(n-4) 26 Commutative Property of LTI Systems LTI systems have a useful commutative property ■ Their sequential order can be rearranged with no change in their final output Input x(n) LTI An) LTI System #1 System #2 Input x(n) LTI Sin) LTI Output y(n) (b) System #2 System #1 Figure 1-10 Linear time-invariant (LTI) systems in series: (a) block diagram of two LTI systems; (b) swapping the order of the two systems does not change the resultant output y(ri). Analyzing LTI Systems ■ Unit impulse response of an LTI system ■ System's time-domain output sequence when input is a single unity-valued sample (unit impulse) preceded and followed by zero-valued samples ■ System's unit impulse response completely characterizes the system 28 Analyzing LTI Systems (a) Input x(n) Linear Time-Invariant Discrete System Output y(n) (b) iix(n) impulse input 1- ^unity-valued sample Ay(n) impulse response 0 Time 0 Time Figure 1-11 LTI system unit impulse response sequences: (a) system block diagram; (b) impulse input sequence x(n) and impulse response output sequence y(n). 29 Analyzing LTI Systems ■ Knowing impulse response, we can determine system's output for any input ■ Output is equal to convolution of input sequence and system's impulse response ■ Moreover, we can find system's frequency response by taking discrete Fourier transform of that impulse response 30 Analyzing LTI Systems x(n-1) x(n-2) x(n-3) (a) A x(n) impulse input 1 (b) (c) iiy(n) impulse response 1/4 unity-valued sample A \Y(m)\ 1 0.75+ 0.5 0.25 0 n (Time) 0 n (Time) / Discrete Fourier transform Frequency magnitude response — 0 H—h 3 H—I—I—I—I—I—h 6 9 12 15 18 m(Freq) Figure 1-12 Analyzing a moving averager: (a) averager block diagram; (b) impulse input and impulse response; (c) averager frequency magnitude response. 31 Analyzing LTI Systems Fig. 1-12 ■ A4-point moving averager 1 1 v, y(n) = — [x(n) + x(n -1) + x(n — 2) + x(n - 3)] = — > x(k) k=n-3 m Frequency magnitude response plot shows that moving averager has characteristic of a lowpass filter ■ Averager attenuates (reduces amplitude of) high-frequency signal content applied to its input 32