Amplitude
MUS421/EE367B Lecture 3 FFT Windows
Julius O. Smith III (jos@ccrma.stanford.edu) Center for Computer Research in Music and Acoustics (CCRMA) Department of Music, Stanford University Stanford, California 94305
Outline
March 28, 2005
• Rectangular, Hann, Hamming
• MLT Sine
• BlackmanHarris Window Family
• Kaiser
• Chebyshev
• Bartlett
• Poisson
• Gaussian
• Optimal Windows
1
This result is plotted below:
Note that this is the complete window transform, not just its magnitude. We obtain real window transforms like this only for symmetric, zerophase windows.
3
The Rectangular Window
In Lecture 0, we looked at the rectangular window:
Time (samples)
The window transform was found to be
∆
=
M · asinc _{M} (ω)
(1)
where asinc _{M} (ω) denotes the aliased sinc function.
asinc _{M} (ω)
∆
_{=}
sin(M ω/2)
M · sin(ω/2)
2
More generally, we may plot both the magnitude and phase of the window versus frequency:
4
Amplitude (dB)
In audio work, we more typically plot the window transform magnitude on a decibel (dB) scale:
DFT of a Rectangular Window − M = 11
5
Sidelobe RollOﬀ Rate
In general, if the ﬁrst n derivatives of a continuous function w(t) exist (i.e., they are ﬁnite and uniquely deﬁned), then its Fourier Transform magnitude is asymptotically proportional to
_{}_{W}_{(}_{ω}_{)}_{} _{→} constant
_{ω} n+1
(as ω → ∞)
Proof: Papoulis, Signal Analysis, McGrawHill, 1977
Thus, we have the following ruleofthumb:
n derivatives ↔ −6(n + 1) dB per octave rolloﬀ rate
(since −20 log _{1}_{0} (2) = 6.0205999
This is also −20(n + 1) dB per decade.
To apply this result, we normally only need to look at the window’s endpoints. The interior of the window is usually diﬀerentiable of all orders.
Examples:
.).
• Amplitude discontinuity ↔ −6 dB/octave rolloﬀ
• Slope discontinuity ↔ −12 dB/octave rolloﬀ
• Curvature discontinuity ↔ −18 dB/octave rolloﬀ
For discretetime windows, the rolloﬀ rate slows down at high frequencies due to aliasing.
7
Since the DTFT of the rectangular window approximates the sinc function, it should “roll oﬀ” at approximately 6 dB per octave, as veriﬁed in the loglog plot below:
Normalized Frequency (rad/sample)
As the sampling rate approaches inﬁnity, the rectangular window transform converges exactly to the sinc function. Therefore, the departure of the rolloﬀ from that of the sinc function can be ascribed to aliasing in the frequency domain, due to sampling in the time domain.
6
In summary, the DTFT of the M sample rectangular window is proportional to the ‘aliased sinc function’:
asinc _{M} (ωT)
∆
_{=}
_{≈}
sin(ωM T /2)
M
sin(πf M T ) MπfT
· sin(ωT /2)
∆
=
Some important points:
sinc(f M T )
• Zero crossings at integer multiples of Ω _{M}
_{=} ∆ 2π
M
where Ω _{M}
length M DFT
_{=} ∆ 2π
M
= frequency sampling interval for a
• Main lobe width is 2Ω _{M} = ^{4}^{π}
M
• As M gets bigger, the mainlobe narrows (better frequency resolution)
• M has no eﬀect on the height of the side lobes (Same as the “Gibbs phenomenon” for Fourier series)
• First sidelobe only 13 dB down from mainlobe peak
• Side lobes roll oﬀ at approximately 6dB per octave
• A phase term arises when we shift the window to make it causal, while the window transform is real in the zerophase case (i.e., centered about time 0)
8
Generalized Hamming Window Family
Consider the following picture in the frequency domain:
ω/Ω _{M}
We have added 2 extra aliased sinc functions (shifted), which results in the following behavior:
• There is some cancellation of the side lobes
• The width of the main lobe is doubled
9
Hann or Hanning or Raised Cosine
The Hann window is deﬁned by the settings α = 1/2 and β = 1/4:
Time (samples)
Normalized Frequency (rad/sample)
11
In terms of the rectangular window transform W _{R} (ω) = M · asinc _{M} (ω) (zerophase, unitamplitude case), this can be written as:
∆
W _{H} (ω) = αW _{R} (ω) + βW _{R} (ω − Ω _{M} ) + βW _{R} (ω + Ω _{M} )
Using the Shift Theorem, we can take the inverse transform of the above equation:
w _{H} = αw _{R} (n) + βe ^{−}^{j}^{Ω} ^{M} ^{n} w _{R} (n) + βe ^{j}^{Ω} ^{M} ^{n} w _{R} (n)
=
w _{R} (n) α + 2β cos ^{2}^{π}^{n}
M
Choosing various parameters for α and β result in diﬀerent windows in the generalized Hamming family, some of which have names.
10
Hann window properties:
• Mainlobe is 4Ω _{M} wide
• 1st side lobe is at 31dB
• Side lobes roll oﬀ at approx. 18dB / octave
Hamming
This window is determined by optimizing over α and β in such a way as to reduce the worstcase side lobe level.
Doing this, results in the following values:
• α = .54
• β = (1 − α)/2 (for unit timedomain peak amplitude)
12
Hamming Window
Hamming Window, M = 21
Time (samples)
Normalized Frequency (rad/sample)
13
Longer Hamming Window
Hamming Window, M = 101
Time (samples)
Normalized Frequency (rad/sample)
• Since the sidelobes nearest the main lobe are most aﬀected by the Hamming optimization, we now have a larger frequency region over which the spectral envelope looks like that of the asinc function (an “aliased 6 dB/octave rolloﬀ”).
• The sidelobe level (42.7 dB) is also improved over that of the shorter window (40.6 dB).
15
Hamming Window Properties
• Discontinuous “slam to zero” at endpoints
• main lobe is 4Ω _{M}
• Roll oﬀ is approx. 6 dB / octave (aliased)
• 1st side lobe is improved over Hann
• side lobes closer to “equal ripple”
Note: The Hamming window could also be called the “Chebyshev Generalized Hamming Window”. This is because the Hamming window minimizes the sidelobe level within the family. Chebyshevtype designs generally exhibit equiripple error behavior, since the worstcase error (sidelobe level in this case) is minimized.
14
Window Transform Summary
Window Transforms, Window length = 20
Normalized Frequency (cycles per sample)
Normalized Frequency (cycles per sample)
Normalized Frequency (cycles per sample)
16
The MLT Sine Window
The Modulated Lapped Transform (MLT) uses the sine window :
w(n) = sin n + ^{1} _{2}
_{2}_{M} ,
π
n = 0, 1, 2,
, 2M − 1 .
• Used in MPEG1, Layer 3 (MP3 format), MPEG2 AAC, MPEG4
• Sidelobes 24 dB down
• Asymptotically optimal coding gain
17
FrequencyDomain Implementation
The BlackmanHarris window family can be very eﬃciently implemented in the frequency domain as a (2L − 1)point convolution with the spectrum of the unwindowed data. Examples:
• Start with a length M rectangular window
• Take an M point DFT
• Convolve the DFT data with the 3point smoother [1/4, 1/2, 1/4] to implement a Hann window
• Note that the Hann window requires no multiplies in linear ﬁxedpoint data formats
• Implement any Blackman window as a 5point smoother in the frequency domain
19
BlackmanHarris Window Family
• The BlackmanHarris family of windows is basically a generalization of the Hamming family.
• In the case of the Hamming family, we constructed a summation of 3 shifted sinc functions.
• The Blackman/Harris family is derived by considering a more general summation of shifted sinc functions:
w _{B} (n) = w _{R} (n)
L−1
l=0
α _{l} cos(lΩ _{M} n)
∆
where Ω _{M} = 2π/M, n = −(M − 1)/2,
Special Cases:
(M − 1)/2 (M odd).
• L = 1 ⇒ Rectangular
• L = 2 ⇒ Generalized Hamming
• L = 3 ⇒ Blackman Family
18
Classic Blackman
The socalled “Blackman Window” is the speciﬁc case in which α _{0} = 0.42 α _{1} = 0.5, and α _{2} = 0.08
Properties:
• Sidelobes roll oﬀ about 18dB per octave (as T → 0)
• −58dB sidelobe level (worst case)
• One degree of freedom used to increase the rolloﬀ rate from 6dB/octave to 18 dB per octave
• One degree of freedom used to minimize sidelobes
• One degree of freedom used to scale the window
Matlab:
N =
101;
L
=
3;
No2
=
(N1)/2;
n=No2:No2;
ws 
= 
zeros(L,3*N); 
z 
= 
zeros(1,N); 
for 
l=0:L1 
ws(l+1,:)
=
[z,cos(l*2*pi*n/N),z];
end
alpha
w =
=
alpha
[0.42,0.5,0.08];
*
ws;
%
Classic
Blackman
20
Amplitude
Magnitude (dB)
Classic Blackman Window and Transform
ThreeTerm BlackmanHarris
Frequency (bins)
21
ThreeTerm BlackmanHarris Window and Transform
Three−Term Blackman−Harris Window: M = 51
Time (samples)
Frequency (bins)
23
• All degrees of freedom (scaling aside) are used to minimize side lobes (like Hamming).
Matlab:
N =
101;
L
=
3;
No2
=
(N1)/2;
n=No2:No2;
ws 
= 
zeros(L,3*N); 
z 
= 
zeros(1,N); 
for 
l=0:L1 
ws(l+1,:)
=
[z,cos(l*2*pi*n/N),z];
end
% 3term
alpha
w
=
BlackmanHarris(Nuttall):
[0.4243801,
*
ws;
0.4973406,
=
0.0782793];
alpha
22
Longer ThreeTerm BlackmanHarris Window and Transform
Three−Term Blackman−Harris Window: M = 301
Time (samples)
−20
−40
−60
−80
−100
−120
Frequency (bins)
24
PowerofCosine
w(n) = w _{R} (n) cos ^{L} ^{π}^{n} ,
M
n
∈ − ^{M} ^{−} ^{1}
2
_{,} M − 1
2
• L = 0, 1, 2,
• ﬁrst L terms of its Taylor expansion, evaluated at the endpoints are identically 0
• rolloﬀ rate ≈ 6(L + 1)dB/octave
• L = 0 ⇒ Rectangular window
• L = 1 ⇒ MLT sine window
• L = 2 ⇒ Hann window (“raised cosine” = “cos ^{2} ”)
• L = 3 ⇒ Alternate Blackman (max rolloﬀ rate)
Thus, cos ^{L} windows parametrize Lthorder BlackmanHarris windows conﬁgured so as to use all L degrees of freedom to maximize rolloﬀ rate.
25
Poisson (“Exponential”)
w _{P} (n) = w _{R} (n)e ^{−}^{α}
n
(M −1)/2
where: α determines the time constant ( τ =
Poisson Window M = 51
M
2α
^{)}
time (samples)
In the zplane, the Poisson window has the eﬀect of contracting the unit circle. Applied to a causal signal h(n) having z transform H(z), we have
27
Miscellaneous Windows
Bartlett (“Triangular”)
w(n) = w _{R} (n) 1 −
n − 1)/2
(M
• Convolution of two halflength rectangular windows
• Window transform is sinc ^{2} =⇒
• First sidelobe twice as far down as rect (26 dB)
• Main lobe twice as wide as that of a rectangular window having the same length (same as that of a halflength rect used to make it)
• Often applied to sample correlations of ﬁnite data
• Also called the “tent function”
∞
26
28
HannPoisson (“No Sidelobes”)
w(n) = ^{1}
_{2} 1 + cos π
n − 1)/2 ^{e} −α
(M
n
(M −1)/2
• Poisson window times Hann window (exponential times raised cosine)
• “No sidelobes” for α ≥ 2
• Valuable for “hill climbing” optimization methods (gradientbased)
Matlab: 

function 
[w,h,p] 
= 
hannpoisson(M,alpha) 
%HANNPOISSON

Length
M
HannPoisson
window
Mo2 
= 
(M1)/2; 
n=(Mo2:Mo2)’; 

scl 
= 
alpha 
/ 
Mo2; 
p =
scl2
exp(scl*abs(n));
=
pi
/
Mo2;
h 
= 
0.5*(1+cos(scl2*n)); 
w 
= 
p.*h; 
29
HannPoisson Slope and Curvature
Slope and Curvature of DTFT dB Magnitude, Hann−Poisson Window, M = 21, Alpha = 2.0
31
HannPoisson Window and Transform
Hann−Poisson Window, M = 21, Alpha = 2.0
Time (samples)
32
Side Lobe Level (SLL)
Kaiser
Question: How do we use all M degrees of freedom (sample values) in an M point window w(n) to obtain W (ω) ≈ δ(ω) in some optimal sense?
The Kaiser window maximizes the energy in the main lobe of the window.
max
w
^{} main lobe energy total energy
The functions which maximize this ratio are known as prolate spheroidal wave functions.
Kaiser discovered an approximation based upon Bessel functions:
∆
w _{K} (n) =
I _{0} β 1−
n
M/2 2
0,
I _{0} (β)
_{,}
_{−} M−1
2
≤ n ≤ ^{M}^{−}^{1}
2
elsewhere
The transform of this window is:
33
SLL vs Main Lobe Width for the Kaiser Window ( =0,0.5,1,
,4)
Main lobe width in units of rectangular−window main−lobe widths
• β is equal to 1/2 ‘timebandwidth product’
• β trades oﬀ side lobe level for main lobe width larger β ⇒ lower S.L.L., wider mainlobe
35
W(ω _{k} ) =
^{M}
sinh β ^{2} − ^{M}^{ω} ^{k}
2
2 ^{}
_{0} (β)
I
_{β} _{2} _{−} ^{} Mω _{k}
2
2
where I _{0} is a Bessel function of the ﬁrst kind, and is equal to
∞
∆
I _{0} (x) =
^{} (x/2) ^{k} k!
(x/2) ^{k}
k=0
∞
k=0
(Compare this with e ^{x}^{/}^{2} =
k!
2
.)
Note: Sometimes you see the Kaiser window parameterized by α where β = πα
∆
34
β = [0, 2, 4, 6, 8, 10]
Length 50 Kaiser windows, 6 betas between 0 and 10
Time (samples)
36
dB
dB
dB
dB
dB
dB
dB
dB
dB
dB
β = [0, 2, 4, 6, 8, 10]
Length 50 Kaiser windows, 6 betas between 0 and 10
Normalized Frequency (cycles per sample)
37
Kaiser Windows and Transforms
39
M
= [20, 30, 40, 50]
Kaiser window transforms, 4 window lengths between 20 and 50, beta=4
Normalized Frequency (cycles per sample)
38
Chebyshev
Minimize the Chebyshev norm of the side lobes:
∆
min _{w} sidelobes(W ) _{∞} = min _{w} {max _{ω}_{>}_{ω} _{c} W(ω)}
Alternatively, minimize main lobe width subject to a
sidelobe spec:
max (ω _{c} )
w
^{} W (ω) ≤ c _{α} , ∀ω≥ω _{c}
ClosedForm Window Transform:
_{W}_{(}_{ω} k _{)} _{=} cos ^{} M cos ^{−}^{1} ^{} β cos ^{} ^{π}^{k}
M
cosh ^{} M cosh ^{−}^{1} (β) ^{}
β
= cosh _{M} cosh ^{−}^{1} (10 ^{α} ) ,
1
, (k ≤ M − 1)
(α ≈ 2, 3, 4)
[Note error in text, which says “β = cosh ^{−}^{1} [· · · ]”]
• Window w = IDFT(W ) [zerophase case]
or IDFT of (−1) ^{k} W(ω _{k} ) for causal case
• α controls sidelobe level (“stopband ripple”):
SideLobe Level in dB = −20α.
• smaller ripple ⇒ larger ω _{c}
• see matlab function “chebwin(M,ripple)”
• also called the DolphChebyshev Window
40
Chebyshev Window, Length 31, Ripple 40 dB
Length 31 Chebyshev window
Normalized Frequency (cycles/sample)
41
Chebyshev Window, Length 101, Ripple 40 dB
Length 101 Chebyshev window
Normalized Frequency (cycles/sample)
43
Chebyshev Window, Length 31, Ripple 200 dB
Length 31 Chebyshev window
Normalized Frequency (cycles/sample)
42
Chebyshev and Hamming Windows Compared
DFT of Chebyshev and Hamming Window: M = 31, Ripple = −42 dB
Normalized Frequency (rad/sample)
For the comparison, we set the ripple parameter for chebwin to 42 dB:
window
=
[
chebwin(31,42)’
44
zeros(1,102431)
];
Gaussian
The Gaussian “bell curve” is the only smooth function that transforms to itself:
1
σ _{√} 2π _{e} −t ^{2} _{/} 2σ ^{2} _{↔} _{e} −ω ^{2} _{/} 2(1/σ) ^{2}
It also achieves the minimum timebandwidth product
σ _{t} σ _{ω} = σ × (1/σ) = 1
when “width” of a function is deﬁned as the square root of its second central moment. For even functions w(t),
σ t
=
∆
−∞
∞
t
^{2} w(t)dt.
• Since the true Gaussian function has inﬁnite duration, in practice we must window it with some ﬁnite window, or at least truncate it.
• Philippe Depalle suggests using a triangular window raised to some power α for this purpose.
• This choice preserves the absence of sidelobes for suﬃciently large α. • It also preserves nonnegativity of the transform
45
Gaussian Window and Transform
Gaussian Window, M = 21, Sigma = M/8
Time (samples)
47
The Gaussian Window in Spectral Modeling
Special Property: On a dB scale, the Gaussian is quadratic ⇒ parabolic interpolation of a sampled
Gaussian transform
Conjecture: Quadratic interpolation of spectral peaks is generally more accurate on a logmagnitude scale (e.g., dB) than on a linear magnitude scale. This has been veriﬁed in a number of cases, and no counterexamples are yet known. Exercise: Prove this is true for the rectangular window.
is
exact.
Matlab for the Gaussian Window
function
[w]
=
gausswin(M,sigma)
n=((M1)/2:(M1)/2)’;
w
=
exp(n.*n./(2*sigma.*sigma));
46
Optimal Windows
Generally we desire
W(ω) ≈ δ(ω)
• Best results are obtained by formulating this as an FIR ﬁlter design problem.
• In general, both timedomain and frequencydomain speciﬁcations are needed.
• Equivalently, both magnitude and phase speciﬁcations are necessary in the frequency domain.
48
Optimal Windows for Audio Coding
Recently, numerically optimized windows have been developed by Dolby which achieve the following objectives:
• Narrow the window in time
• Smooth the onset and decay in time
• Reduce sidelobes below the worstcase masking threshold
Windows in Graphics
^{1} http://www.cg.tuwien.ac.at/studentwork/CESCG99/TTheussl/paper.html
49
Conclusion
• There is rarely a closed form expression for an optimal window in practice.
• The hardest task is formulating the ideal error criterion.
• Given an error criterion, it is usually straightforward to minimize it numerically with respect to the window samples w.
50
Much more than documents.
Discover everything Scribd has to offer, including books and audiobooks from major publishers.
Cancel anytime.