Peaking and Shelving Filter Properties Shelf Filter Specification • A

advertisement
MUS424:
Signal Processing Techniques for Digital Audio Effects
Jonathan Abel, David Berners
Handout #22
May 18, 2004
Lecture Notes 12
Lecture #14:
May 18, 2004
Peaking and Shelving Filter Properties
Shelf Filter Specification
• A shelf filter h(ω) takes on a gain of `0 at DC, a gain
1
of `π at high frequencies, and a gain of (`0 · `π ) 2 at
a transition frequency ϕ.
• A low shelf filter has the high-frequency gain `π fixed
at one, with `0 free to vary.
• In a high shelf filter, the high-frequency gain `π is
varied with the DC gain `0 fixed at one.
2
MUS424: Handout #22
First-Order Shelf Filter Analog Prototype
• Consider the following first-order analog prototype
filter,
`π · s/ρ + `0
h(s) =
.
s/ρ + 1
• Note that the analog prototype filter takes on the
desired DC and high-frequency gains,
h(ω = 0) = `0 ,
h(ω → ∞) = `π ,
with the factor ρ controlling the transition frequency.
• The analog prototype filter is designed to have a
transition frequency of one. Setting |h(j · 1)|2 =
`0 · `π , the factor ρ may be specified.
2
2
2
`
/ρ
+
`
0
|h(j · 1)|2 = `0 · `π = π 2
,
1/ρ + 1
which implies
µ ¶ 12
`π
ρ=
.
`0
• Substituting into the expression for h(s), we have
1
1
2
h(s) = (`0 `π ) ·
s + (`0/`π ) 2
1
2
(`0/`π ) s + 1
.
MUS424: Handout #22
3
First-Order Shelf Filter Analog Prototype Properties
• The analog prototype shelf filter has transfer function
1
s + (`0/`π ) 2
1
2
h(s) = (`0 `π ) ·
1
2
(`0/`π ) s + 1
.
• It has a real pole and real zero at reciprical frequencies about the transition frequency s = j · 1,
1
sp = −(`π /`0) 2 ,
1
sz = −(`0/`π ) 2 .
• Note that on a dB scale the normalized analog shelf
filter is antisymmetric in log s about the transition
frequency,
1
h(1/s) ∝
1/s + (`0/`π ) 2
1
(`0/`π ) 2 /s + 1
1
1 + (`0 /`π ) 2 s
=
∝ 1/h(s).
1
(`0/`π ) 2 + s
4
MUS424: Handout #22
First-Order Digital Shelf Filter via Bilinear Transform
• The digital shelf filter is formed via bilinear transform
on the analog prototype,
h(z) = h(s(z)),
2 1 − z −1
s= ·
.
T 1 + z −1
We have
1
h(s) = (`0`π ) 2 ·
s + 1/ρ
,
s/ρ + 1
1
ρ = (`π /`0) 2 ,
and,
ρ(1 − z −1 ) + T2 (1 + z −1)
h(z) = (`0`π ) ·
,
T
−1
−1
(1 − z ) + ρ 2 (1 + z )
( T2 + ρ) + ( T2 − ρ)z −1
1
= (`0`π ) 2 · T
,
T
−1
(ρ 2 + 1) + (ρ 2 − 1)z
³
´
"
#
1−T /2ρ
−1
T
1
−
z
ρ+ 2
1+T /2ρ
1
³
´
= (`0`π ) 2
·
.
T
1−ρT
/2
1 + ρ2
1−
z −1
1
2
1+ρT /2
• Note that the pole at −ρ and zero at −1/ρ have
been transformed according to the bilinear transform.
MUS424: Handout #22
5
Selecting T
• The ”sampling period” T is chosen to put the transition frequency of the analog prototype, Ω = 1, at
the desired frequency ϕ.
• Evaluating the bilinear transform on the unit circle,
z −1 = e−jω ,
2
s =
T
2
=
T
1 − z −1
2 1 − e−jω
·
= ·
,
1 + z −1 T 1 + e−jω
ejω/2 − e−jω/2
2 j sin(ω/2)
· jω/2
= ·
,
e
+ e−jω/2 T cos(ω/2)
we see that the frequency ω on the unit circle corresponds to the frequency
2
Ω = tan(ω/2)
T
on the s-plane imaginary axis. (Note that for small
frequencies |ω| ¿ 1, tan(ω/2) ≈ ω/2, and Ω ≈ T1 .
• To map the analog prototype filter transition frequency of 1 to the desired transition frequency ϕ,
we set
T
= tan(ϕ/2).
2
6
MUS424: Handout #22
Example Shelf Filters
second-order shelf filter transfer function magnitudes, ft = 125 * 2.^[0:6]
20
15
10
5
0
10 -1
10 0
frequency - kHz
10 1
second-order shelf filter transfer function magnitudes, gain = [2:2:20]
20
15
10
5
0
10 -1
10 0
frequency - kHz
10 1
MUS424: Handout #22
7
Peak Filter Specification
• A peak (or notch) filter p(ω) takes on a gain of 1 at
DC and high frequencies, and achieves a maximum
(or minimum) gain of ` at some point between√the
transition frequencies ϕ±, at which the gain is `.
• The frequency of the magnitude extremum is called
the center frequency, ϕc.
8
MUS424: Handout #22
Digital Peak Filter
The second-order digital filter
b0 + b1 z −1 + b2 z −2
p(z) =
1 + a1 z −1 + a2 z −2
with coefficients given by
2Q − sin ϕc
,
2Q + sin ϕc
= b1 = −(1 + a2) cos ϕc ,
1
1
= (1 + a2 ) + (1 − a2 )`,
2
2
1
1
= (1 + a2 ) − (1 − a2 )`,
2
2
a2 =
a1
b0
b2
implements a peak (or notch) filter with maximum (or minimum) gain ` at a
center frequency ϕc between the
√ specified transition frequencies ϕ± , at which
the filter takes on magnitude `. The center frequency ϕc and the inverse
bandwidth Q may be written in terms of the transition frequencies ϕ± and
dB peak gain λ,
n
¡ 2
¢ 12 o
ϕc = acos κ − sign{κ} κ − 1
,
1 + cos ϕ− cos ϕ+
cos ϕ− + cos ϕ+
·
¸1
1 ` · sin2 ϕc · (cos ϕ− + cos ϕ+ ) 2
Q =
.
2 2 cos ϕc − cos ϕ− − cos ϕ+
κ =
In the case that ϕ+ + ϕ− = π, we have
ϕc = π/2,
√
`
Q =
| cot δ|,
2
1
δ = (ϕ− − ϕ+ ).
2
MUS424: Handout #22
9
Example Peak Filters
peak filter transfer function magnitudes, ft = 125 * 2.^[0:6]
20
15
10
5
0
10 -1
10 0
frequency - kHz
10 1
peak filter transfer function magnitudes, gain = [2:2:20]
20
15
10
5
0
10 -1
10 0
frequency - kHz
10 1
10
MUS424: Handout #22
Graphic Equalizer
graphic equalizer shelf and peak filters
6
5
4
3
2
1
0
10 -1
10 0
frequency - kHz
10 1
• A graphic equalizer is implemented as a cascade of
peak and shelf filters having a prioi specified bandwidths and user-controlled gains.
MUS424: Handout #22
11
Graphic Equalizer Behavior
traditional graphic equalizer with controls set to [0 0 0 5 5 0 0 0] dB
10
8
6
4
2
0
10 -1
10 0
frequency - kHz
10 1
• By adjusting the gains of the peak and shelf filters
in the cascade, a wide variety of transfer function
magnitudes may be produced.
• Although the idea is that the transfer function magnitude should smoothly interpolate the specified gains,
it doesn’t always work out that way.
12
MUS424: Handout #22
Graphic Equalizer Behavior
traditional graphic equalizer with controls set to 5*ones(1,8) dB
10
8
6
4
2
0
10 -1
10 0
frequency - kHz
10 1
• Contributions from adjacent bands cause the filter to
overshoot the desired gains.
MUS424: Handout #22
13
Graphic Equalizer Behavior
traditional graphic equalizer with narrow-band peak filters
10
8
6
4
2
0
10 -1
10 0
frequency - kHz
10 1
• Traditional graphic equalizers don’t smoothly interpolate the given gains.
– Small filter bandwidths lead to rippled transfer
functions.
– Large filter bandwidths overshoot desired gains.
14
MUS424: Handout #22
Alternative Gain Computation
novel graphic equalizer
10
8
6
4
2
0
10 -1
10 0
frequency - kHz
10 1
• The idea is to find a set of peak and shelf filter gains
which account for the overlap between bands, so that
the resulting peak and shelf filter cascade interpolates the specified band gains.
MUS424: Handout #22
15
Peak Filter Self Similarity
peak filter transfer function magnitudes, gain = [2:2:20]
20
15
10
5
0
10 -1
10 0
frequency - kHz
10 1
normalized peak filter transfer function magnitudes, gain = [2:2:20]
1
0.8
0.6
0.4
0.2
0
10 -1
10 0
frequency - kHz
10 1
• Peaking filters parameterized by a maximum dB gain
λ, achieved somewhere between transition frequencies ϕ− and ϕ+, at which the dB gain is λ/2, are
approximately self similar on a log magnitude scale.
α · log |p(ω; λ, ϕ±)| ≈ log |p(ω; α · λ, ϕ±)|.
16
MUS424: Handout #22
Shelf Filter Self Similarity
second-order shelf filter transfer function magnitudes, gain = [2:2:20]
20
15
10
5
0
10 -1
10 0
frequency - kHz
10 1
normalized shelf filter transfer function magnitudes, gain = [2:2:20]
1
0.8
0.6
0.4
0.2
0
10 -1
10 0
frequency - kHz
10 1
• Low shelf filters specified by a low-frequency dB gain
λ, a dB gain λ/2 at a transition frequency ϕ, and
a high-frequency gain of one are also approximately
self similar on a log magnitude scale.
α · log |h(ω; λ, ϕ)| ≈ log |h(ω; α · λ, ϕ)|.
MUS424: Handout #22
17
Filter Design Approach
• Consider a cascade g(ω; θ) of K peak and shelf filters having gains and λk , k = 1, . . . , K and transition frequencies ϕk , k = 1, . . . , K − 1 stacked in the
column θ,
g(ω; θ) = h(ω; λ1, ϕ1 ) · h(ω; λK , ϕK−1) ·
K−1
Y
p(ω; λk , ϕk−1, ϕk ).
k=2
• Because of the self similarity property, the dB magnitude of the cascade, denoted by γ(ω; θ),
def
γ(ω; θ) = 20 log 10{g(ω; θ)},
= σ(ω; λ1, ϕ1) + σ(ω; λK , ϕK−1) +
K−1
X
π(ω; λk , ϕk−1, ϕk ),
k=2
is approximately linear in the filter gains,
γ(ω; θ) ≈ λ1 · σ(ω; 1.0, ϕ1 ) + λK · σ(ω; 1.0, ϕK−1) +
K−1
X
λk · π(ω; 1.0, ϕk−1 , ϕk ).
k=2
18
MUS424: Handout #22
Filter Design Approach
• At a particular frequency ωi, we have
£
¤
γ(ωi; θ) ≈ σ1(ωi ) π2(ωi ) · · · πK−1(ωi) σK (ωi) λ,
where λ is the stack of dB band gains,
£
¤>
λ = λ1 · · · λK ,
and where σk (ωi ) and π(ωi ) are the transfer function
dB magnitudes of shelf and peak filters with specified transition frequencies and 1.0 dB nominal gains,
evaluated at ωi ,
σk (ωi) = 20 log 10{h(ωi; 1.0dB, ϕk )}
and
π(ωi) = 20 log 10{p(ωi; 1.0dB, ϕk−1, ϕk )}.
• Stacking instances of γ(ω; θ) evaluated at a set of
frequencies ωi to form the column γ, we have
£
γ ≈ Bλ,
¤
B = σ1 π 2 · · · π K−1 σK ,
where σ k and π k are columns of dB magnitudes
evaluated at ωi of shelf and peak filters having gains
of 1.0 dB and specified transition frequencies.
MUS424: Handout #22
19
Graphic Equalizer Design
• The self similarity of second-order peaking and shelving filters leads to an approximate linear relationship
between the dB filter gains and the dB gain of the
cascade,
γ ≈ Bλ,
• Therefore, given a set of shelf and peak filters having
specified transition frequencies, and positive definite
weighting matrix W , the gains
λ̂ = (B >W B)−1B >W γ
will approximately minimize the weighted square difference between a desired dB magnitude response γ
and the shelf and peak filter cascade dB magnitude
at frequencies ωi, γ.
• For a graphic equalizer with K − 1 fixed band edges,
the frequencies ωi can be chosen as the K band
centers, and the gains λ̂ simply computed as the
control gains γ scaled by the basis inverse,
λ̂ = B −1γ.
20
MUS424: Handout #22
Graphic Equalizer Design Example
traditional and novel graphic equalizers
15
10
5
0
-5
-10
-15
10 -1
10 0
frequency - kHz
10 1
• For a graphic equalizer with K − 1 fixed band edges,
the frequencies ωi can be chosen as the K band
centers, and the gains λ̂ simply computed as the
control gains γ scaled by the basis inverse,
λ̂ = B −1γ.
– Note that for a grphic equalizer with fixed band
edges, B −1 may be computed a priori.
– To account for discrepancies in the self similarity
property, λ̂ may be computed iteratively, forming
B using the gains from the previous solution.
MUS424: Handout #22
21
Iterated Solution
graphic equalizer with iterated band gains
15
10
5
0
-5
-10
-15
10 -1
10 0
frequency - kHz
10 1
• Iterative solution of the equation for the corrected
band gains can correct for discrepancies in filter self
similarity,
λn+1 = B(λn)−1γ.
• It seems likely that the iteration converges since the
sensitivity of the basis to changes in the gain are
small, and changes in the basis B are monotonic
with changes in the gains λ.
22
MUS424: Handout #22
Transfer Function Modeling
measured transfer function magnitude, selected extrema
0
-5
-10
-15
-20
10 -1
10 0
frequency - kHz
10 1
• A cascade of peak and shelf filters can be fit to an
arbitrary transfer function by selecting a set of transition frequencies, and fitting the gains.
• Transition frequency selection method.
– Tabulate extrema or inflection point frequencies.
– Pick transition frequencies as geometric means
of significant extrema or at significant inflection
points.
MUS424: Handout #22
23
Transfer Function Modeling
measured (solid) and modeled (dashed) transfer function magnitudes
0
-5
-10
-15
-20
10 -1
10 0
frequency - kHz
10 1
• Band gain selection method.
– Pick a dense sampling of frequencies ωi, say Bark
or ERB spaced.
– Form basis, and compute gains,
λ̂ = (B >W B)−1B >W γ.
• The resulting transfer function will not interpolate
the specified gains γ, but rather approximate the
desired magnitude, minimizing the weighted mean
square dB difference.
24
MUS424: Handout #22
Critical Bandwidth and Critical Band Smoothing
original and critical-band smoothed power spectra
10
5
0
-5
-10
-15
-20
-25
10 -1
10 0
frequency - kHz
10 1
• When applied to broad band signals, details of a filter
smaller than a critical bandwidth are irrelevant—only
the total power matters.
MUS424: Handout #22
25
Critical Bandwidth
• The Bark frequency scale divides the human hearing
range into about 25 ciritcal bands.
• Frequency f in kHz and critical-band rate b in Bark
are related via the following expressions,
£
¤1
2 2
b = 10.3 log(1 + f ) ,
£
©
ª
¤ 12
2
f = exp (b/10.3) − 1 .
26
MUS424: Handout #22
Critical Bandwidth
• Critical bandwidth as a function of frequency is approximately
3
w = 0.094 + 0.071f 2 .
MUS424: Handout #22
27
Critical Band Smoothing
original and smoothed power spectra
30
20
10
0
-10
-20
10 -1
10 0
frequency - kHz
10 1
• By smoothing the filter power over bandwidths proportional to critical bandwidth, filter complexity is
reduced while retaining psychoacoustically relevant
cues.
• Critical-band smoothing may be done via a running
mean over frequency, or via windowing of a frequencywarped impulse response.
28
MUS424: Handout #22
Critical Band Smoothing
original and smoothed impulse responses
7
6
5
4
3
2
1
0
-1
0
0.5
1
1.5
2
2.5
3
time - milliseconds
3.5
4
4.5
5
• As expected, impulse responses are shortened by criticalband smoothing.
MUS424: Handout #22
29
Filter Phase
raw, minimum phase and linear phase impulse responses
3
2.5
2
1.5
1
0.5
0
-0.5
0
2
4
6
time - milliseconds
8
10
12
• Humans are relatively insensitive to filter phase.
• A linear phase filter delays all frequency components
the same amount τ ,
H(ω) = e−jτω · |H(ω)|.
• A minimum phase filter delays input energy the least
of all filters having the same magnitude response,
m
m
X
X
h2min(n) ≥
h2(n), ∀m.
n=0
n=0
Download