E85.2607: Lecture 1 – Introduction 1 Administrivia 2 DSP review 3 Fun with Matlab E85.2607: Lecture 1 – Introduction 2010-01-21 1 / 24
E85.2607: Lecture 1 – Introduction
1 Administrivia
2 DSP review
3 Fun with Matlab
E85.2607: Lecture 1 – Introduction 2010-01-21 1 / 24
Course overview
Advanced Digital Signal Theory
Design, analysis, and implementation of audio effects and synthesizers
EQ, reverb, chorus, phase vocoder, sinusoidal modeling, FM synthesis, ...
Emphasis on practical implementation, building complete systems.
Course web page: http://www.ee.columbia.edu/~ronw/adst
E85.2607: Lecture 1 – Introduction 2010-01-21 2 / 24
http://www.ee.columbia.edu/~ronw/adst
whoami
PhD, Electrical Engineering, Columbia University
Research interests: Source separation, speech recognition, musicinformation retrieval
http://www.ee.columbia.edu/~ronw
E85.2607: Lecture 1 – Introduction 2010-01-21 3 / 24
http://www.ee.columbia.edu/~ronw
Sound familiar?
Periodic and aperiodic signals
Discrete Fourier Transform
Convolution, filtering
Linear time-invariant systems
Impulse response
Frequency response
z-transform
E85.2607: Lecture 1 – Introduction 2010-01-21 4 / 24
Digital signals
Continuous time Discrete time
Dis
cret
eva
lue
Con
tinuo
usva
lue
Discrete-time signal sequence of samples
e.g. x [n ] = [0,−2.3,−1.3, 20, 4.2, ... ]Digital signal discrete-time signal that has been quantized
Discrete on both axes: samples can only take on a limited set ofvalues (quantization levels)Quantization introduces noise
E85.2607: Lecture 1 – Introduction 2010-01-21 5 / 24
Sampling
DAFXADC DACx(n) y(n) y(t)x(t)
f =1__Ts
f =1__Ts
0.5
0 500-0.05
0
0.05x(t)
t in !sec "0 10 20
-0.05
0
0.05
n "
x(n)
0 10 20-0.05
0
0.05
n "
y(n)
0 500-0.05
0
0.05
t in !sec "
y(t)
T
t = n1
fs
t time in seconds (real number)n time in samples (integer)
fs sampling rate(e.g. 44100 samplessecond
)E85.2607: Lecture 1 – Introduction 2010-01-21 6 / 24
Important signals: impulse
−4 −2 0 2 4 6 8 10n
0.0
0.2
0.4
0.6
0.8
1.0
δ[n] =
{1, n = 0,0, n 6= 0
Think of all discrete time signals as a sequence of scaled and time-shiftedimpulses.
x [n ] = [0,−2.3,−1.3, 20, 4.2, ... ]= 0 δ[n ]− 2.3 δ[n − 1]− 1.3 δ[n − 2] + 20 δ[n − 3] + 4.2 δ[n − 4] + ...
E85.2607: Lecture 1 – Introduction 2010-01-21 7 / 24
Important signals: sinusoid
0 5 10 15n
−1.0
−0.50.0
0.5
1.0x[n] = sin(2πfn)
sin(2πfn + φ), frequency = f cyclessample , phase = φ
Period: N = 1f samples
But what will it sound like?
Convert from samples: f cyclessample × 1fssamplessecond
How many samples in one period of a 440 Hz tone sampled at 44.1 kHz?
E85.2607: Lecture 1 – Introduction 2010-01-21 8 / 24
Important signals: sinusoid
0 5 10 15n
−1.0
−0.50.0
0.5
1.0x[n] = sin(2πfn)
sin(2πfn + φ), frequency = f cyclessample , phase = φ
Period: N = 1f samples
But what will it sound like?
Convert from samples: f cyclessample × 1fssamplessecond
How many samples in one period of a 440 Hz tone sampled at 44.1 kHz?
E85.2607: Lecture 1 – Introduction 2010-01-21 8 / 24
Discrete Fourier Transform
Decompose any periodic signal into sum of re-scaled sinusoids
Inverse DFT
x [n ] =1
N
N−1∑n=0
X [k ] e j2πnk/N k = 0, . . . ,N − 1
Forward DFT
X [k ] =N−1∑n=0
x [n ] e−j2πnk/N
Note that X [k ] are complex: X [k ] = XR [k ] + jXI [k ]
E85.2607: Lecture 1 – Introduction 2010-01-21 9 / 24
Magnitude and Phase spectra
X [k ] = |X [k ] | e j∠X [k ]
Magnitude: amount of energy ateach frequency
|X [k ]| =√
X 2R [k ] + X2I [k ]
Phase: delay at each frequency
∠X [k ] = arctan XI [k ]XR [k ]
−1.0−0.5
0.0
0.5
1.0
x[n] = cos(2πfn)
0
2
4
6
8
10|X[k]|
0 2 4 6 8 10 12 14 16−4−3−2−1
01234
∠X[k]
E85.2607: Lecture 1 – Introduction 2010-01-21 10 / 24
DFT symmetry and aliasing
24000 28000 32000 36000 40000-80
-60
-40
-20
0
X(f
)in
dB
f in Hz !
0 4000 8000 12000 16000 20000 44000 48000 52000 56000 60000
24000 28000 32000 36000 40000-80
-60
-40
-20
0
X(f
)in
dB
Spectrum of analog signal
!
0 4000 8000 12000 16000 20000 44000 48000 52000 56000 60000
f in Hz
Spectrum of digital signalSampling frequency f =40000 kHzS
The spectrum of a discrete time signal is periodic with period fs
The spectrum of a real valued signal is symmetric around fs/2
Any energy at frequencies greater than fs/2 will wrap around
E85.2607: Lecture 1 – Introduction 2010-01-21 11 / 24
Short-time Fourier Transform
What if frequency content varies withtime?
Break signal up into short (optionallyoverlapping) segments
Multiply by window function
Take DFT of each segment
E85.2607: Lecture 1 – Introduction 2010-01-21 12 / 24
STFT example
0 1 2 3 4 5 6 7 8Time (sec)
0
2
4
6
8
10
Freq
uenc
y(k
Hz)
−30−24−18−12−60
6
12
18
24
30
Pow
er(d
B)
E85.2607: Lecture 1 – Introduction 2010-01-21 13 / 24
http://www.ee.columbia.edu/~ronw/adst/lectures/matlab/wavs/lib-excerpt.wav
Linear time-invariant systems
Process input signal using delays, multiplications, additions
Describe using a difference equation, e.g.
y [n ] = b0 x [n ] + b1 x [n − 1]
Can also have feedback, e.g.
y [n ] = b0 x [n ] + b1 x [n − 1] + a1 y [n − 1] + a2 y [n − 2]
E85.2607: Lecture 1 – Introduction 2010-01-21 14 / 24
LTI systems – Block diagram
E85.2607: Lecture 1 – Introduction 2010-01-21 15 / 24
LTI systems – Properties
E85.2607: Lecture 1 – Introduction 2010-01-21 16 / 24
Impulse response and convolution
h(n)
y(n) = h(n)
-1 0 1 2 3 4n
x(n) = (n)! y(n) = h(n)
x(n) = (n)!
-1 0 1 2 3n
1
Characterize LTI system in time-domain by its impulse response h[n ]An LTI system is just another signal
Given input signal x [n ], output is convolution with h[n ]
Convolution
y [n ] = x [n ] ∗ h[n ] =∞∑
k=−∞x [k ] h[n − k ]
But how do we compute the impulse response from a differenceequation?
E85.2607: Lecture 1 – Introduction 2010-01-21 17 / 24
z-transform
z-transform
X (z) =∞∑
n=−∞x [n ] z−n
Maps discrete-time signal to a continuous function of a complexvariable
Incredibly useful for analyzing LTI systems
Turns difference equations into polynomials:
x [n −m ] z←→ z−M X (z)
Convolution becomes multiplication:
x [n ] ∗ h[n ] z←→ X (z) H(z)
If z = e jΩ, get discrete-time Fourier transform (DTFT)
E85.2607: Lecture 1 – Introduction 2010-01-21 18 / 24
Transfer function
Transfer function H(z) is the z-transform of the impulse response
Can read off z-transform from difference equation
y [n ] = b0 x [n ] + b1 x [n − 1] + a1 y [n − 1] + a2 y [n − 2]
z←→ Y (z) = (bo + b1 z−1) X (z) + (a1 z−1 + a2 z−2) Y (z)
H(z) =Y (z)
X (z)=
bo + b1 z−1
1− a1 z−1 − a2 z−2
But why? δ[n ]z←→ 1
Compute impulse response analytically by finding inverse z-transform ofH(z) (lots of algebra)
E85.2607: Lecture 1 – Introduction 2010-01-21 19 / 24
Transfer function
Transfer function H(z) is the z-transform of the impulse response
Can read off z-transform from difference equation
y [n ] = b0 x [n ] + b1 x [n − 1] + a1 y [n − 1] + a2 y [n − 2]z←→ Y (z) = (bo + b1 z−1) X (z) + (a1 z−1 + a2 z−2) Y (z)
H(z) =Y (z)
X (z)=
bo + b1 z−1
1− a1 z−1 − a2 z−2
But why? δ[n ]z←→ 1
Compute impulse response analytically by finding inverse z-transform ofH(z) (lots of algebra)
E85.2607: Lecture 1 – Introduction 2010-01-21 19 / 24
Transfer function
Transfer function H(z) is the z-transform of the impulse response
Can read off z-transform from difference equation
y [n ] = b0 x [n ] + b1 x [n − 1] + a1 y [n − 1] + a2 y [n − 2]z←→ Y (z) = (bo + b1 z−1) X (z) + (a1 z−1 + a2 z−2) Y (z)
H(z) =Y (z)
X (z)=
bo + b1 z−1
1− a1 z−1 − a2 z−2
But why? δ[n ]z←→ 1
Compute impulse response analytically by finding inverse z-transform ofH(z) (lots of algebra)
E85.2607: Lecture 1 – Introduction 2010-01-21 19 / 24
Transfer function
Transfer function H(z) is the z-transform of the impulse response
Can read off z-transform from difference equation
y [n ] = b0 x [n ] + b1 x [n − 1] + a1 y [n − 1] + a2 y [n − 2]z←→ Y (z) = (bo + b1 z−1) X (z) + (a1 z−1 + a2 z−2) Y (z)
H(z) =Y (z)
X (z)=
bo + b1 z−1
1− a1 z−1 − a2 z−2
But why? δ[n ]z←→ 1
Compute impulse response analytically by finding inverse z-transform ofH(z) (lots of algebra)
E85.2607: Lecture 1 – Introduction 2010-01-21 19 / 24
Frequency response
0 5 10 15 200.00.20.40.60.81.01.2
|H(f
)|
Magnitude Response
0 5 10 15 20
Frequency (kHz)
−4−3−2−1
01234
∠H
(f)
Phase Response
Often more intuitive to analyze system in the frequency-domain
H(e jΩ) DTFT of impulse response
Slice of z-transform corresponding to the unit circleDFT (discrete freq) is just sampled DTFT (continuous freq)
E85.2607: Lecture 1 – Introduction 2010-01-21 20 / 24
Poles and zeros
−2 −1 0 1 2Real
−1.0−0.5
0.0
0.5
1.0
Imag
inar
y
Zeros: roots of numerator of H(z)
Correspond to valleys in frequency response
Poles: roots of denominator of H(z)
Correspond to peaks in frequency response
System is unstable if it has poles outside of (or on) the unit circleImpulse response goes to infinity
E85.2607: Lecture 1 – Introduction 2010-01-21 21 / 24
FIR and IIR filters
Finite Impulse Response
No feedback ⇒ all zeroes ⇒ always stable∗∗ if coefficients are finiteEasy to design by drawing frequency response by hand, then usinginverse DFT to get impulse responseOften needs a long impulse response ⇒ expensive to implement
Infinite Impulse Response
Feedback ⇒ has poles ⇒ can be unstableCan implement complex filters using fewer delays than FIRBut harder to design
E85.2607: Lecture 1 – Introduction 2010-01-21 22 / 24
Fun with Matlab
Signal generation linspace, rand, sinI/O wavread, wavwrite, soundscPlotting plot, imagescTransforms fft, ifftFiltering conv, filterAnalyzing filters freqz, zplane, iztrans
E85.2607: Lecture 1 – Introduction 2010-01-21 23 / 24
Reading
Review your DST notes
Skim Introduction to Digital Filters
Linear Time-Invariant FiltersTransfer Function AnalysisFrequency Response Analysis
DAFX, Chapter 1 (if you have it)
E85.2607: Lecture 1 – Introduction 2010-01-21 24 / 24
https://ccrma.stanford.edu/~jos/filters/Linear_Time_Invariant_Digital_Filters.htmlhttps://ccrma.stanford.edu/~jos/filters/Transfer_Function_Analysis.htmlhttps://ccrma.stanford.edu/~jos/filters/Frequency_Response_Analysis.html
AdministriviaDSP reviewFun with Matlab