Android 2.3 Visualizer - Trouble understanding getFft()

前端 未结 2 1730
别那么骄傲
别那么骄傲 2020-12-03 14:13

First time here so sorry in advance for any butchered formatting.

So I am completely new to DSP so I have only a very general understanding of the Fourier Transform.

相关标签:
2条回答
  • 2020-12-03 14:52

    In case it helps anyone, I've created a Visualizer which takes the output from the MediaPlayer and displays a visualization. It works with both normal waveform and FFT data:

    https://github.com/felixpalmer/android-visualizer

    It includes code for converting the output of getFft() into something visually meaningful.

    0 讨论(0)
  • 2020-12-03 15:13

    The frequency at FFT output sample k is given by:

    Fk = k * Fs / N,    k = 0,1,...,N-1 
    

    where

    • Fs is the sampling frequency of the time series input
    • N is the number of samples used to compute the FFT

    The two sides of the spectrum refers to the positive and negative frequencies in the output of the FFT. The FFT forces the frequency output to be periodic with a period of Fs. If you look at the FFT output, it covers the frequencies from 0 to Fs. It is often advantageous to view the spectrum over the range of -0.5*Fs to 0.5*Fs instead by shifting the FFT output from 0.5*Fs -> Fs to -0.5*Fs -> 0 since they are equal because of the periodicity.

    For real-valued signals, like the ones you have in audio processing, the negative frequency output will be a mirror image of the positive frequencies. Because of this, often only one side of the spectrum is used when analyzing real signals.

    Another important point is the significance of 0.5*Fs which is known as the Nyquist Frequency. A signal can only accurately represent frequencies up to the Nyquist frequency and anything above it will be aliased (folded) back onto the spectrum causing distortion.

    So really all you should worry about for visualization purposes are the FFT output samples corresponding to the range of frequencies from 0 to Fs/2 since those are the meaningful samples for a real signal with sampling rate Fs.

    0 讨论(0)
提交回复
热议问题