lecture 3 - filtering
TRANSCRIPT
![Page 1: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/1.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Paris Smaragdis [email protected]
paris.cs.illinois.edu
CS 498PS – Audio Computing Lab
Filtering
![Page 2: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/2.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Overview
• Filters! • What are they? • How do we make them? • How do we apply them? • When do we use them?
• Common uses of filters • Source/filter models • Subtractive synthesis • Room simulation
2
![Page 3: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/3.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Convolution
• Operation between two time series
• Formal definition:
• Commutative:
3
z= y∗ xz(t)= y(0)⋅x(t)+ y(1)⋅x(t−1)+!z(t)= y(i)⋅x(t− i)
i∑
z= y∗ x= x∗ y
![Page 4: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/4.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Intuitive explanation
• For each sample of y shift x to that sample’s position, scale it by y’s value, and add to output • Note that this results in a longer output than input
• Output length is length( x) + length( y) – 1
4
x 1 2 3
y 1 0 0 2 0 3 0 0
y ✻ x 1 2 3 2 4 9 6 9 0 0
![Page 5: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/5.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Some examples
5
![Page 6: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/6.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Convolution ⟶ FIR Filters
• When convolving you apply an FIR filter
• Finite Impulse Response • They have a “finite” effect in time
• i.e. won’t echo infinitely
• “Passive” filters • They remove energy, but cannot add any
• As a result they are very stable
6
![Page 7: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/7.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Filter characteristics
• Passband & stopband • Passband: Frequency range where there is no (big) suppression • Stopband: Frequency range where there is suppression
• Transition band • Frequency range in-between passband and stopband
• Cutoff frequency • Point of 3dB down from passband in the transition band
• Ripples • Deviations from desired levels
7
![Page 8: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/8.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Filter frequency response
8
Passband Stopband
Transition band
Passband ripples
Stopband ripplesCutoff
![Page 9: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/9.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Filter types by response
• Four main types depending on their passband • Can serve as building blocks of other filters
• Arbitrary filter responses • Customized to serve a specific task
• E.g. denoising, dehumming, dehissing, etc.
9
![Page 10: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/10.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Lowpass filters
• Pass only the low frequencies • Main parameter: Cutoff frequency • Used to remove high frequency elements (hiss, noise, etc)
10
![Page 11: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/11.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Example
11
📻 📻
![Page 12: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/12.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Highpass filters
• Lets only high frequencies pass • Specified by cutoff frequency again • Useful for removing low frequency things (rumbling, hum, etc).
12
![Page 13: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/13.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Example
13
📻
![Page 14: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/14.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Bandpass filters
• Pass a contiguous range of frequencies • Two parameters: center frequency and bandwidth
• Or the two bounding frequencies
14
Center frequency
Bandwidth
Lower frequency
Upper frequency
![Page 15: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/15.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Example
15
📻
![Page 16: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/16.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Bandreject (or bandstop) filters
• Suppress a contiguous set of frequencies • The opposite of a bandpass filter
• Very useful for removing things (e.g. 60Hz hum)
16
Center frequency
Bandwidth
Lower frequency
Upper frequency
![Page 17: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/17.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Example
17
📻
![Page 18: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/18.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Shelving filters
• Typically lowpass or highness • Equally suppress all frequencies in stopband
18
Shelving – flat stopband
Non-shelving – non-flat stopband
![Page 19: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/19.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Arbitrary responses
• More complex cases • Often used to resolve specific issues (more later)
19
![Page 20: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/20.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
So what do we convolve with?
• FIR filters are time series too • Usually too short to listen to
• Filter design • How do we get these filtering time series?
20
📻 📻 📻 📻 📻 📻Lowpass 0.5 Lowpass 0.2 Lowpass 0.7 Highpass 0.5 Highpass 0.2 Highpass 0.7
![Page 21: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/21.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Two views of a filter
21
Tim
e dom
ain
Freq
uenc
y do
mai
n
![Page 22: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/22.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Frequency response
• Taking the DFT of the filter gives us its response:
• Why is this useful? • If we have a desired response we can get the filter coefficients!
• By using the inverse DFT
22
X= DFT x( )⇒ X[k]= x[n]e− j2πnk/Nn=0
N−1
∑
![Page 23: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/23.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Designing a lowpass filter
• The ideal response is a step function
• The inverse DFT of the step function is the sinc function • You can find that analytically
23
X[k]= 1, if k<ω0, otherwise
⎧⎨⎪⎪
⎩⎪⎪
x[n]= IDFT X( )⇒ x[n]=ω sin πnω( )πnω
= ω sinc nω( )
ω
![Page 24: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/24.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
How does that look?
• If we generate the sinc it looks like a lowpass filter!
24
Hey, that’s not a step function!
![Page 25: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/25.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Some tradeoffs
• The longer the filter the better the response
25
Hey, what’s with the ripples?
![Page 26: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/26.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
One more thing to do …
• Remember why this is bad?
• We need to taper the sinc to smooth its spectrum • Same thing that we did with the spectrogram • Tradeoff: Dampens the ripples, but widens the filter
26
![Page 27: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/27.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Windowing the filter
• Results in a more palatable response
27
Slower transition, but smaller ripples
![Page 28: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/28.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Designing a highpass filter
• Subtract a lowpass from the input • Highpassed = input – lowpass( input)
28
x[n]=1−ω sinc nω( ), if n= 0−ω sinc nω( ), if n≠ 0
⎧
⎨⎪⎪⎪
⎩⎪⎪⎪
![Page 29: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/29.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Designing a bandpass filter
• To get a bandpass the coefficients are:
29
x[n]= 2cos πnωc( )ωb sinc ωbn( )
![Page 30: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/30.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Designing a bandreject filter
• Remove bandpassed signal from input • Just like with the highpass filter design
30
x[n]=1−2cos πnωc( )ωb sinc ωbn( ), if n= 0−2cos πnωc( )ωb sinc ωbn( ), if n≠ 0
⎧
⎨⎪⎪⎪
⎩⎪⎪⎪
![Page 31: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/31.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
• Take desired response, IDFT it, window it
General filter design: The window method
31
a)
b) c)
d)
![Page 32: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/32.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
And there’s much more
• Frequency sampling method • Define frequency points and their response
• Optimization methods • E.g. Parks-McClellan, linear programming, etc. • Specify constraints and get optimal filter via optimizer
• Remember there will always be tradeoffs
• Look into scipy.signal, lots of filter things to see
32
![Page 33: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/33.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
IIR filters
• Infinite Impulse Response • They don’t get applied with plain convolution • Use feedback to produce infinitely long effects
• Can be powerful but also numerically unstable
• Implemented using:
33
y[n]= 1ao
bix[n− i]+ ai y[n−1]i=0
N
∑i=0
M
∑⎡
⎣⎢⎢
⎤
⎦⎥⎥
FIR coefficients bi convolved with past inputs
Additional coefficients ai applied on past outputs
![Page 34: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/34.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Butterworth filters
• My favorite IIR filters for audio • Maximally flat passband • Gradual stopband, steeper with higher orders
34
![Page 35: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/35.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Chebyshev Type I
• Flat stopband, ripples in passband • User specifies cutoff and allowable ripples in passband
• Tradeoff: Larger ripples ⟶ steeper transition band
35
![Page 36: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/36.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Chebyshev Type II
• Flat passband, ripples in stopband • Similar to Chebyshev Type I, but flip pass/stopband
• Larger ripples allow for steeper transition band
36
![Page 37: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/37.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Elliptic filters
• Specify both passband and stopband ripples • Parameters: Cutoff, passband rippling, stopband rippling • More suppressed ripples ⟶ less steep transition band
37
![Page 38: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/38.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Allpass filters
• No changes in the magnitude • But can produce a phase delay • Useful for delay effects (more later)
38
![Page 39: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/39.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
The Q-factor
• Indicates the amount of resonance in a filter • Ratio of center frequency to bandwidth
• Higher Q means a sharper filter peak • Widely used in rock and dance music
• Wah-wah guitars, filtered synth pads
39
📻
📻Filters with increasing Q
High-Q changing cutoff
![Page 40: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/40.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
The source-filter model
• Very popular sound generation model • Used in speech, music, acoustics, …
• Source: • A frequency-rich sound
• Filter: • A filter that shapes the source as needed
40
![Page 41: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/41.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Vocal tract model
• Source • Vocal tract waveform
• Filter • Resonances of vocal cavities
• Uses • Speech synthesis • Singing synthesis • Demo!
41Go to https://dood.al/pinktrombone/ for more speech synthesis fun
![Page 42: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/42.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Modeling of musical instruments
• Source • Excitation of a string/membrane/airflow/…
• Filter • The resonances of the instrument body
• Piano/violin/guitar body, etc.
• Popular in physical modeling of music
42
![Page 43: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/43.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Subtractive synthesis
• Analog synthesizers (and modern emulators) • Source: spectrally rich waveforms (square, sawtooth, noise) • Filter: Sweeping high-Q filters
43
📻
📻
![Page 44: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/44.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Room simulations
• Using convolutions for delays • When spaced far apart filter coefficients sound like echoes
• Modeling room reflections • We can model room reverberations • Convolve with delaying noise • Convolve with actual room response
• Examples:
44
📻 📻📻
📻📻
📻📻
InputDecaying noise Masonic lodge Musikvereinsaal
📻📻
Large hall
![Page 45: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/45.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Equalizers
• Banks of filters that cover entire frequency range
45
![Page 46: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/46.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Graphical EQs
• Each slider is a narrow bandpass filter
46
![Page 47: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/47.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Designing a graphical EQ
• Lowpass shelving filter for first band • Highpass shelving filter for last band • Bandpass filters for all others
• Make sure they collectively sum to 1
47
![Page 48: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/48.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Parametric EQs
• Limited number of configurable filters • Set frequency peak and width
• Allows for precise filter tuning • Useful for solving resonance problems
• e.g. mic feedback
48
![Page 49: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/49.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Designing a parametric EQ
• Easy! • Lowpass filter / bandpass filter(s) / highpass filter • Have adjustable parameters for each
• Cutoffs, Q, filter type, etc.
• By tuning the filters you can approximate arbitrary frequency responses
49
![Page 50: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/50.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Why do we need EQs?
• Enthusiasts • Change music characteristics (e.g. boomy bass) • To make up for deficiencies in speakers
• Sound engineers • Top compensate for poor acoustics or feedback • To enhance the quality of recorded sound
• Hearing devices • To compensate for hearing loss in various frequency bands
50
![Page 51: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/51.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Fast convolution
• Convolution is very slow! • Lots of multiplications
• It can be sped up significantly using the FFT • Perform convolution in the frequency domain • Complexity drops to 2 N log2 N
• But is this efficient as shown above?
51
z[t]= y[i]⋅x[t−1]i∑
z= x∗ y⇔ DFT z( )= DFT x( )⊙DFT y( )
![Page 52: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/52.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Overlap-add fast convolution
• Similar to spectrograms • Step 1: Make frames
• Zero pad! • Do not window
• Step 2: Convolve frames using FFTs • i.e. multiply complex spectra
• Elementwise multiplication • Step 3: Invert back to time
• Use overlap and add!
52
![Page 53: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/53.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
What’s happening here?
53
![Page 54: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/54.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Cross synthesis
• Fun with crossing spectra of different sounds • Source: A sound with rich spectral content • Filter: The spectrum of a duller sound • Multiply spectra in the frequency domain • Invert back to time domain
• Often referred to as the vocoder • Demo!
54
![Page 55: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/55.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Taking shortcuts
• Sometimes it is easier to apply custom filters by directly manipulating spectrograms • E.g. remove unwanted frequencies
• Don’t do that for simple filters • It isn’t technically correct and can produce artifacts • But it can also save you time by making things simpler
55
![Page 56: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/56.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Recap
• Overview of filtering for sound • Types of filters • Filter design • Filter parameters
• Common filter uses • Removal of interference • Equalizers • Source/filter models
56
![Page 57: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/57.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Reference material
• Intro to digital filters with audio applications • https://ccrma.stanford.edu/~jos/fp/
• If you are brave read all of it! • But we only need this as reference for now
57
![Page 58: Lecture 3 - Filtering](https://reader033.vdocuments.net/reader033/viewer/2022042219/6259f399a0b9491c7612933a/html5/thumbnails/58.jpg)
UN
IVE
RS
ITY
OF
IL
LIN
OIS
@ U
RB
AN
A-C
HA
MP
AIG
N
Next lab on Thursday
• Filter design • How to design and measure basic filters
• Filter usage • How to use filters to remove unwanted elements • How to produce various sounds using filters
58