0

I would like to evaluate power spectrum (amplitude) changes in several tens of seconds length sound record, only on some chosen frequencies. The sound has spectrum like this (mobile phone app analysation):

mobile phone app analysation

I want to plot time changes in only some separate frequences, e.g. on 4kHz and 8kHz, as the time curves. No spectragraph.

Example: The sound has 30 second in length. I want to get power spectrum by FFT, take only frequencies on 4kHz and 8kHz and get two separate curves in one figure of apmlitudes on 4kHz and 8kHz in time.

How would I do that in Matlab?

Max Leske
  • 5,007
  • 6
  • 42
  • 54
vicki
  • 1

1 Answers1

0

You'll use some sort of sliding window, where PS(f, t) is element f from the DFT performed on a block of samples centered on t. The window size will determine the resolution in the frequency domain. (is power at 3.98 kHz included in the trace for 4 kHz?)

I want to get power spectrum by FFT, take only frequencies on 4kHz and 8kHz.

No, you don't. Direct computation of the DFT/GDFT for two frequencies is much faster than computing the entire FFT.

Also, you can apply the Fourier Transform identity for time shifts to update the GDFT instead of recalculating it at each time step. You apply the time shift, add in the sample entering the window, and subtract out the one leaving.

Total complexity using fft and sliding window: O(N * w * lg w) where w is the window size. Total complexity using GDFT and time shift: O(c * N) where c is the count of frequencies you care about.

The constant is similar in both cases, so you really want to use the second whenever c < w * lg w.

Don't forget to take the magnitude (abs function) before graphing.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • I literally wrote exactly this code on Friday, then modified it to not use time shifting because my device is limited to integer arithmetic, and the limited precision of the lookup table for the factors used in the time shift caused error accumulation. The result is that without time shifting, my GDFT differs by a phase angle from the one calculated using sliding-window... but no effect on the magnitude. – Ben Voigt Dec 21 '14 at 16:32