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:
- 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.
- 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?
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)
)