lecture02 stft

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform...

0 downloads 66 Views 9MB Size
Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Introduction of Fourier Analysis and Time-frequency Analysis Li Su

February 13, 2017

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Fourier analysis

“Mathematics compares the most diverse phenomena and discovers the secret analogies that unite them.” – Joseph Fourier (1768 – 1830)

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Frequency and spectrum I

Signal model: a signal f (t) ∈ R contains components of different frequencies

I

For physical meaning, the term “frequency” is defined in terms of sinusoidal function cos(ωt) and sin(ωt), where ω is the angular frequency (rad/s)

I

The spectrum shows the intensity and phase of the sinusoidal functions composing f (t)

I

Fourier analysis facilitates this model

I

Fourier analysis is a classic method of retrieving the spectrum of a signal

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Fourier series I

A periodic signal f (t) ∈ R can be represented in terms of an infinite sum of sines and cosines. ∞ ∞ X X f (t) = a0 + an cos(ωn t) + bn sin(ωn t) (1) n=1

Z

π

a0 =

f (t)dt, −π

I

I

Z

n=1 π

Z

an =

f (t) cos(ωn t)dt, −π

π

bn =

f (t) sin(ωn t)dt −π

The frequencies of these sines and cosines are constructed by a harmonic series, containing a fundamental frequency (i.e., ω0 ) and its integer multiples (harmonics); ωn = nω0 . These sines and cosines form an orthogonal basis, and the Fourier coefficients are the projection of f (t) on the basis. Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Illustration A synthetic viewpoint:

From: M. Mueller, “Fundamentals of Music Processing,” Chapter 2, Springer 2015

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Example: a note C4 played on a piano I

Fundamental frequency f0 = 261.6 Hz

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Physical interpretation For a bounded vibrating string with length L: I

Fundamental mode with wavelength λ0 = L2

I

Fundamental frequency f0 = 2v L

I

1st harmonic frequency 2f0

I

2nd harmonic frequency 3f0

I

Pitched musical signal → f0 + higher order harmonics → periodic Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

More examples (a) Piano (b) Trumpet (c) Violin (d) Flute

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Phase We can write Equation (1) as f (t) = a0 +

∞ q X an2 + bn2 cos(ωn t + φn )

(2)

n=1

where φn = tan−1

bn an

(3)

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Phasor, complex number, and negative frequency We can also write Equation (1) as f (t) = a0 +

∞ X cn n=1

2

e jωn t +

c¯n −jωn t e 2

(4)

where e jωn t = cos(ωn t) + j sin(ωn t), cn = an + jbn I

When written in phasor forms, a real-valued signal is decomposed into components with positive and negative frequencies

I

For real-valued signals (e.g., most of the audio signals), negative frequencies are redundant

I

For complex-valued signals, negative frequencies are informative Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Fourier transform I

The Fourier transform is a generalization of the Fourier series, by changing the sum to an integral.

I

A signal f (t) ∈ R can be represented as Z ∞ F (ω) = f (t)e −jωt dt ,

(5)

−∞ I

The inverse Fourier transform Z ∞ f (ω) = F (ω)e jωt dω .

(6)

−∞ I

Denote F (ω) = Ff (t) and f (t) = F −1 F (ω) Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Example (1): impulse

The Dirac delta function ( 1, f (t) = δ(t) = 0, Z



F (ω) =

t = 0, t 6= 0.

δ(t)e −jωt dt = e −jω·0 = 1 .

(7)

(8)

−∞

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Example (2): cosine

f (t) = cos(ηt) Z ∞ F (ω) = cos(ηt)e −jωt dt −∞ Z ∞ = cos(ηt) cos(ωt)dt −∞ Z ∞ − j cos(ηt) sin(ωt)dt

(9)



1 = 2

 for

ω = ±η

(= 0)

−∞

=

1 1 δ(ω − η) + δ(ω + η) 2 2

(10)

It is also evident that Fe jηt = δ(ω − η) Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Example (3): rectangular pulse ( 1, − T2 < t < T2 , f (t) = (11) 0, others Z T 2 −1 −jωt T2 F (ω) = e −jωt dt = e − T2 jω −T 2

sin T ω = ω

(12)

In a weak sense, lim F (ω) = δ(ω)

T →∞

lim f (t) = δ(t)

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015

T →0

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Example (4): Gaussian

2

f (t) =e −at Z ∞ 2 F (ω) = e −at e −jωt dt −∞ ∞

Z =

e

−at 2

Z



cos(ωt)dt− j

−∞

e

−at 2

r sin(ωt)dt =

−∞

π − ω2 e 4a . 2a (13)

(odd function!)

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Example (4): Gaussian (cont’d) I

The Fourier transform of a Gaussian is still a Gaussian

I

f (t) = e − 2 is an eigenfunction of the Fourier transform

I

We also have limT →∞ F (ω) = δ(ω) and limT →0 f (t) = δ(t)

t2

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Translation and modulation I

Shifted by t0 in the time domain → multiplied by a phase shift in the frequency domain

I

Modulated by e jω0 t in the time domain → shifted by ω0 in the frequency domaiin

Z f (t − t0 )e Z

−jωt

Z

f (u)e −jω(t0 +u) dt = e −jωt0 F (ω)(14)

Z

f (t)e −j(ω−ω0 )t dt = F (ω − ω0 )(15)

dt =

f (t)e jω0 t e −jωt dt =

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Convolution

Convolution of f (t) and g (t): Z



f (t) ∗ g (t) =

f (τ )g (t − τ )dτ

(16)

−∞

The convolution theorem: for F (ω) = Ff (t) and G (ω) = Fg (t) then F (f (t) ∗ g (t)) = F (ω)G (ω)

Li Su

(17)

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Fourier Series Fourier transform Examples

Magnitude spectrum, additivity and interference I

Magnitude spectrum: |F (ω)|

I

If f (t) = fA (t) + fB (t), then F (ω) = FA (ω) + FB (ω)

I

But |F (ω)| = 6 |FA (ω)| + |FB (ω)|!

I

Constructive interference and destructive interference

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Sampling Quantization Spectral leakage

Sampling I I

Sampling: make a continuous-time signal be discrete-time A discrete-time signal x(n), n ∈ Z, sampled from f (t), t ∈ R, by a sampling period T x(n) = f (nT )

I I

(18)

Sampling frequency fs = T1 , we have n = tfs Audio signals: fs = 8 kHz, 16 kHz, 22.05 kHz, 44.1 kHz, etc. I

T =?

I

fs =?

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Sampling Quantization Spectral leakage

Aliasing I

Limited sampling rate implies limited information of the spectrum

I

Nyquist-Shannon sampling theorem: if the highest frequency of a signal f (t) is fh , then the signal can be perfectly reconstructed by a sampled signal with sampling rate of at least 2fh

I

If sampling rate smaller than 2fh : aliasing From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Sampling Quantization Spectral leakage

Quantization I

Quantization – make a analog-value signal digital

I

Bit depth: number of bits of information in each sample

I

Example: bit depth = 4

I

Audio signals: 16-bit, 24-bit or more

I

For an audio signal with 2-channel, 16-bit and sampling rate 44.1 kHz, what is its bit rate?

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Sampling Quantization Spectral leakage

Types of signal

Can you tell the difference among the following terms? I

Continuous (連續)

I

Analog (類比)

I

Discrete (離散)

I

Digital (數位)

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Sampling Quantization Spectral leakage

Spectral leakage I

We are never able to measure a signal of infinite length

I

Fourier transform on a finite support [TA , TB ]: Z

TB

F (ω) =

f (t)e −jωt dt

TA I

Spectral leakage: the spectrum of a sinusoidal function is never a impulse

I

Heisenberg’s uncertainty: better localization in time implies worse localization in frequency Li Su

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Discrete Fourier Transform (DFT) Interpretation of DFT Examples Fast Fourier transform (FFT)

DFT For a discrete-time signal (usually sampled from a continuous-time signal) ~x ∈ RN , x = [x(0), x(1), . . . , x(N − 1)] X (k) =

N−1 X

x(n)e −

j2πkn N

(19)

0

Let X ∈ RN , X = [X (0), X (1), . . . , X (N − 1)] and ω = − j2π N

X = Fx,

 1 1  F = .  ..

1 ω .. .

1 ω2 .. .

··· ··· .. .

1 ω (N−1) .. .

1 ω N−1 ω 2(N−1) · · · ω (N−1)(N−1) Li Su

    (20) 

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Discrete Fourier Transform (DFT) Interpretation of DFT Examples Fast Fourier transform (FFT)

Interpretation of DFT (1) The discrete Fourier transform approximates the continuous Fourier transform (Riemann sum approximation) xˆ(ω) =

X

=

X

x(n)e −jωn

n∈Z

f (nT )e −jωn

n∈Z

Z ≈

f (nT )e −jωt dt

t∈R

Z jωt 1 f (nT )e − T dt T t∈R 1 ω = F (21) T T =

Li Su

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Discrete Fourier Transform (DFT) Interpretation of DFT Examples Fast Fourier transform (FFT)

Interpretation of DFT (2) I

Frequency resolution =

I

When N is even: X (0) =

X (1) =

N−1 X n=0 N−1 X

fs N

(the distance between two bins)

x(n) x(n)e −

f =0 j2πn N

=

n=0

N−1 X

fs

x(n)e −j2π( N t ) f =

n=0

fs N

.. .  X

N −1 2

 =

N−1 X

x(n)e −

j2πn · N2 −1 N

n=0 Li Su

(

)

f =

fs fs − 2 N

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Discrete Fourier Transform (DFT) Interpretation of DFT Examples Fast Fourier transform (FFT)

Interpretation of DFT (3)



N 2



N +1 2



X  X

=

=

N−1 X n=0 N−1 X

fs 2

x(n)e −

j2πn · N2 N

x(n)e −

j2πn · N2 −1 N

f =−

fs fs + 2 N

x(n)e −

j2πn · N2 −1 N

f =−

fs N

( )

(

f = )

n=0

.. . X (N − 1) =

N−1 X n=0

Li Su

(

)

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Discrete Fourier Transform (DFT) Interpretation of DFT Examples Fast Fourier transform (FFT)

Example (1): normal case A chirp signal f (t) := sin(0.003πt 2 ) for t ≥ 0

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Discrete Fourier Transform (DFT) Interpretation of DFT Examples Fast Fourier transform (FFT)

Example (2): aliasing A chirp signal f (t) := sin(0.004πt 2 ) for t ≥ 0

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Discrete Fourier Transform (DFT) Interpretation of DFT Examples Fast Fourier transform (FFT)

Example (3): approximation property

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Discrete Fourier Transform (DFT) Interpretation of DFT Examples Fast Fourier transform (FFT)

Fast Fourier transform (FFT)

I

Complexity of N-point DFT: O(N 2 )

I

Cooley-Tukey FFT algorithm: O(N log N)

I

Utilizing the redundancy of the DFT matrix F

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Discrete Fourier Transform (DFT) Interpretation of DFT Examples Fast Fourier transform (FFT)

Algorithm

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Non-stationarity of signals I

Fourier analysis assumes that the amplitude/frequency/phase of a signal do not change over time

I

But this never happens in real world

I

Music is non-stationary: onset, offset, pitch change, etc. X f (t) = Am (t) cos(ωm (t)t + φm (t)) (22) m

I

How to model the temporal dynamics of a non-stationary signal?

I

How to model time and frequency information at the same time? Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Example

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Short-Time Fourier Transform (STFT) I

Dennis Gabor (1900 – 1979)

I

Nobel Prize in Physics (1971)

I

Known for Holography, Time-frequency analysis, etc.

– Google Doodle on June 5, 2010

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Short-Time Fourier Transform (STFT)

I

Short-time Fourier transform (STFT): capture local information through a sliding window function h(t) Z (h) Sx (t, ω) = x(τ )h(τ − t)e −jωτ dτ,

I

Also have magnitude and phase

I

Spectrogram: |Sx |2

(23)

(h)

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Sliding window and short-time spectrum

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Window function I

I I

For better temporal continuity, better control of spectral leakage and less ripple artifacts (than using rectangular window)  Hann window: h(t) = 21 + 12 cos 2πn , n = − N2 , . . . , N2 N Comparison of rectangular, triangular and Hann windows:

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Illustration (1): window type Hann window (up) and rectangular window (bottom)

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Illustration (2): window length Short Hann window (32 ms, up) and long Hann window (128 ms, bottom)

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Illustration (3): scaling Spectrogram and dB-scaled spectrogram of a scale played with the piano

From: M. Mueller, Fundamentals of Music Processing, Chapter 2, Springer 2015 Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Implementation of STFT (1) I

Slice the signal into frames of segments

I

Multiply the short segments by a window function Do FFT for each segment!

I

From: http://zone.ni.com/reference/en-XX/help/371361J-01/lvanls/stft_spectrogram_core/

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Implementation of STFT (2) I

Discrete STFT: X (n, k) =

N−1 X

x(m + nH)h(m)e −

j2πkm N

(24)

m=0 I

H: time step (hop size)

I

The index k corresponds to the frequency f (k) :=

I

The index n corresponds to the time t(n) :=

I

Example: for an audio signal sampled at fs = 44.1 kHz, use window size N = 4096 samples and hop size H = 1024 samples. Could you specify the time-frequency grid in the STFT representation? Li Su

kfs N

nH fs

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Example (1): piano solo

fs = 44.1 kHz, H = 441, N = 4096 (left) and N = 1024 (right)

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Example (2): voice

fs = 44.1 kHz, H = 441, N = 4096 (left) and N = 1024 (right)

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Example (3): rock

fs = 44.1 kHz, H = 441, N = 4096 (left) and N = 1024 (right)

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis

Fourier Analysis Basics of Digital Signal Processing (DSP) Discrete Fourier Transform (DFT) Short-Time Fourier Transform (STFT)

Non-stationary signals Short-Time Fourier Transform (STFT) Implementation Examples

Example (4): symphony

fs = 44.1 kHz, H = 441, N = 4096 (left) and N = 1024 (right)

Li Su

Introduction of Fourier Analysis and Time-frequency Analysis