Professional Documents
Culture Documents
LECTURE #1 Sinusoids,
Quick, Brief Treatment of
DSP First Approach
1
READING ASSIGNMENTS
COURSE OBJECTIVE
2
WHY USE DSP ?
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”
3
LECTURE OBJECTIVES
(go quickly)
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
5
Speech Signal: BAT
6
STORING DIGITAL SOUND
A cos(2 ( 440)t )
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
8
PLOT the SINUSOID
5 cos(0.3 t 1.2 )
Use T=20/3 and the peak location at t=-4
203
Common Values
sin(k) = 0
cos(0) = 1
cos(2k) = 1 and cos((2k+1) ) = -1
cos((k+0.5) ) = 0
9
LECTURE CONTINUED
OBJECTIVES
Derive Sinusoid Formula from a plot
TIME-SHIFTED SINUSOID
x(t ) 5 cos(0.3 t ) One peak at t = 0
10
PHASE TIME-SHIFT
A cos( (t tm )) A cos( t )
and we obtain: tm
or,
tm
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 21
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)
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
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 )
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)
a short slice
15
QUICK REVIEW: Phasors, etc.
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
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 )
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)ejt
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
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
Solutions to zN=1
are N equally
spaced vectors on
the unit circle!
Note
N 1
e
k 0
j 2 k / N
0
20
WANT to ADD SINUSOIDS
Main point to remember: Adding
sinusoids of common frequency results in
sinusoid with SAME frequency
A cos(0 t )
Get the new complex amplitude by complex addition
N
k Ae j
A e
k 1
j k
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 j0 t
k 1
N
Ak e j k e j0 t
k 1
Ae j e j0 t A cos(0 t )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 43
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))
k1
Aug 2016
A 6.949, 1.545
© 2003-2016, JH McClellan & RW Schafer 45
x1 (t )
tm1
x2 ( t )
tm2
x3 (t ) x1 (t ) x2 (t )
tm3
23
DSP First, 2/e
READING ASSIGNMENTS
This Lecture:
Chapter 3, Section 3-1
Chapter 3, Section 3-3 (DSP-First 2/e)
Other Reading:
Appendix A: Complex Numbers
24
LECTURE OBJECTIVES
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
25
MOTIVATION
Beat
Notes
26
Speech Signal: BAT
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
28
GRAPHICAL SPECTRUM
-7 0 7
Freq. in rad/s
General form:
A cos(t )
A2 e j e jt A2 e j e jt
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
A sin(7t ) 1
2
Ae j 0.5 e j 7t 12 Ae j 0.5 e j 7t
-7 0 7
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
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
33
SPECTRUM of VOWEL
(Polar Format)
0.5Ak
k
Vowel Waveform
(sum of all 5 components)
One epoch or
one period
2
-1
-2
34
Summary: GENERAL FORM
N
x(t) A0 Ak cos(2 f k t k )
k1
N
x(t) X 0 Ak e j k e j 2 f k t
k1 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 ke j 2 f k t
k1
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 69
Next:
Operations on the Spectrum
35
LECTURE OBJECTIVES
2M + 1 spectrum components, a k ak
*
M
x (t )
k M
k a e
j 2 f k t
36
OPERATIONS on SPECTRUM
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
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
x1 (t )
x2 ( t ) ?
5/26/2016 © 2015-2016, JH McClellan & RW Schafer 76
38
Adding Two Signals (2)
x1 (t )
x2 ( t )
x1 (t ) x2 (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
39
Differentiating x(t)
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 )
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
Chirps: x (t ) cos( t 2 )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 83
SPECTRUM DIAGRAM
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
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 )
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
3rd
5th
44
EXAMPLE 2
Here’s another spectrum:
10
7e j / 3 7e j / 3
4e j / 2 4e j / 2
(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
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
Time-Varying
FREQUENCIES Diagram
A-440
Frequency is the vertical axis
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)
SPECTROGRAM EXAMPLE
Two Constant Frequencies: Beats
48
STEPPED FREQUENCIES
C-major SCALE: successive sinusoids
Frequency is constant for each note
IDEAL
SPECTROGRAM of C-Scale
Sinusoids ONLY
From SPECTROGRAM
ANALYSIS PROGRAM
ARTIFACTS at Transitions
49
Spectrogram of LAB SONG
Sinusoids ONLY
Analysis Frame = 40ms
ARTIFACTS at Transitions
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
50
Spectrogram of BAT (plotspec)
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)
51
New Signal: Linear FM
x (t ) A cos( t 2 2 f 0 t )
Freq will change LINEARLY vs. time
Example of Frequency Modulation (FM)
Define “instantaneous frequency”
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
53
CHIRP WAVEFORM
OTHER CHIRPS
x (t ) A cos( cos( t ) )
i (t ) dtd (t ) sin( t )
(t) could be speech or music:
FM radio broadcast
54
SINE-WAVE FREQUENCY
MODULATION (FM)
55