0

I have 2 arrays containing time and voltage. I would like to convert time domain to frequency domain in Java. I would like to use FFT. If there is any open source library I could use, please point me to it. I have done a research and found few algorithms but they are asking for real part and imaginary part. If anyone got idea regarding that, please let me know how I could use that in my context.

Code I have found so far

gprathour
  • 14,813
  • 5
  • 66
  • 90
Dinesh
  • 149
  • 1
  • 3
  • 12
  • Yeah, you want FFT, though I'm not familiar with the packages available for Java to suggest one. The "real" and "imaginary" values are "halves" of the "frequency domain" result of an FFT, and in effect give info on the "phase" of the signal. But my head will explode if I think about it much more than that. – Hot Licks Jul 08 '14 at 16:35
  • Where you don't want/need phase info it's common to combine the real and imaginary values into RMS (root mean square) values -- square root of real squared plus imaginary squared. – Hot Licks Jul 08 '14 at 17:09
  • Also note that it's typical to run the FFT multiple times, maybe every 0.1 second for audio. This gives a view of the frequency spectrum as it changes over time. – Hot Licks Jul 08 '14 at 17:11
  • Note that your samples need to be uniformly spaced in time - if your time interval is not constant then you can't use an ordinary FFT. – Paul R Jul 08 '14 at 18:20

1 Answers1

1

Here is one library:

http://www.fftw.org/download.html

You can also use R with Java. See this link:

Java-R integration?

If you are not familiar with R check their home page r-project dot org (I can't post more links)

While I haven't checked the implementation you link to, you should be able to use that one by suppling 0s for the imaginary part. In that case you are going "forward", i.e. set DIRECT to true transforming from time-domain to the frequency domain. The function will return an array containing real parts of the frequency in even numbered seats, and the imaginary part in odd numbered.

Community
  • 1
  • 1
skarist
  • 1,030
  • 7
  • 9
  • Thanks for details. It really helps. So I could use even numbered seats as my array because I have provided imaginary part as 0s. Am I correct?? – Dinesh Jul 08 '14 at 17:28
  • You would use this something like this: double[] your_real_values = new double[sample_size]; double[] dummy_img_values = new double[sample_size]; // popuplate the your_real_values array with the correct values Arrays.fill(dummy_img_values,0.0); double[] fft_vals = FFTbase.fft(your_real_values,dummy_img_values,true); the return array is of size 2*sample_size and fft_vals[i] contains the real part of the frequencies if i is even otherwise the img part. – skarist Jul 08 '14 at 19:27