Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio spectrum analysis using FFT algorithm in Java

I want to analyze the spectrum of an audio file in Java (ME). I want to draw spectrum as some media players do. But I don't understand some points:

  1. Input for FFT algorithm, which I have to get from the audio file. I don't now what it is called, what it is and more important, I don't know how to get it.
  2. Output: if input is an array (range?) I obtain other array, and it have range: 0-1, right (or not)? So what I have to do with it?
like image 656
itakanzebo Avatar asked Jul 08 '11 16:07

itakanzebo


1 Answers

You need a few additional steps in addition to the FFT. This has been covered many times already in previous similar questions here on SO, and you can find additional material by searching for "dsp", "fft", "spectrum", "spectrogram", etc, but essentially you need to do the following:

  • apply a window function to the input data (e.g. Hann(ing))
  • apply FFT to windowed input data (for complex-to-complex FFT the imaginary inputs should all be zero)
  • calculate squared magnitude of first N / 2 FFT output bins (re * re + im * im)
  • convert squared magnitude to dB scale (10 * log10(squared_magnitude))
like image 132
Paul R Avatar answered Oct 19 '22 23:10

Paul R