You are on page 1of 55

DSP First, 2/e

LECTURE #1 Sinusoids,
Quick, Brief Treatment of
DSP First Approach

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 1

License Info for DSPFirst Slides

 This work released under a Creative Commons License


with the following terms:
 Attribution
 The licensor permits others to copy, distribute, display, and perform
the work. In return, licensees must give the original authors credit.
 Non-Commercial
 The licensor permits others to copy, distribute, display, and perform
the work. In return, licensees may not use the work for commercial
purposes—unless they get the licensor's permission.
 Share Alike
 The licensor permits others to distribute derivative works only under
a license identical to the one that governs the licensor's work.
 Full Text of the License
 This (hidden) page should be kept with the presentation

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 2

1
READING ASSIGNMENTS

 This Lecture for Chapter 2:


 Chapter 2, Sections 2-1, 2-2
 Chapter 2, Sects. 2-3 to 2-5
 Chapter 2, Section 2-6
 Chapter 1: Introduction
 Appendix B: MATLAB

 Suggested: Review Appendix A on Complex


Numbers
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 3

COURSE OBJECTIVE

 Students will be able to:


 Understand mathematical descriptions of
signal processing algorithms and express
those algorithms as computer
implementations (MATLAB)
 What are your objectives?

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 4

2
WHY USE DSP ?

 Mathematical abstractions lead to


generalization and discovery of new
processing techniques

 Computer implementations are flexible

 Applications provide a physical context

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 5

Fourier Everywhere
 Telecommunications
 Sound & Music
 CDROM, Digital Video
 Fourier Optics
 X-ray Crystallography
 Protein Structure & DNA
 Computerized Tomography
 Nuclear Magnetic Resonance: MRI
 Radioastronomy
 Ref: Prestini, “The Evolution of Applied Harmonic Analysis”

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 6

3
LECTURE OBJECTIVES
(go quickly)

 Write general formula for a “sinusoidal”


waveform x(t), or signal (continuous-
time)
 From the formula, plot the sinusoid versus
time.

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 7

TUNING FORK EXAMPLE,


(note Matlab plots)

 CD-ROM demo
 “A” is at 440 Hertz (Hz)
 Waveform is a SINUSOIDAL SIGNAL
 Computer plot looks like a sine wave
 This should be the mathematical formula:

A cos(2 ( 440)t   )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 8

4
TUNING FORK A-440 Waveform

T  8.15  5.85
 2.3 ms

Time (sec)

f  1/ T
 1000 / 2.3
 435 Hz
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 9

SPEECH EXAMPLE

 More complicated signal (BAT.WAV)


 Waveform x(t) is NOT a Sinusoid
 Theory will tell us
 x(t) is approximately a sum of sinusoids
 FOURIER ANALYSIS
 Break x(t) into its sinusoidal components
 Define a specialized frequency spectrum.

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 10

5
Speech Signal: BAT

 Nearly Periodic in Vowel Region


 Period is (Approximately) T = 0.0065 sec

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 11

DIGITIZE the WAVEFORM

 x[n] is a SAMPLED SINUSOID


 A list of numbers stored in memory
 Sample at 11,025 samples per second
 Called the SAMPLING RATE of the A/D
 Time between samples is 1/11025 = 90.7 sec
 Output via D/A hardware (at Fsamp)

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 12

6
STORING DIGITAL SOUND

 x[n] is a SAMPLED C-T signal (a D-T


signal)
 A list of numbers stored in memory
 CD rate is 44,100 samples per second
 16-bit samples
 Stereo uses 2 channels
 Number of bytes for 1 minute is
 2 X (16/8) X 60 X 44100 = 10.584 Mbytes
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 13

SINES and COSINES

 Always use the COSINE FORM

A cos(2 ( 440)t   )

 Sine is a special case:

sin( t )  cos( t  2 )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 14

7
SINUSOIDAL SIGNAL

A cos( t   )
 FREQUENCY
 Radians/sec
  AMPLITUDE A
 Magnitude
 Hertz (cycles/sec)
  (2 ) f
 PERIOD (in sec)
1 2
 PHASE

T 
Aug 2016 f  © 2003-2016, JH McClellan & RW Schafer 15

PLOTTING COSINE SIGNAL


from the FORMULA
cos(00..33t t11.2.2) )
5 cos(
 Determine period:
T  2 /   2 / 0.3  20 / 3
 Determine a peak location by solving
( t   )  0  (0.3 t  1.2 )  0
 Zero crossing is T/4 before or after
 Positive & Negative peaks spaced by T/2
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 16

8
PLOT the SINUSOID

5 cos(0.3 t  1.2 )
 Use T=20/3 and the peak location at t=-4

  203  

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 17

REVIEW TRIG. FUNCTIONS

 Common Values
 sin(k) = 0
 cos(0) = 1
 cos(2k) = 1 and cos((2k+1) ) = -1
 cos((k+0.5) ) = 0

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 18

9
LECTURE CONTINUED
OBJECTIVES
 Derive Sinusoid Formula from a plot

 Relate TIME-SHIFT to PHASE

 Signal ENVELOPE defined

 ATTENUATION of Decaying Sinusoid

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 19

TIME-SHIFTED SINUSOID
x(t )  5 cos(0.3 t ) One peak at t = 0

x (t  4)  5 cos(0.3 (t  4))  5 cos(0.3 (t  ( 4))

Peak shifts from t=0 to t = -4


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 20

10
PHASE  TIME-SHIFT

 Equate the formulas:

A cos( (t  tm ))  A cos( t   )
 and we obtain:   tm  
 or, 
tm  

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 21

(, ) from a PLOT (A=5)

T  10period
.01sec
 100
1
 2
T  2
0.01  200
tm  0.00125 sec    tm  (200 )(tm )  0.25
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 22

11
SINE DRILL (MATLAB GUI)

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 23

PHASE is AMBIGUOUS
 The cosine function is periodic, period is 2
A cos( t    2 )  A cos( t   )
 Thus adding any multiple of 2 to the phase
leaves x(t) unchanged
 Equivalent to time-shifting by one period:

A cos( t    2 ) 
A cos( (t  2 /  )   )  A cos( (t  T )   )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 24

12
Peak Locations of a
Sinusoid Function
 cos( ) attains max value at
  2n , n  0,  1,  2,  3,...
0.3 t  1.2  2n
5 cos(0.3 t  1.2 )
t m  ,10 23 ,  4, 2 23 ,

  20
3
 Many peaks;
One will be closest
to the origin

© 2003-2016, JH McClellan & RW


Aug 2016 Schafer 25

Time Shift and Time Delay


d At the origin/source:
x0 (t )  A cos(0t   0 )
td

At the destination: assuming no attenuation


xd (t )  A cos(0 (t  td )   0 )  A cos(0t  0td   0 )
Phase at the destination: ( 0td   0 ) mod 2

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 26

13
Attenuation
In real waves, there will always be a certain degree of
attenuation.

x (t )  A cos( t   )
In a sinusoid, A is a constant.
However, the amplitude can
A(t )  e  (t  2 ) / 2
have exponential decay, e.g.,
A(t )  Ae t / 
x (t )  Ae  t /  cos( t   )

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 27

MATLAB Example (I)


Generating sinusoids in MATLAB is easy:
% define how many values in a second
fs = 8000;
% define array tt for time
% time runs from -1s to +3.2s
% sampled at an interval of 1/fs
tt = -1 : 1/fs : 3.2;
xx = 2.1 * cos(2*pi*440*tt + 0.4*pi);

The array xx then contains a “sampled” signal of:

x(t )  2.1cos(880 t  0.4 )


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 28

14
MATLAB Example (II)
Introducing attenuation with time
% fs defines how many values per second
fs = 8000;
tt = -1 : 1/fs : 3.2;
yy = exp(-abs(tt)*1.2);% exponential decay
yy = xx.*yy;
soundsc(yy,fs)

Array yy contains a signal with changing amplitude:

y (t )  2.1e 1.2|t | cos(880 t  0.4 )


Soundsc lets you hear the signal yy

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 29

Plotting the Signal


Waveform “envelope”

a short slice

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 30

15
QUICK REVIEW: Phasors, etc.

 Phasors = Complex Amplitude


 Complex Numbers represent Sinusoids

A cos( t   )  {( Ae j )e j t }
 SKIP THIS: Develop the ABSTRACTION:
 Adding Sinusoids = Complex Addition
 PHASOR ADDITION THEOREM
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 31

COMPLEX ADDITION =
VECTOR Addition

z3  z1  z2
 ( 4  j 3)  ( 2  j5)
 (4  2)  j ( 3  5)
Aug 2016
 6  j2
© 2003-2016, JH McClellan & RW Schafer 32

16
Euler’s FORMULA, UNIT CIRCLE

 Complex Exponential
 Real part is cosine
 Imaginary part is sine
 Magnitude is one

e j  cos( )  j sin( )
re j  r cos( )  jr sin( )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 33

Common Values of ej


 Changing the angle
  0  1  1  j 0  e j 0  e j 2 n

    1  1  j 0  e j  e j ( 2 n 1)

   / 2  j  e j / 2  e j ( 2 n 1 / 2 )

  3 / 2   j  e j 3 / 2  e  j / 2  e j ( 2 n 1 / 2 )

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 34

17
COMPLEX EXPONENTIAL
SIGNAL (C. Sinusoid)

e j t  cos( t )  j sin( t )
 Interpret this as a Rotating Vector
 t
 Angle changes vs. time
 ex: rad/s
 Rotates  in 0.01 secs

e j  cos( )  j sin( )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 35

Back to Phasors:
COMPLEX AMPLITUDE
General Sinusoid

x(t )  A cos( t   )  { Ae j e j t }
Sinusoid = REAL PART of complex exp: z(t)=(Aej)ejt

x(t )  { Xe j t }  {z (t )}
Complex AMPLITUDE = X, which is a constant

X  Ae j when z (t )  Xe j t
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 36

18
Example: Inverse Phasor

 Determine the 60-Hz sinusoid whose


COMPLEX AMPLITUDE is:
X  3  j3
 Convert X to POLAR:

x(t )  {( 3  j 3)e j (120 t ) }


 { 12 e j / 3e j120 t }
 x(t )  12 cos(120 t   / 3)
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 37

Inverse Euler Relations


 Cosine is real part of exp, sine is imaginary part
 Real part: z  z *  {z}
2
e j  e  j
z  e j ,  {e j }   cos( )
2
 Imaginary part: z  z *  y  {z}
2j
e j  e  j
z  e j ,  {e j }   sin( )
2j

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 38

19
ROOTS OF UNITY
 We often have to solve zN=1
 How many solutions?

z N  r N e j N  1  e j 2  k
2 k
 r  1, N  2 k   
N
z  e j 2 k N , k  0,1, 2,  N  1
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 39

ROOTS OF UNITY for N=6

 Solutions to zN=1
are N equally
spaced vectors on
the unit circle!
 Note
N 1

e
k 0
j 2 k / N
0

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 40

20
WANT to ADD SINUSOIDS
 Main point to remember: Adding
sinusoids of common frequency results in
sinusoid with SAME frequency

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 41

PHASOR ADDITION RULE


N
x (t )   Ak cos(0 t   k )
k 1

 A cos(0 t   )
Get the new complex amplitude by complex addition
N

 k Ae j
A e
k 1
j k

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 42

21
Phasor Addition Proof
N N

 A cos(
k 1
k 0 t   k )   { Ak e j (0 t  k ) }
k 1

N 
  Ak e j k e j0 t 
 k 1 
 N  
   Ak e j k e j0 t 
 k 1  

  Ae j e j0 t  A cos(0 t   ) 
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 43

Example: Add Sinusoids

 ADD THESE 2 SINUSOIDS:


x1 (t )  cos(77 t   )
x2 (t )  3 cos(77 t  0.5 )
 COMPLEX (PHASOR) ADDITION:

1e  j  3e j 0.5
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 44

22
Add 20 Sinusoids (use MATLAB)
20
s(t)   k cos(120 (t  0.002k))
k1

 Each sinusoid  Complex Amp


20
S  Ae j
  k e j120  (0.002k )
k1
 MATLAB
kk=1:20;
SS = sum( sqrt(kk) .* exp(120i*pi*(-0.002)*kk) );
zprint( SS )

Aug 2016
A  6.949,   1.545
© 2003-2016, JH McClellan & RW Schafer 45

ADD SINUSOIDS EXAMPLE

x1 (t )
tm1

x2 ( t )
tm2

x3 (t )  x1 (t )  x2 (t )

tm3

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 46

23
DSP First, 2/e

CHAPTER 3 STARTS HERE


Lecture 5
Spectrum Representation

READING ASSIGNMENTS

 This Lecture:
 Chapter 3, Section 3-1
 Chapter 3, Section 3-3 (DSP-First 2/e)

 Other Reading:
 Appendix A: Complex Numbers

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 48

24
LECTURE OBJECTIVES

 Sinusoids with DIFFERENT Frequencies


 SYNTHESIZE by Adding Sinusoids
N
x (t )   Ak cos(2 f k t   k )
k 1
 SPECTRUM Representation
 Graphical Form shows DIFFERENT Freqs

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 49

FREQUENCY DIAGRAM
 Want to visualize relationship between
frequencies, amplitudes and phases
 Plot Complex Amplitude vs. Frequency
Complex amplitude
10
7e j / 3 7e  j / 3
4e  j / 2 4e j / 2

–250 –100 0 100 250


f (in Hz)
Spectral line
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 50

25
MOTIVATION

 Synthesize Complicated Signals


 Musical Notes
 Piano uses 3 strings for many notes
 Chords: play several notes simultaneously
 Human Speech
 Vowels have dominant frequencies
 Application: computer generated speech
 Can all signals be generated this way?
 Sum of sinusoids?

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 51

Fur Elise WAVEFORM

Beat
Notes

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 52

26
Speech Signal: BAT

 Nearly Periodic in Vowel Region


 Period is (Approximately) T = 0.0065 sec

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 53

Euler’s Formula Reversed


 Solve for cosine (or sine)
e j t  cos( t )  j sin( t )
e  j t  cos(  t )  j sin(  t )
e  j t  cos( t )  j sin( t )
e j t  e  j t  2 cos( t )

cos( t )  12 ( e j t  e  j t )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 54

27
INVERSE Euler’s Formula
 What is the “spectrum” representation for
a single sinusoid?
 Solve Euler’s formula for cosine (or sine)

cos( t )  12 (e j t  e  j t )

sin( t )  1
2j
( e j t  e  j t )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 55

SPECTRUM Interpretation
 Cosine = sum of 2 complex exponentials:

A cos(7t )  A e j 7t  A e j 7t
2 2
 One has a positive frequency
 The other has negative freq.
 Amplitude of each is half as big

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 56

28
GRAPHICAL SPECTRUM

A cos(7t  0.1)  A2 e j 0.1e j 7 t  A2 e  j 0.1e  j 7 t


A  j 0.1 A j 0.1
e e
2 2

-7 0 7 
Freq. in rad/s

AMPLITUDE, PHASE & FREQUENCY are labels


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 57

General form of sinusoid


spectrum

 General form:

A cos(t   )
 A2 e j e jt  A2 e  j e  jt
 Amplitudes are multiplied by ½
 Complex amplitudes are complex conjugates
 Called conjugate symmetry
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 58

29
REPRESENTATION of SINE
 Sine = sum of 2 complex exponentials:
A sin(7t )  2Aj e j 7 t  2Aj e  j 7 t
 12 Ae  j 0.5 e j 7t  12 Ae j 0.5 e  j 7t
1
j
 j  e j 0.5
 Positive freq. has phase = -0.5
 Negative freq. has phase = +0.5
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 59

GRAPHICAL Spectrum of sine


EXAMPLE of SINE (has Phase of –/2)

A sin(7t )  1
2
Ae  j 0.5 e j 7t  12 Ae j 0.5 e  j 7t

( 12 A)e j 0.5 ( 12 A)e  j 0.5

-7 0 7 

AMPLITUDE, PHASE & FREQUENCY are labels


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 60

30
LINE SPECTRUM ---> a labeled
bar graph vs. frequency
 All the spectrum components of x(t)
shown (sum of sinusoids):
10
7e j / 3
7e  j / 3
4e  j / 2 4e j / 2

–250 –100 0 100 250


f (in Hz)

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 61

Add Spectrum Components-2


10
7e j / 3
7e  j / 3
4e  j / 2 4e j / 2

–250 –100 0 100 250


f (in Hz)

x (t )  10 
7e  j / 3e j 2 (100)t  7e j / 3e  j 2 (100)t
4e j / 2e j 2 ( 250)t  4e  j / 2e  j 2 ( 250)t
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 62

31
Simplify Components

x (t )  10 
7e  j / 3e j 2 (100)t  7e j / 3e  j 2 (100)t
4e j / 2e j 2 ( 250)t  4e  j / 2e  j 2 ( 250)t
Use Euler’s Formula to get REAL sinusoids:

A cos( t   )  12 Ae j e j t  12 Ae  j e  j t
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 63

FINAL ANSWER

x (t )  10  14 cos(2 (100)t   / 3)
 8 cos(2 ( 250)t   / 2)
So, we get the general form:
N
x (t )  A0   Ak cos(2 f k t   k )
k 1
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 64

32
Example: Synthetic Vowel

 Sum of 5 Frequency Components

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 65

Example: Synthetic Vowel


 Sum of 5 Frequency Components

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 66

33
SPECTRUM of VOWEL
(Polar Format)

0.5Ak

k

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 67

Vowel Waveform
(sum of all 5 components)
One epoch or
one period
2

-1

-2

Note that the period is 10 ms, which equals 1/f0


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 68

34
Summary: GENERAL FORM
N
x(t)  A0   Ak cos(2 f k t   k )
k1
N
x(t)  X 0   Ak e j k e j 2  f k t 
k1 X k  Ak e j k
{z}  12 z  12 z  Frequency  f k
N
x(t)  X 0  12 X k e j 2  f k t  12 X ke j 2  f k t 
k1
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 69

DSP First 2/e

Next:
Operations on the Spectrum

35
LECTURE OBJECTIVES

 Operations on a time-domain signal x(t) have a


SIMPLE form in the frequency-domain

 SPECTRUM Representation has lines at:


( Ak ,  k , f k )
 Represents Sinusoid with DIFFERENT Frequencies
N
x (t )   Ak cos(2 f k t   k )
k 1

5/26/2016 © 2015-2016, JH McClellan & RW Schafer 71

General Spectrum of real x(t)

 2M + 1 spectrum components, a k  ak
*

M
x (t ) 
k  M
k a e
j 2 f k t

 At f  f k the complex amplitude is a


k

 usually, for real x(t) f0  0

5/26/2016 © 2015-2016, JH McClellan & RW Schafer 72

36
OPERATIONS on SPECTRUM

 Adding DC, or amplitude scaling


 Adding two (or more) signals
 Time-Shifting
 Multiply in frequency by complex exponential
 Differentiation of x(t)
 Multiply in frequency-domain by (j)
 Frequency Shifting
 Multiply in time-domain by sinusoid
5/26/2016 © 2015-2016, JH McClellan & RW Schafer 73

Scaling or Adding a constant

 Adding DC

x (t )  c   ak e j 2 f k t  a0e j 2 ( 0 ) t  ce j 2 ( 0 ) t
k 0
  
new DC is a0  c

 Scaling
M M
 x (t )   a e
k  M
k
j 2 f k t
  ( a )e
k  M
k
j 2 f k t

5/26/2016 © 2015-2016, JH McClellan & RW Schafer 74

37
Scaling and Adding a constant
2 x ( t )  6   2 a k e j 2  f k t  2 a0  6
k 0

new DC

5/26/2016 © 2015-2016, JH McClellan & RW Schafer 75

Adding Two Signals (1)

 Adding signals with same fundamental


M M M
x1 (t )  x2 (t )   a1k e j 2 fk t 
k  M
 a 2 k e j 2 f k t 
k  M
 (a
k  M
1k  a 2 k ) e j 2 f k t

x1 (t )

x2 ( t ) ?
5/26/2016 © 2015-2016, JH McClellan & RW Schafer 76

38
Adding Two Signals (2)

 Adding signals with some common frequencies

x1 (t )

x2 ( t )

x1 (t )  x2 (t )

5/26/2016 © 2015-2016, JH McClellan & RW Schafer 77

Time Shifting x(t)

 Time Shifting
M M
x (t   d )  a e
k  M
k
j 2 f k ( t  d )
  (a 
k  M
e   )e
k
 j 2 fk d j 2 f k t

bk
M
y (t )  b e
k  M
k
j 2 f k t

 Multiply all Spectrum complex amplitudes


by complex exponentials
5/26/2016 © 2015-2016, JH McClellan & RW Schafer 78

39
Differentiating x(t)

 Take derivative of the Signal x(t)


dx(t ) M M
  ak ( j 2 f k )e j 2 f k t
  ( j 2 f k ) ak e j 2 fk t
dt k  M k  M

bk
M
y (t )   be
k  M
k
j 2 f k t

 Multiply complex amplitudes by j=j2f

5/26/2016 © 2015-2016, JH McClellan & RW Schafer 79

Frequency Shifting x(t)

 Multiply x(t) by Complex Exponential/Sinusoid


Frequency Shifting
y (t )  Ae j e j 2 f c t x (t )
M
y (t )   Ae  e
k  M
j j 2 f c t
a k e j 2 f k t
M
  (a Ae  )e
k  M
k
j j 2 ( f k  f c ) t

 Spectrum components shifted: fk  fk  fc


5/26/2016 © 2015-2016, JH McClellan & RW Schafer 80

40
Frequency Shifting x(t)

x (t )

x ( t ) e j 2 ( 9 ) t
Shift up by 9 Hz

x (t ) sin( 2 (9)t )

5/26/2016 © 2015-2016, JH McClellan & RW Schafer 81

DSP First, 2/e

Next:
Periodic Signals, Harmonics
& Time-Varying Sinusoids
 Chapter 3, Sections 3-2 and 3-4
 Chapter 3, Sections 3-6 and 3-7

41
LECTURE OBJECTIVES
 Signals with HARMONIC Frequencies
 Add Sinusoids with fk = kf0
N
x (t )  A0   Ak cos( 2 kf 0t   k )
k 1

Second Topic: FREQUENCY can change vs. TIME


Introduce Spectrogram Visualization
(spectrogram.m) (plotspec.m)

Chirps: x (t )  cos( t 2 )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 83

SPECTRUM DIAGRAM

 Recall Complex Amplitude vs. Freq


1 X k 10 1 X k  ak
2 j / 3  j / 3 2
7e 7e
 j / 2
4e 4e j / 2
X k  Ak e j k
–250 –100 0 100 250
f (in Hz)

x (t )  10  14 cos(2 (100)t   / 3)
 8 cos(2 ( 250)t   / 2)
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 84

42
SPECTRUM for PERIODIC ?
 Nearly Periodic in the Vowel Region
 Period is (Approximately) T = 0.0065 sec

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 85

Harmonic Signal
Periodic signal: x(t )  x(t  T )
Can only have harmonic freqs : f k  k f 0
WHY ?
N
x (t )  A0   Ak cos(2 kf 0t   k )
k 1 f 0T  1
x (t ) is periodic if
cos(2 kf 0 (t  T )   k )  cos(2 kf 0t  2 kf 0T   k )

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 86

43
Define FUNDAMENTAL FREQ
N
x(t )  A0   Ak cos(2 kf 0t  k ) 1
k 1 f0 
T0
Main point:
for periodic signals, all spectral lines have
frequencies that are integer multiples of the
fundamental frequency.
All harmonics have fundamental period T0/k

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 87

Harmonic Spectrum (3 Freqs)

3rd
5th

What is the fundamental frequency? 10 Hz

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 88

44
EXAMPLE 2
 Here’s another spectrum:
10
7e j / 3 7e  j / 3
4e  j / 2 4e j / 2

–24 –10.4 0 10.4 24


f (in Hz)

What is the fundamental frequency?

(0.1)GCD(104,240) = (0.1)(8)=0.8 Hz
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 89

NON-HARMONIC
FREQUENCIES, NON-PERIODIC
SPECIAL RELATIONSHIP
to get a PERIODIC SIGNAL

NON-PERIODIC SIGNAL

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 90

45
Harmonic Signal (3 Freqs)
T=0.1

PERIODIC
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 91

NON-Harmonic Signal

NOT
Aug 2016 © 2003-2016, JH McClellan & RW Schafer PERIODIC
92

46
FREQUENCY ANALYSIS
 Now, a much HARDER problem
 Given a recording of a song, have the
computer write the music

 Can a machine extract frequencies?


 Yes, if we COMPUTE the spectrum for x(t)
 During short intervals

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 93

Time-Varying
FREQUENCIES Diagram
A-440
Frequency is the vertical axis

Time is the horizontal axis


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 94

47
SPECTROGRAM

 SPECTROGRAM Tool
 MATLAB function is spectrogram.m
 Our toolbox has plotspec.m & spectgr.m
 ANALYSIS program
 Takes x(t) as input
 Produces spectrum values Xk
 Breaks x(t) into SHORT TIME SEGMENTS
 Then uses the FFT (Fast Fourier Transform)

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 95

SPECTROGRAM EXAMPLE
 Two Constant Frequencies: Beats

cos(2 (672)t )  cos(2 (648)t )


 2 cos(2 (12)t ) cos(2 (660)t )

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 96

48
STEPPED FREQUENCIES
 C-major SCALE: successive sinusoids
 Frequency is constant for each note

IDEAL

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 97

SPECTROGRAM of C-Scale
Sinusoids ONLY

From SPECTROGRAM
ANALYSIS PROGRAM

ARTIFACTS at Transitions

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 98

49
Spectrogram of LAB SONG

Sinusoids ONLY
Analysis Frame = 40ms
ARTIFACTS at Transitions

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 99

Overlapping Sections in
Spectrograms (useful in Labs)
 50% overlap is common
 Consider edge effects when analyzing a short sinusoid

SECTION
LOCATIONS

MIDDLE of SECTION
is REFERENCE TIME

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 100

50
Spectrogram of BAT (plotspec)

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 101

Time-Varying Frequency
 Frequency can change vs. time
 Continuously, not stepped
 FREQUENCY MODULATION (FM)

x (t )  cos(2 f c t  v (t ))
VOICE
 CHIRP SIGNALS
 Linear Frequency Modulation (LFM)

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 102

51
New Signal: Linear FM

 Called Chirp Signals (LFM)


QUADRATIC
 Quadratic phase

x (t )  A cos( t 2  2 f 0 t   )
 Freq will change LINEARLY vs. time
 Example of Frequency Modulation (FM)
 Define “instantaneous frequency”

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 103

INSTANTANEOUS FREQ
 Definition is NOT the trivial choice (t)/t
x (t )  A cos( (t ))
Derivative
 i (t )  dt
d  (t )
of the “Angle”

 For Sinusoid:
x (t )  A cos(2 f 0t   )
 (t )  2 f 0t   Makes sense

 i ( t )  d  (t )
dt
 2 f 0
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 104

52
INSTANTANEOUS FREQ
of the Chirp
 Chirp Signals have Quadratic phase
 Freq will change LINEARLY vs. time

x (t )  A cos( t 2   t   )
  (t )   t 2   t  
 i ( t )  d  (t )
dt
 2 t  
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 105

CHIRP SPECTROGRAM

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 106

53
CHIRP WAVEFORM

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 107

OTHER CHIRPS

 (t) can be anything:

x (t )  A cos( cos(  t )   )
 i (t )  dtd  (t )   sin(  t )
 (t) could be speech or music:
 FM radio broadcast

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 108

54
SINE-WAVE FREQUENCY
MODULATION (FM)

Look at CD-ROM Demos in Ch 3

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 109

Problem Solving Skills

 Math Formula  Plot & Sketches


 Sum of Cosines  S(t) versus t
 Amp, Freq, Phase  Spectrum

 Recorded Signals  MATLAB


 Speech  Numerical
 Music  Computation
 No simple formula  Plotting list of
numbers

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 110

55

You might also like