Hi, I have now a Java code implementing real FFT. I need actually Java code for implementing integer (fixed-point) FFT. I mean with this that the FFT accepts Java int type as input and produces Java int type as output. If there is no Java fixed-point FFT, how can I convert the existing Java real FFT to a fixed-point FFT? Would please somebody give a code example in Java. PS: I can now perform Inverse FFT using the current Java FFT and it does work very well (I get the original signal back). I assume that the fixed-point FFT will do the same. Thank you Robert

# Is there a sample Java code for fixedpoint FFT?

Started by ●January 25, 2006

Reply by ●January 26, 20062006-01-26

Robert Hay wrote:> I have now a Java code implementing real FFT. I need actually Java code > for implementing integer (fixed-point) FFT. I mean with this that the FFT > accepts Java int type as input and produces Java int type as output. If > there is no Java fixed-point FFT, how can I convert the existing Java real > FFT to a fixed-point FFT? Would please somebody give a code example in > Java.If you can't find a Java example, there a lots of FFT examples in ANSI C which should be small enough and similar enough to Java syntax to convert into using Java syntax and data types. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M

Reply by ●January 26, 20062006-01-26

"Robert Hay" <rezahay@yahoo.com> writes:> Hi, > > I have now a Java code implementing real FFT. I need actually Java code > for implementing integer (fixed-point) FFT. I mean with this that the FFT > accepts Java int type as input and produces Java int type as output. If > there is no Java fixed-point FFT, how can I convert the existing Java real > FFT to a fixed-point FFT? Would please somebody give a code example in > Java. > > PS: I can now perform Inverse FFT using the current Java FFT and it does > work very well (I get the original signal back). I assume that the > fixed-point FFT will do the same.Since you're using Java, you can't possibly be concerned about speed, so why not simply convert the integers to floats on input and then back to integers on output? -- % Randy Yates % "How's life on earth? %% Fuquay-Varina, NC % ... What is it worth?" %%% 919-577-9882 % 'Mission (A World Record)', %%%% <yates@ieee.org> % *A New World Record*, ELO http://home.earthlink.net/~yatescr

Reply by ●January 30, 20062006-01-30

>Since you're using Java, you can't possibly be concerned about speed, so >why not simply convert the integers to floats on input and then >back to integers on output? >-- >% Randy Yates % "How's life on earth? >%% Fuquay-Varina, NC % ... What is it worth?" >%%% 919-577-9882 % 'Mission (A World Record)', >%%%% <yates@ieee.org> % *A New World Record*, ELO >http://home.earthlink.net/~yatescr >I had already tried that. It doesn't work if I want to use the output of FFT as the input for the Inverse FFT. I don't get my original signal back. Thanks

Reply by ●January 30, 20062006-01-30

> >I had already tried that. It doesn't work if I want to use the output of >FFT as the input for the Inverse FFT. I don't get my original signal >back. > >Thanks >My problem actually is as follows: My program (in Java) gets two array of integers from another program, uses FFT or Inverse FFT depending on what the calling program requests, and returns two array of integers to the caller. The next time the caller may want to get its original signal by requesting from my program an Inverse FFT operation. My program uses a Java FFT to realize that. But the FFT routine accepts floats (instead of integers) and it returns floats (instead of integers). If my program converts the floats to integers and the next time the caller requests an Inverse FFT then the original signal could not be recovered. I know that Kiss supports Fixed-point FFT but the C code is very complex for me. Therefore my question was: Has please somebody a Java FFT which can handles integers? or Can please somebody tell me (in a few Java statements) how a real FFT can be converted to integer FFT? Thanks in advance

Reply by ●January 30, 20062006-01-30

Robert Hay wrote:>>Since you're using Java, you can't possibly be concerned about speed, so >>why not simply convert the integers to floats on input and then >>back to integers on output? >>-- >>% Randy Yates % "How's life on earth? >>%% Fuquay-Varina, NC % ... What is it worth?" >>%%% 919-577-9882 % 'Mission (A World Record)', >>%%%% <yates@ieee.org> % *A New World Record*, ELO >>http://home.earthlink.net/~yatescr >> > > > > I had already tried that. It doesn't work if I want to use the output of > FFT as the input for the Inverse FFT. I don't get my original signal > back.Do you know why not? Excessive truncation? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●January 30, 20062006-01-30

Robert Hay wrote:> >Since you're using Java, you can't possibly be concerned about speed, so > >why not simply convert the integers to floats on input and then > >back to integers on output? > >-- > >% Randy Yates % "How's life on earth? > >%% Fuquay-Varina, NC % ... What is it worth?" > >%%% 919-577-9882 % 'Mission (A World Record)', > >%%%% <yates@ieee.org> % *A New World Record*, ELO > >http://home.earthlink.net/~yatescr > > > > > I had already tried that. It doesn't work if I want to use the output of > FFT as the input for the Inverse FFT. I don't get my original signal > back.1) Do not convert to integer on your float FFT routine. 2) Convert between integer and float for your integer FFT routine. 3) Integer FFT/IFFT's (generally) do not return the original signal without differences (due to rounding/quantization errors). -- rhn

Reply by ●February 1, 20062006-02-01

>Robert Hay wrote: >> >Since you're using Java, you can't possibly be concerned about speed,so>> >why not simply convert the integers to floats on input and then >> >back to integers on output? >> >-- >> >% Randy Yates % "How's life on earth? >> >%% Fuquay-Varina, NC % ... What is it worth?" >> >%%% 919-577-9882 % 'Mission (A World Record)', >> >%%%% <yates@ieee.org> % *A New World Record*, ELO >> >http://home.earthlink.net/~yatescr >> > >> >> >> I had already tried that. It doesn't work if I want to use the outputof>> FFT as the input for the Inverse FFT. I don't get my original signal >> back. > >1) Do not convert to integer on your float FFT routine. >2) Convert between integer and float for your integer FFT routine. >3) Integer FFT/IFFT's (generally) do not return the original signal >without differences (due to rounding/quantization errors). > >-- >rhn > >Should I conclude that Integer FFT/IFFT impossible is?

Reply by ●February 1, 20062006-02-01

Robert Hay wrote:> My problem actually is as follows: My program (in Java) gets two array of > integers from another program, uses FFT or Inverse FFT depending on what > the calling program requests, and returns two array of integers to the > caller. The next time the caller may want to get its original signal by > requesting from my program an Inverse FFT operation.This is an intrinsic problem -- integers cannot very accurately represent the results of a DFT -- and using an integer FFT will do nothing to solve it. The best you can do is to compute a floating-point FFT and then pick a scaling for the results so that you lose as little precision as possible when you truncate to integers. If you use an "integer FFT", it will be computing exactly the same thing but losing even more bits in the intermediate calculations. You have to live with the fact that the inverse FFT is not going to give your original signal back exactly. This is true even for a floating-point FFT, but the errors if you truncate to integer/fixed-point outputs are going to be bigger. Regards, Steven G. Johnson

Reply by ●February 1, 20062006-02-01