short time fourier transforms outline chapters from the book outline

11
Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT) Audio Information Retrieval: Short Time Fourier Transforms C. G. v. d. Boogaart R. Lienhart Multimedia Computing Lab University of Augsburg {boogaart,lienhart}@multimedia-computing.org www.multimedia-computing.org Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT) Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT) Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT) Chapters from the book This chapter inherits from the following chapters from [Oppenheim et al., 1999]: 8 The Discrete Fourier Transform ((8.1 - 8.4), 8.5 - 8.8) 9 Computation of the Discrete Fourier Transform (brief overview) 10 Fourier Analysis of Signals Using the Discrete Fourier Transform (10.1 - 10.5) 7.2 Design of FIR Filters by Windowing Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT) Outline Preface Discrete Fourier Transform (DFT) From the DTFT to the DFT Properties Circular and Linear Convolution Discrete Cosine Transform (DCT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Upload: dohuong

Post on 01-Jan-2017

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Audio Information Retrieval: Short Time FourierTransforms

C. G. v. d. Boogaart R. Lienhart

Multimedia Computing LabUniversity of Augsburg

{boogaart,lienhart}@multimedia-computing.org

www.multimedia-computing.org

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Outline

Preface

Discrete Fourier Transform (DFT)

Fast Computation of the DFT

Short Time Fourier Transform (STFT)

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Chapters from the book

This chapter inherits from the following chapters from[Oppenheim et al., 1999]:

• 8 The Discrete Fourier Transform ((8.1 - 8.4), 8.5 - 8.8)

• 9 Computation of the Discrete Fourier Transform (briefoverview)

• 10 Fourier Analysis of Signals Using the Discrete FourierTransform (10.1 - 10.5)

• 7.2 Design of FIR Filters by Windowing

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Outline

Preface

Discrete Fourier Transform (DFT)From the DTFT to the DFTPropertiesCircular and Linear ConvolutionDiscrete Cosine Transform (DCT)

Fast Computation of the DFT

Short Time Fourier Transform (STFT)

Page 2: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

From the DTFT to the DFTFrom the DTFT to the Discrete Fourier Series

We already discussed the discrete-time Fourier transform (DTFT):

X (ejω) =∞∑

n=−∞x [n]e−jωn (1)

and the inverse (IDTFT):

x [n] =1

∫ π

−πX (ejω)ejωndω (2)

where the signal is discrete and its Fourier transform is continuous(and periodic). Both extend to infinity. For processing finite lengthsequences, the discussion of periodic sequences is necessary. Thisleads to the discrete Fourier series (DFS).

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

From the DTFT to the DFTDiscrete Fourier Series (DFS)

The pair of DFS analysis and synthesis equations is given asfollows:

X̃ [k] =N−1∑n=0

x̃ [n]e−j 2πknN (3)

x̃ [n] =1

N

N−1∑k=0

X̃ [k]ej 2πknN (4)

x̃ [n] and X̃ [k] are discrete, periodic with period N and extend toinfinity. With ·̃ we emphasis the periodicity.For the pair of corresponding sequences we write:

x̃ [n]DFS←→ X̃ [k] (5)

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

From the DTFT to the DFTDiscrete Fourier Series (DFS)

For each periodic sequence x̃ [n] a corresponding finite lengthsequence x [n] exists. It is recovered as follows:

x [n] =

{x̃ [n] : 0 ≤ n ≤ N − 1

0 : otherwise. (6)

The corresponding transforms x̃ [n]DFS←→ X̃ [k] and

x [n]DTFT←→ X (ejω) have the following relationship:

X̃ [k] = X (ejω)|ω=2πk/N = X (ej 2πkN ) . (7)

I.e. X̃ [k] is a sampled version of X (ejω) sampled at N equallyspaced frequencies with frequency spacing of 2π/N.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

From the DTFT to the DFTFrom the DFS to the DFT

• When the discrete Fourier series is used to representfinite-length sequences, it is called the discrete Fouriertransform (DFT).

• The representation of the DFT through samples of the DTFTis in effect a representation of the finite-duration sequence bya periodic sequence.

• One period of the periodic sequences represent thecorresponding finite-duration sequence.

Page 3: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

From the DTFT to the DFTDiscrete Fourier Transform (DFT)

The finite-length sequence x [n] can be obtained from the periodicsequence x̃ [n] with:

x [n] =

{x̃ [n] : 0 ≤ n ≤ N − 1

0 : otherwise. (8)

Accordingly producing a periodic sequence out of a sequence oflength N can be written as:

x̃ [n] = x [(n modulo N)] . (9)

This is abbreviated with the following notation:

x̃ [n] = x [((n))N ] . (10)

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

From the DTFT to the DFTDiscrete Fourier Transform (DFT)

The fully analog dependencies in both directions are also true forX [k] and X̃ [k]:

X [k] =

{X̃ [k] : 0 ≤ n ≤ N − 1

0 : otherwise(11)

X̃ [k] = X [(k modulo N)] (12)

X̃ [k] = X [((k))N ] (13)

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

From the DTFT to the DFTDiscrete Fourier Transform (DFT)

The pair of DFT analysis and synthesis equations is given asfollows:

X [k] =N−1∑n=0

x [n]e−j 2πknN (14)

x [n] =1

N

N−1∑k=0

X [k]ej 2πknN . (15)

We writex [n]

DFT←→ X [k] . (16)

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

From the DTFT to the DFTDiscrete Fourier Transform (DFT)

Remarks:

• With X [k] = 0 for k outside the interval 0 ≤ k ≤ N − 1 andx [n] = 0 for n outside the interval 0 ≤ n ≤ N − 1 by definition.

• However if the equations are evaluated for values outsidethose intervals, the result will not be zero, but a periodicextension of the sequences. The periodicity is always present.

• These facts have important influence on the properties of theDFT and on how modifications of X [k] effect x [n].

Page 4: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Properties(Circular) Shift

A time shifted sequence and its DTFT have the relationship:

x [n −m]DTFT←→ e−jωmX (ejω) . (17)

We are interested in the equivalent property for the DFT.Therefore we want to determine x̂ [n] in the relationship:

x̂ [n]DFT←→ X̂ [k] = e−j(2πk/N)mX [k] . (18)

It can be show that it holds:

x̂ [n] =

{x [((n −m))N ] : 0 ≤ n ≤ N − 1

0 : otherwise. (19)

I. e. the equivalent is a circular shift.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Properties(Circular) Shift

Figure: Illustration of the circular shift. [Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

PropertiesDuality

Frequency and time representations of sequences in the DFT sensehave a strong duality property.If the (forward) DFT of x [n] is X [k]

x [n]DFT←→ X [k] , (20)

then the (forward) DFT of the sequence X [n] is:

X [n]DFT←→ Nx [((−k))N ], 0 ≤ k ≤ N − 1 . (21)

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

PropertiesCircular Convolution

Given two finite-duration sequences of length N:

x1/2[n]DFT←→ X1/2[k] . (22)

Forx3[n]

DFT←→ X3[k] = X1[k]X2[k] (23)

it holds (for 0 ≤ n ≤ N − 1):

x3[n] =N−1∑m=0

x1[m]x2[((n −m))N ]. (24)

The operation is called N-point circular convolution. It is notidentically to the (linear) convolution introduced earlier.

Page 5: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Figure: Circular convolution with N = 2L. [Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Figure: Circular convolution with N = L. [Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Figure: Summary of Properties of the DFT. WN = e−j(2π/N).[Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Circular and Linear Convolution

Efficient algorithms are available for computing the DFT.Therefore it is computationally efficient to implement aconvolution of two sequences by the following procedure:

1. Compute the DFTs X1[k] and X2[k] of the sequences x1[n]and x2[n].

2. Compute the product X3[k] = X1[k] X2[k].

3. Compute x3[n] as the inverse DFT of X3[k].

Normally we are interested in a linear convolution of twosequences, e.g. for implementing a linear system.

Page 6: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Circular and Linear Convolution

We have a sequence x1[n] of length L and a sequence x2[n] oflength P.

• The sequence x3[n] = x1[n] ∗ x2[n] obtained by linearconvolution has a maximum length of L + P − 1.

• A circular convolution (with periodic N) can be different fromthe linear convolution, if time aliasing occurs. Examples:

N ≥ L + P − 1: Time aliasing is avoided. Circular and linearconvolution are identical.

N = L = P: Time aliasing occurs in all values.N = L > P: Time aliasing occurs in P − 1 values, the rest

N − (P − 1) are not corrupted.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Circular and Linear ConvolutionImplementing a LTI

• In order to implement a LTI, we want to realize a linearconvolution of the signal x [n] (length N) with the relativelyimpulse response h[n] (length P) of the LTI.

• Therefore we can use a DFT of length N with N ≥ L + P − 1.x [n] and h[n] have to be zero-padded.

• This introduces two problems:

1. For long signals N becomes very large.2. A very long system delay is introduced.

• Splitting the signal in blocks and applying block convolutionsolves this.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Circular and Linear ConvolutionImplementing a LTI

Block convolution can be implemented with two strategies:

1. Overlap-add:• The signal is split in non overlapping blocks of length L.• A convolution with a N ≥ L + P − 1 DFT is applied.• The results from different blocks overlap by P − 1. They are

added to generate the full result.

2. Overlap-save:• The signal is split in blocks of length L overlapping by P − 1.• A convolution with a N = L DFT is applied.• The non corrupted part of the result of length L− (P − 1)

each are concatenated.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Figure: Block convolution: overlap-add, overlap-save.[Oppenheim et al., 1999]

Page 7: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Discrete Cosine Transform (DCT)

• The DFT represents a signal in terms of complex exponentialfunctions.

• The discrete cosine transform (DCT) represents an even signalin terms of cosines. An arbitrary signal has to be made even(at least implicitly) before its DCT can be computed.

• Several different forms exist to make a signal even, resulting inseveral forms of the DCT.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Figure: Generating even sequences out of arbitrary sequences for theDCT. [Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Discrete Cosine Transform (DCT)

• The DCT-2 is used in data compression applications becauseof a property called“energy compaction”.

• The DCT-2 of a finite-length sequence often has itscoefficients more highly concentrated at low indices than theDFT does. It is nearly optimum in some sense for sequencesfulfilling a certain property.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Outline

Preface

Discrete Fourier Transform (DFT)

Fast Computation of the DFT

Short Time Fourier Transform (STFT)

Page 8: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Fast Computation of the DFT

• In terms of multiplications and additions a direct calculationof the DFT has a complexity of O(N2).

• Algorithms with lower complexity exist.• In case only some values of the DFT are needed: Goertzel

algorithm.• For N a power of 2: The standard fast Fourier transform

(FFT) with complexity O(N log N). “Butterfly”.• For N a product of primes: Generalized FFT.• And perhaps more.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Figure: Typical flowchart for FFT computation with bit-reversedindexing. [Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Outline

Preface

Discrete Fourier Transform (DFT)

Fast Computation of the DFT

Short Time Fourier Transform (STFT)Window FunctionsTime-Bandwidth ProductComputation

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Short Time Fourier Transform (STFT)

• To apply the DFT to a real signal, we can:

1. Calculate one DFT for the whole signal (impractical, especiallyfor long signals).

2. Split the signal into blocks and calculate a DFT for each block(see block convolution).

• The STFT uses the second possibility:• The signal is split into blocks of equal length.• The blocks are overlapping, by e.g. 50 %.• Each block is windowed, i.e. multiplied with smooth function,

which nearly vanishes near the edges.

Page 9: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Window Functions

Typical window functions are (all = 0 outside the interval0 ≤ n ≤ M):

Rectangular: w [n] = 1, 0 ≤ n ≤ M

Bartlett(triangular)

Hann, Hanning: w [n] = 0.5− 0.5 cos(2πn/M), 0 ≤ n ≤ M

Hamming: w [n] = 0.54− 0.46 cos(2πn/M), 0 ≤ n ≤ M

Blackman: w [n] = 0.42− 0.5 cos(2πn/M) +0.08 cos(4πn/M), 0 ≤ n ≤ M

Kaiser: w [n] =I0[β(1−[(n−M

2)/ M

2]2])1/2

I0(β) , 0 ≤ n ≤ M with I0(•)the zeroth-order modified Bessel function of the firstkind. Rectangular for β = 0, Gauss for β →∞.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Window Functions

Figure: Shape of the windows. [Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Window Functions

Figure: Log magnitude of the Fourier transforms of the windows.[Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Window Functions

Figure: Kaiser window for different parameters. [Oppenheim et al., 1999]

Page 10: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Window Functions

Figure: Comparison of some properties of the windows.[Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Time-Bandwidth Product

• Longer windows lead to higher frequency resolution and tomore smoothing in time direction and vice versa.

• Windows therefore introduces are trade-off between time andfrequency resolution.

• This leads to the uncertainty principle of information theory(Heisenberg). It says that the product of temporal andfrequency extent of a window function has a total lower limit(see [Rioul and Vetterli, 1991]):

σtσf ≥1

4π. (25)

The“=” is only reached for the Gaussian window function (seee.g. [Tipler, 1994]), which therefore has the minimal possibleextent in the time-frequency plane.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Figure: STFT of a speech signal with short window length.[Oppenheim et al., 1999]

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Figure: STFT of a speech signal with long window length.[Oppenheim et al., 1999]

Page 11: Short Time Fourier Transforms Outline Chapters from the book Outline

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Computation

X [l , k] =M−1∑0=n

x [n]w [n − l(M/q)]e−j2πk(n−l(M/q))

M (26)

x [n] =1

qL

+∞∑l=−∞

M−1∑k=0

X [l , k]ej2πk(n−l(M/q))

M (27)

with

L =+∞∑

n=−∞w [n] =

M−1∑n=0

w [n] (28)

q = 1/overlapping (29)

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Computation

A very typical setting of the STFT in audio signal processing oraudio information retrieval would be:

• Hamming window.

• 50 % overlapping (i.e. q = 2).

• M = 1024 (or similar).

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Gabor Transform

• The Gaussian window is the optimum in terms oftime-frequency resolution according to the Heisenberguncertainty principle.

• The Gaussian window is also called Morlet Wavelet.

• A signal transform with the Gaussian window, which is verysimilar to the STFT, is called Gabor transform [Gabor, 1946].

• Is has the smallest main lobe of all windows (i.e. like theKaiser window for β →∞ and ideally (with no truncation orvery late truncation) no side lobe.

• The Gabor transform needs more overlapping (calledoversampling factor) than a STFT with a standard window.

Outline Preface Discrete Fourier Transform (DFT) Fast Computation of the DFT Short Time Fourier Transform (STFT)

Gabor, D. (1946).Theory of communication.Journal of the Institution of Electrical Engineers, pages429–457.

Oppenheim, A. V., Schafer, R. W., and Buck, J. R. (1999).Discrete-time signal processing.Prentice-Hall, Inc., Upper Saddle River, NJ, USA, 2nd edition.

Rioul, O. and Vetterli, M. (1991).Wavelets and signal processing.IEEE Signal Processing Magazine, 8(4):14–38.

Tipler, P. A. (1994).Physik.Spektrum Akademischer Verlag, Heiderlberg, Berlin.