36
2/3/2017 1 Audio Filter Design ELEC-E5620 - Audio Signal Processing, Lecture #3 Vesa Välimäki 3.2.2017 Sound check A(z) A(z) s(0) s(1) s(2) (n) © 2016 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen ELEC-E5620 Audio Signal Processing Lecture #4: Audio Filter Design DEMO Moog Filter Aaro & Micah 3.2.2017 2

Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

  • Upload
    others

  • View
    2

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

1

Audio Filter Design

ELEC-E5620 - Audio Signal Processing, Lecture #3

Vesa Välimäki

3.2.2017

Sound check

A(z)A(z)

s(0) s(1) s(2)

(n)

© 2016 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #4: Audio Filter Design

DEMO

Moog Filter

Aaro & Micah

3.2.20172

Page 2: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

2

0. General issues (Vesa & Fabian) 13.1.2017

1. History and future of audio DSP (Vesa) 20.1.2017

2. Digital filters in audio (Vesa) 27.1.2017

3. Audio filter design (Vesa) 3.2.2017

4. Analysis of audio signals (Vesa) 10.2.2017

No lecture (Evaluation week for Period III) 17.2.2017

5. Audio effects processing (Fabian) 24.2.2017

6. Synthesis of audio signals (Fabian) 3.3.2017

7. 3-D sound (Prof. Ville Pulkki) 10.3.2017

8. Physics-based sound synthesis (Vesa) 17.3.2017

9. Sampling rate conversion (Vesa) 24.3.2017

10. Audio coding (Vesa) 31.3.2017

Course Schedule in 2017

3.2.20173

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Introduction and motivation

• Properties of digital filters

• FIR or IIR?

• Error norms for filter design

• Auditory resolution

• FIR filter design

• IIR filter design

• Conclusion

• The first demo: The Moog Filter!!!

3.2.20174

Outline

Page 3: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

3

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.20175

Introduction and Motivation

• Recall basic audio filters the previous lecture– Usually straightforward design in closed form

• More advanced filters needed in many real-life applications– Equalization of loudspeakers/headphones

– 3D sound using HRTFs (head-related transfer function)

– Room correction (loudspeaker-room EQ)

– Digital musical instruments (e.g., piano soundboard, or violin body)

– Acoustic system modeling in general

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.20176

Example: HRTF Modeling

Target response

FIR, order 48

IIR, order 24

Warped IIR, order 24

• Source: Huopaniemi, J., Zacharov, N., and Karjalainen, M., Objective and SubjectiveEvaluation of Head-Related-Transfer FunctionFilter Design, 105th AES Convention

Page 4: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

4

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Which application? What purpose?– Requirements help to choose the design method

• General principle– Quick methods for real-time applications

– Accurate methods for off-line processing

• Things to remember in audio filter design– The frequency resolution of the human hearing

system in nonlinear: good at low, poor at high frequencies

– Conventional ”textbook” filter design techniques (lowpass, highpass, bandpass…) are usually unsuitable

3.2.20177

Introduction and Motivation, cont’d

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Convolution for linear and time-invariant (LTI) systems:

where h[n] is the filter’s impulse response and x[n] is the input signal

• In the z-domain

3.2.20178

Properties of Filters

k

knhkxnxnhny ][][][][][

N

k

kk

M

k

kk

za

zb

zX

zYzHzXzHzY

0

0

)(

)()()()()(

Page 5: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

5

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Frequency response– Replace z with ejω

• Magnitude response– Take the absolute value

• In Matlab– freqz.m

3.2.20179

Properties of Filters: Magnitude Response

)(

)()(

j

jj

eX

eYeH

)( jeH

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Phase response– Radian phase shift

• Phase delay– Time delay of each sinusoidal

component (in samples)

• Group delay– Time delay (in samples) of the

amplitude envelope of a sinusoid at frequency ω

• In Matlab: – phasez.m– phasedelay.m– grpdelay.m

3.2.201710

Properties of Filters: Phase Response

)(arg)( jeH

)(

)( P

)()(

d

dD

Page 6: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

6

© 2016 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #4: Audio Filter Design

• Phase response and phase delay– 2nd-order allpass filter

Phase Delay of a Digital Filter

3.2.201711

)(

)( P

© 2016 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #4: Audio Filter Design

• The phase delay is –1 times the slope of a straight line fitted through 0 and ():

Phase Delay of a Digital Filter, Ex. #1

3.2.201712

0

)(0

)()(P

Page 7: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

7

© 2016 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #4: Audio Filter Design

• The phase delay is –1 times the slope of a straight line fitted through 0 and ():

Phase Delay of a Digital Filter, Ex. #2

3.2.201713

0

)(0

)()(P

© 2016 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #4: Audio Filter Design

• Phase response and group delay– The same 2nd-order

allpass filter as before

Group Delay of a Digital Filter

3.2.201714

)()(

d

dD

Page 8: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

8

© 2016 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #4: Audio Filter Design

• The group delay is –1 times the local gradient of the phase function ()

Group Delay of a Digital Filter, Ex. #1

3.2.201715

)()(

d

dD

© 2016 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #4: Audio Filter Design

• Phase delay = group delay, when the phase function is linear

• Otherwise: Phase delay ≠ group delay,

Phase Delay vs. Group Delay

3.2.201716

Phase delay

Group delay

Page 9: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

9

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Radians– Sampling frequency = 2π Axis [0, π]

• Normalized– Sampling frequency = 1 Axis [0, 0.5]

– Easy to convert to Hz by multiplying by sampling frequency

• Matlab (default)– Sampling frequency = 2 Axis [0, 1]

– Weird...

• Hz– Sampling frequency = e.g. 44.1 kHz Axis [0, 22.05 kHz]

3.2.201717

How to Present the Digital Frequency Axis?

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Linear phase– Easy to obtain using FIR filters

– Symmetric impulse response

– Phase delay = group delay

– Sometimes desirable, but why?

• Zero phase– Special case of a linear-phase filter

– Impulse response symmetric w.r.t. 0 → noncausal!– Possible offline: filtfilt.m

18

Phase Characteristics (1)

3.2.2017

Page 10: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

10

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Linear-phase → constant phase delay at all frequencies – 100 samples of delay in this example

3.2.201719

Linear Phase in Practice

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Minimum phase– No zeros outside the unit circle

– Often desirable, why?

– Releases energy as fast as possible

for the given magnitude response

– Always stable and causal • Also the inverse filter is stable!

• Maximum phase– All zeros outside the unit circle (or on the unit circle)

– Time-reversed version of the minimum-phase system

20

Phase Characteristics (2)

3.2.2017

Page 11: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

11

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201721

Impulse Response with Different Phase

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Lowpass, order 19

• Cutoff frequency 0.25fs/2• Use the function fir1.m

– For plotting: freqz.m, impz.m, zplane.m• Pay attention to the frequency normalization!

• Download the code (fir1_demo.m) from MyCourses and test it!

3.2.201722

Linear-Phase/Minimum-Phase FIR Filter

Page 12: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

12

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201723

Linear-Phase/Minimum-Phase FIR Filter

Linear phase Minimum phase

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201724

Linear-Phase/Minimum-Phase FIR Filter

Linear phase Minimum phase

Page 13: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

13

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201725

Pole-Zero Plots

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201726

Pole-Zero Plots

Page 14: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

14

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Option #1: Mirroring of Zeros– Reflect zeros outside the unit circle to inside the unit circle

– Not feasible when the filter order is large, because then it is difficult or impossible to find the zeros (i.e., roots of a polynomial)

3.2.201727

How to Construct a Minimum Phase?

r

ezrrez

jj

1,

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Option #2: The Hilbert Transform Method– Logarithm of a magnitude response and its minimum phase are

Hilbert transform pairs

– To convert a filter to minimum-phase: Replace its phase responsewith the Hilbert transform of the log magnitude response!

– See:

https://ccrma.stanford.edu/~jos/sasp/Minimum_Phase_Filter_Design.html

3.2.201728

How to Construct a Minimum Phase?

)(arg)(log)(log)(ˆ zHjzHzHzH

Page 15: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

15

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Option #3: Cepstral Windowing– Cepstrum is the inverse DFT of the log DFT spectrum– Deleting the left side of the cepstrum by windowing using w(n) modifies

the phase so that the signal becomes minimum-phase:

where F-1{ } is the inverse Discrete Fourier Transform (DFT)• Download the codes (minphase_rceps.m

minphase_hilbert.m) from MyCourses and try!• See also:

https://ccrma.stanford.edu/~jos/fp/Creating_Minimum_Phase_Filters.html

3.2.201729

How to Construct a Minimum Phase?

)(ˆ1mp

1

)(

)()()(ˆ

)(log)(

ncFeFnh

nwncnc

zHFnc

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• When should I choose FIR, when an IIR filter?– Pros and cons of FIR and IIR filters?

3.2.201730

”The Battle of Impulse Responses”

Page 16: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

16

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Team “FIR”

3.2.201731

”The Battle of Impulse Responses”

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Team “IIR”

3.2.201732

”The Battle of Impulse Responses”

Page 17: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

17

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Approximate the target response with a digital filter

• Minimize the error function

Error = target – approximation

• In digital filter design, Lp norms are often used– L2 leads to the least-squares design

– L∞ leads to the Chebyshev (minimax) design

3.2.201733

The Filter Design Problem

)(ˆ)()( jjj eHeHeE

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Many popular filter design techniques, such as Prony’smethod, use this

• An easy LS FIR filter design method is to truncate the impulse response of the ideal filter– By including the largest samples, you minimize the squared error

3.2.201734

Least-Squares (L2) Norm

0

2

2

2

22

22

)(ˆ)(ˆ)(ˆ)(

2)(ˆ)(ˆ)(ˆ)()(

n

jjjjj

nhnhnhnh

deHeHeHeHeE

Page 18: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

18

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• ad is the desired frequency response, is frequency response error– F is the Fourier transform matrix

• Minimize the squared error:

3.2.201735

Solving FIR Filter Coefficients in LS Design

T

dTT

dTT

dTd

Td

TT

Tdd

d

d

ah

ahaahahhh

ahahh

ah

ah

FFF

0FFFF2FF

0FF

Fminmin

F

1

22

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Chebyshev (minimax) norm:– Minimize the maximum component of the error norm

– Need an iteration loop and an end rule (for selected accuracy)

– Finally the error function will be “equiripple”

3.2.201736

Chebyshev (L∞) Norm

)(ˆ)(maxˆ)(ˆ)()(

jjjjj eHeHeHeHeE

Page 19: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

19

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Take properties of human hearing into account– Linear or non-uniform (e.g. critical bands) frequency scale?

– The domain where the magnitude is matched (e.g. T60-domain)?

• Tools– Auditory smoothing: averaging of the spectrum with a sliding window

– Weighting functions: suppress less important frequency areas

– Frequency warping: expand important frequency range; shrink the less important range

3.2.201737

Auditory Resolution

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

Example target response– ERB & Bark

smoothing

– 1/3 and 1/10 octave smoothing

– Cepstral smoothing

3.2.201738

Auditory Smoothing

Source: Huopaniemi, J. Virtual Acoustics and 3-D Soundin Multimedia Signal Processing. Doctoral Thesis, TKK, 1999.

Page 20: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

20

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Psychoacousticalweighting functions– ERB

– Bark

3.2.201739

Weighting Functions

Source: Huopaniemi, J. Virtual Acoustics and 3-D Soundin Multimedia Signal Processing. Doctoral Thesis, TKK, 1999.

© 2016 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #4: Audio Filter Design

• Frequency scale warping before designing the filter– Replace the unit delay with

a first order allpass filter

– λ is the warping parameter

Frequency Warping

1

11

1

z

zz

3.2.201740

1

11

1

z

zz

Source: Huopaniemi, J. Virtual Acoustics and 3-D Sound in Multimedia Signal Processing. Doctoral Thesis, TKK, 1999.

Page 21: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

21

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Allpass filter → flat magnitude response

• Frequency-dependent group delay

• If λ = 0.7661 (fs = 48 kHz), warping is set to match the Bark scale (Smith and Abel 1999)

• Design the filter in warped frequency domain → concentrate on the important frequency range

3.2.201741

Properties of Warped Filters

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Implement the filters in the warped frequency domain– WFIR or WIIR structures

– More accuracy, but more computation as well

– In WIIR structures the delay-free loops must be avoided → remap coefficients

• Unwarp the warped transfer function to a standard IIR filter

3.2.201742

How to Warp?

Page 22: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

22

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201743

Warped FIR Filter

• Chain of first-order allpass filters in FIR filter structure

• s(n) is the signal to be warped

• sw(n) is the warped signal

• The extent of warping is determined by o With = 0, the warped FIR filter becomes a standard FIR filter

A(z)A(z)A(z)

s(0) s(1) s(2) s(L-1)

A zz

z( )

1

11

(n)

sw(n)

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Frequency sampling– Construct the target frequency response (magnitude & phase)– Also at negative frequencies: the same magnitude but opposite phase– Use IFFT to obtain the filter coefficients – The length of IFFT specifies the filter size– There will be ”don’t care” regions between the selected points

• Windowing method– Truncate the impulse response using a window function– Many choices for window functions!– Suitable for modeling measured/estimated impulse responses in audio

• In Matlab: fir1.m, fir2.m, and others

3.2.201744

FIR Filter Design

Page 23: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

23

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Rectangular window– Minimizes the truncated time-domain L2 norm

– Gibb’s phenomenon (passband ripple)

– Low sidelobe rejection

– Relatively steep transition band

• Other window functions– Hann

– Hamming

– Blackman

– …

3.2.201745

Properties of Window Functions

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201746

Rectangular Window

Page 24: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

24

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201747

Hann Window

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201748

Hamming Window

Page 25: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

25

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201749

Blackman Window

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

3.2.201750

Window Comparison

Rectangular

Hamming

Hann

Blackman

Page 26: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

26

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Minimize

• Again, minimize the error:

• Weight important data values– Frequency ranges of interest

3.2.201751

Weighted LS FIR Filter Design

1

0

2)(ˆ)()(

L

kkkk HHWE

h FTWF 1FTWad

T

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• A set of equalizers (EQ) with fixed center freq. and Q value– One equalizing filter per band for each channel

– Octave graphic EQ: 10 bands per channel

– 1/3-oct graphic EQ: ~30 bands per channel

52

Graphic EQ

(Picture taken from http://www.bssaudio.com/)

3.2.2017

Page 27: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

27

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Cascade structure

• Parallel structure

53

Graphic EQ Types

19.11.2015

Out

H1(z) z-1H2(z) HM(z)

In

G1 G2 GMG0

OutH1(z) z-1H2(z) HM-1(z) HM(z)In

G1 G2 GM-1 GM

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Each subfilter is an equalizing filter with fixed fc and Q: Gain G at peak, 0 dB elsewhere

• Problem: interaction between bands…

54

Cascade Graphic EQ

19.11.2015

OutH1(z) z-1H2(z) HM-1(z) HM(z)In

G1 G2 GM-1 GM

Page 28: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

28

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Naïve design leads to severe approximation problems– Filter gains = command gains

3.2.201755

Cascade Graphic EQ for Octave Bands

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• It is possible to measure the interaction and form an interaction matrix (Abel and Berners, 2004; Oliver and Jot, 2015)

• Matrix B shows how much each band filter leaks to neighboring bands:– Normalized so it shows how much 1 dB of gain affects other bands

3.2.201756

Octave Graphic EQ Design (1)

Page 29: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

29

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Use inverse matrix of B to solve the optimal dB gains in LS sense:

• After optimization: filter gains ≠ command gains

• In the next example, 8 peak/notch filters and two 1st-order shelf filters are cascaded (Välimäki and Reiss, 2016)

3.2.201757

Octave Graphic EQ Design (2)

OutH1(z) z-1H2(z) HM-1(z) HM(z)In

G1 G2 GM-1 GM

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Maximum error about 5 dB

3.2.201758

Unoptimized Octave Graphic EQ

Page 30: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

30

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Maximum error about 2 dB

3.2.201759

Optimized Octave Graphic EQ

© 2010 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

S-89.3540 Audio Signal ProcessingLecture #5: Audio Filter Design

New Graphic EQ Design Methods

• The previous design method is ok for some applications, but it doesn’t fulfill the hi-fi requirement (max 1 dB error)

• Alternative #1: a novel parallel graphic EQ design– Very high accuracy, but requires optimization (Rämö et al., 2014)

• Alternative #2: a novel cascade graphic EQ design– Even more accurate (Välimäki and Liski, 2017)

3.2.201760

Page 31: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

31

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Linear prediction

• Prony’s method

• Also others

3.2.201761

IIR Filter Design

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• A.k.a. Linear Prediction Coding (LPC)

• Powerful analysis technique, especially in speech processing

• Other applications– Pitch prediction

– Signal modeling for sound synthesis

– Detection of clicks in audio restoration

– Spectral envelope estimation

• Predict the next sample as a linear combination of previous samples

3.2.201762

Linear Prediction

Page 32: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

32

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Compute the next sample as a linear combination of the previous samples

• Minimize the expected value of the mean-squared prediction error

3.2.201763

LPC Coefficients

P

kk knxanx

1

)()(ˆ

22 ))(ˆ)(( nxnxEeE n

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Analysis– Use the autocorrelation or covariance method to obtain

prediction coefficients

– FIR filter with prediction coefficients is an inverse filter, which whitens the input signal (decorrelation)

– Autocorrelation method → minimum phase

• Synthesis– Prediction coefficients used in an all-pole IIR filter yield a filter

with the spectral characteristics of the input signal

• In Matlab: lpc.m

3.2.201764

LPC Model

Page 33: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

33

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• (Recorded) target response

3.2.201765

Piano Soundboard Modeling with LPC, N = 20

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• (Recorded) target response

• Modeled

3.2.201766

Piano Soundboard Modeling with LPC, N = 200

Page 34: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

34

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• (Recorded) target response

• Modeled

3.2.201767

Piano Soundboard Modeling with LPC, N = 2000

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• (Recorded) target response

• Modeled

3.2.201768

Piano Soundboard Modeling with LPC, N = 10000

Page 35: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

35

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Design IIR filter from a given impulse response

• Solve denominator coefficients using linear prediction

• Solve numerator coefficients by matching the N +1 first samples of the impulse response

• In Matlab: prony.m

3.2.201769

Prony’s Method

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Properties of filters: magnitude and phase– The phase delay and group delay are identical for linear-phase

systems but otherwise different

• Various audio filter design methods– For FIR filters: Least squares, weighted least squares, frequency

sampling, impulse response truncation/windowing– For IIR filters: linear prediction, Prony’s method

• Auditory resolution can be taken into account– Weighting or warping

• The suitable method depends on the application• Typical design problems are HRTF filters, musical

instruments, and equalizers

3.2.201770

Conclusions

Page 36: Audio Filter Design - Aalto · Lecture #3: Audio Filter Design • Radians – Sampling frequency = 2π Axis [0, π] • Normalized – Sampling frequency = 1 Axis [0, 0.5] – Easy

2/3/2017

36

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• Easily accessible online book (check this out!)– Smith, J. O. III. “Introduction to Digital Filters with Audio Applications,”

http://ccrma.stanford.edu/~jos/filters/

• Filter design– Parks, T. W. and Burrus, C. S. Digital Filter Design. John Wiley & Sons, 1987.

– Mitra, S. K. Digital Signal Processing. McGraw-Hill, 2002.

• Frequency warping– A. Härmä, M. Karjalainen, L. Savioja, V. Välimäki, U. K. Laine, and J.

Huopaniemi, “Frequency-warped signal processing for audio applications,” Journal of the Audio Engineering Society, vol. 48, no. 11, pp. 1011–1031, Nov. 2000.

– Smith, J. O. III and Abel, J. S. “The Bark and ERB bilinear transforms,” IEEE Trans. Speech and Audio Proc., Vol. 7, No, 6, pp. 697-708, Nov. 1999.

3.2.201771

Literature

©2016-2017 Vesa Välimäki, Heidi-Maria Lehtonen and Sami Oksanen

ELEC-E5620 Audio Signal ProcessingLecture #3: Audio Filter Design

• J. S. Abel and D. P. Berners, “Filter design using second-order peaking and shelvingsections,” in Proc. Int. Comput. Music Conf., Miami, FL, USA, Nov. 2004.

• Huopaniemi, J., Zacharov, N., and Karjalainen, M., “ Objective and subjective evaluationof head-related transfer function filter design,” presented at the 105th AES Convention,preprint 4805, San Francisco, California, USA, September 26-29, 1998. Invited paper.

• Huopaniemi, Jyri. Virtual Acoustics and 3-D Sound in Multimedia Signal Processing.Doctoral thesis. Report no. 53 / Helsinki University of Technology, Laboratory ofAcoustics and Audio Signal Processing. Espoo, Finland, 1999.

• R. J. Oliver and J.-M. Jot, “Efficient multi-band digital audio graphic equalizer withaccurate frequency response control,” in Audio Eng. Soc. 139th Conv., New York, NY,USA, Oct. 2015.

• Lehtonen, H.-M., Rauhala, J., and Välimäki, V. “Sparse multi-stage loss filter design forwaveguide piano synthesis,” In Proc. IEEE Workshop on Applications of SignalProcessing to Audio and Acoustics, pp. 331-334, New Paltz, NY, USA, October 16-19,2005.

• J. Rämö, V. Välimäki, B. Bank, “High-precision parallel graphic equalizer,” IEEE/ACM Tr.Audio, Speech, Lang. Process., pp. 1894–1904, Dec. 2014.

• V. Välimäki and J. D. Reiss, “All about audio equalization: Solutions and frontiers,” Appl.Sci., vol. 6, no. 5, p. 129, May 2016.

3.2.2017

References

72