Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse...

25
Time Frequency Representation Juan Pablo Bello MPATE-GE 2623 Music Information Retrieval New York University

Transcript of Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse...

Page 1: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Time Frequency Representation

Juan Pablo BelloMPATE-GE 2623 Music Information RetrievalNew York University

Page 2: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Discrete Signal and Sampling

x(t)

p(t)

x̂(tn) = Q(x(t)! p(t))

Page 3: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

X(!)x(t)

p(t)

x̂(tn)

P (!)

X̂(!k)

Page 4: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Aliasing

X(!)

P (!)

X(!)

P (!)

X̂(!k) X̂(!k)

Page 5: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Aliasing

! = 2"f

!k = 2"(fs ! f)

Page 6: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Discrete Fourier Transform (DFT)

X(!k) !!N!1

n=0 x(tn)e!j!ktn

x = input signaltn = n

fs = discrete time (s), n " 0 is an integer

fs = sampling rate (Hz)X = spectrum of x!k = k! = discrete frequency (rad/s), k " 0 is an integer! = 2"( fsN ) = frequency sampling interval (rad/s)N = number of time/frequency samples

Simple form :

X(k) !!N!1

n=0 x(n)e!j2"nk/N

Page 7: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Discrete Fourier Transform (DFT)

!

"""#

X(0)X(1)...

X(N ! 1)

$

%%%&=

!

"""#

s!0(0) s!0(1) · · · s!0(N ! 1)s!1(0) s!1(1) · · · s!1(N ! 1)...

.... . .

...s!N"1(0) s!N"1(1) · · · s!N"1(N ! 1)

$

%%%&

!

"""#

x(0)x(1)...

x(N ! 1)

$

%%%&

This can also be written as:

X(k) = !x(n), sk(n)"

Which can be formulated as a matrix multiplication:

Page 8: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Discrete Fourier Transform (DFT)

Real part Imaginary partwhere,

sk(n) = ej2!nk/N = cos(2!nk/N) + jsin(2!nk/N)

is the set of the sampled complex sinusoids witha whole number of periods in N samples (Smith, 2007).

Page 9: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Discrete Fourier Transform (DFT)

The N resulting X(k) are complex-valued vectorsXR(k) + jXI(k) such that, !k = 0, 1, · · · , N " 1:

|X(k)| =!

X2R(k) +X2

I (k)

!X = !(k) = tan!1 XI(k)XR(k)

Furthermore, if x(n) is real-valued, then:

X(k) = X"(N " k)

The DFT of an audio signal is half-redundant!

Page 10: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Discrete Fourier Transform (DFT)

Conjugate PairsSpectrum

Page 11: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

The IDFT and FFT

• The Inverse DFT (IDFT) is defined as:

• The DFT needs on the order of N2 operations for its computation.

• The Fast Fourier Transform (FFT) is an efficient implementation of the DFT, that only requires on the order of Nlog2N operations when N is a power of 2.

• The FFT is so fast that it can be used to efficiently perform time-domain operations such as convolution.

x(n) ! 1

N

N!1!

k=0

X(k)ej2!nk/N , n = 0, 1, · · · , N " 1

Page 12: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Spectral Leakage

glitch

Whole number of periods Fractional number of periods

N N

Leakage

Page 13: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Zero padding

N-long signal Zero padded to 8xN length

Spectrum Interpolated Spectrum

Page 14: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Windows

• We are effectively using a rectangular window: w(n)

• Spectrum = convolution of X(k) and W(k)

• Ideal window: narrow central lobe; strong attenuation in sidebands

• Figures show Magnitude in dB:

dB(X) = 20! log10(X)

Page 15: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Windowing

Page 16: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Short-Time Fourier Transform (STFT)

hop size

N

!n(k)

|Xn(k)|

Page 17: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Spectrogram

Page 18: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Time vs Frequency Resolution

frequency ↑time ↓

frequency ↓time ↑

Page 19: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Instantaneous Frequency

2!k

N

The instantaneous frequency for frequency bin k at timeinstant mh can be defined as (Arfib et al., 2003):

fi, k(m) = 12!

d"k(m)dt = 1

2!!"k(m)h/fs

where,

!!k(m) = "kh+ princarg[!k(m)! !k(m! 1)! "kh]

and

princarg(x) = " + [(x+ ")mod(!2")]

wraps the phase to the (!","] range.

Page 20: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Instantaneous Frequency

Page 21: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Instantaneous Frequency

Page 22: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

• The signal is approximated as a sum of time-varying sinusoidal components plus a residual:

Sinusoidal Modeling

x(n) !!K

k=0 ak(n)cos(!k(n)) + e(n)

where,

ak = instantaneous amplitude!k = instantaneous phasee(n) = residual (noise)

Page 23: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Peak picking + interpolation

•Sinusoidal components are peak-picked.•Instantaneous magnitude and phase values are obtained by interpolation.•Components are tracked over time

Page 24: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

Sinusoidal tracking

Page 25: Time Frequency Representation - nyu.edu · Discrete Fourier Transform (DFT) X ... •The Inverse DFT (IDFT) is defined as: ... operations such as convolution. x(n) ...

References

• Smith, J.O. “Mathematics of the Discrete Fourier Transform (DFT). 2nd Edition, W3K Publishing (2007)

• Zölzer, U. (Ed). “DAFX: Digital Audio Effects”. John Wiley and Sons (2002): chapter 8, Arfib, D., Keiler, F. and Zölzer, U., “Time-frequency Processing”; and chapter 10: Amatriain, X., Bonada, J., Loscos, A. and Serra, X. “Spectral Processing”.

• Pohlmann, K.C. “Principles of Digital Audio”. 6th Edition. McGraw Hill (2011): chapter 2.

• Loy, G. “Musimathics, Vol.2”. MIT Press (2011): chapter 3.