I am no expert on this stuff but since no one else has answered, I'll give it a shot.

Try this (I haven't tested it but it should be close):

First, change "int x[] = new int[n];" to "double x[] = new double[n];"

Then, replace the last box with the following:

Be sure to check these results against your existing algorithm to determine if this method is correct.

Also, since the transform only uses the first half of x, you can save time in the loop populating x by changing "for (int i = 0; i < n*2; i+=2) {" to "for (int i = 0; i < n; i+=2) {". There's no sense populating values that you're not using.

Try this (I haven't tested it but it should be close):

First, change "int x[] = new int[n];" to "double x[] = new double[n];"

Then, replace the last box with the following:

```
DoubleFFT_1D f = new DoubleFFT_1D(n/2);
f.realForwardFull(x);
for (int j = 0; j < n; j += 2) {
double amplitude = 2 * x[j]/n;
double frequency =(j/2) * h / T * sample_rate;
System.out.println("frequency = "+frequency+", amp = "+amplitude);
}
```

Be sure to check these results against your existing algorithm to determine if this method is correct.

Also, since the transform only uses the first half of x, you can save time in the loop populating x by changing "for (int i = 0; i < n*2; i+=2) {" to "for (int i = 0; i < n; i+=2) {". There's no sense populating values that you're not using.