Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast Fourier Transform (FFT) input and output to analyse the frequency of audio files in Java?

I have to use FFT to analyse the frequency of an audio file. But I don't know what the input and output is.

Do I have to use 1-dimension, 2-dimension or 3-dimension array if I want to draw the spectrum's audio file? And can someone suggest me library for FFT on J2ME?

like image 480
thongcaoloi Avatar asked Jul 08 '11 06:07

thongcaoloi


1 Answers

@thongcaoloi,

The simple answer regarding the dimensionality of your input data is: you need 1D data. Now I'll explain what that means.

Because you want to analyze audio data, your input to the discrete Fourier transform (DFT or FFT), is a 1-dimensional sequence of real numbers, which represents the changing voltage of the audio signal over time, and your audio file is a digital representation of that changing voltage over time.

Your audio file was produced by sampling the voltage of a continuous audio signal at a fixed sampling rate (also known as the sampling frequency), typically 44.1 KHz for CD quality audio.

But your data file could have been sampled at a much lower frequency, so try to find out the sampling frequency of your data before you do an FFT on that data.

So now you have to extract the individual samples from your audio file. If your file is stereo, it will have two separate sample sequences, one for the right channel and one for the left channel. If the file is mono, it will have only one sample sequence.

If your file is stereo, or any other multi-channel audio format such as 5.1 or 7.1, you could FFT each channel separately, or you could combine any number of channels together using voltage addition. That's up to you, and depends on what you're trying to do with your FFT results.

The output of the DFT or FFT is a sequence of complex numbers. Each complex number is a pair consisting of a real-part and an imaginary-part, typically shown as a pair (re,im).

If you want to graph the power spectral density of your audio file, which is what most people want from the FFT, you'll graph 20*log10( sqrt( re^2 + im^2 ) ), using the first N/2 complex numbers of the FFT output, where N is the number of input samples to the FFT.

You can try to build your own spectrum analyzer software program, but I suggest using something that's already built and tested.

These two FFT spectrum analyzers give results instantly, and have built-in IFFT synthesis, meaning that you can inverse Fourier transform the frequency-domain spectral data to reconstruct the original signal in the time-domain.

http://www.mathworks.com/help/techdoc/ref/fft.html

http://www.sooeet.com/math/fft.php

There's a lot more to this topic, and to the subject of digital signal processing in general, but this brief introduction, should get you started.

like image 69
Ernest Barkowski Avatar answered Sep 28 '22 16:09

Ernest Barkowski