Top Banner
E85.2607: Lecture 1 – Introduction 1 Administrivia 2 DSP review 3 Fun with Matlab E85.2607: Lecture 1 – Introduction 2010-01-21 1 / 24
28

E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

May 31, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

E85.2607: Lecture 1 – Introduction

1 Administrivia

2 DSP review

3 Fun with Matlab

E85.2607: Lecture 1 – Introduction 2010-01-21 1 / 24

Page 2: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 3: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 4: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 5: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 6: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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 samples

second

)E85.2607: Lecture 1 – Introduction 2010-01-21 6 / 24

Page 7: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 8: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

Important signals: sinusoid

0 5 10 15n

−1.0

−0.5

0.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 × 1

fs

samplessecond

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

Page 9: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

Important signals: sinusoid

0 5 10 15n

−1.0

−0.5

0.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 × 1

fs

samplessecond

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

Page 10: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 11: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

Magnitude and Phase spectra

X [k ] = |X [k ] | e j∠X [k ]

Magnitude: amount of energy ateach frequency

|X [k ]| =√

X 2R [k ] + X 2

I [k ]

Phase: delay at each frequency

∠X [k ] = arctanXI [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

Page 12: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 13: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 14: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

−6

0

6

12

18

24

30

Pow

er(d

B)

E85.2607: Lecture 1 – Introduction 2010-01-21 13 / 24

Page 15: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 16: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

LTI systems – Block diagram

E85.2607: Lecture 1 – Introduction 2010-01-21 15 / 24

Page 17: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

LTI systems – Properties

E85.2607: Lecture 1 – Introduction 2010-01-21 16 / 24

Page 18: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 19: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 20: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 21: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 22: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 23: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 24: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 25: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

Poles and zeros

−2 −1 0 1 2

Real

−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 circle

Impulse response goes to infinity

E85.2607: Lecture 1 – Introduction 2010-01-21 21 / 24

Page 26: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

FIR and IIR filters

Finite Impulse Response

No feedback ⇒ all zeroes ⇒ always stable∗

∗ if coefficients are finite

Easy 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

Page 27: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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

Page 28: E85.2607: Lecture 1 -- Introductionronw/adst-spring2010/lectures/lecture… · E85.2607: Lecture 1 { Introduction 2010-01-21 22 / 24. Fun with Matlab Signal generation linspace, rand,

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