1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-05 04:55:19 +02:00

usrp: try to bring back sanity to pre- and post-processing of FFT data

The pre- and post-processing of FFT data was tweaked based on results
obtained from a mis-configured measurement setup, in an only partially
successful attempt to right the wrong data.

- usrp/fft.c (fft_complex): square the magnitude on output but don't
  square the scaling
- usrp/fft.c (fft_real): square the magnitude on input (does this make
  sense ?)
- usrp/fft.c (fft_real): scale the output with the square root of the
  FFT size (dubious)
This commit is contained in:
Werner Almesberger 2010-12-01 10:32:43 -03:00
parent fea4ee551a
commit 40d1234bf4

View File

@ -31,8 +31,8 @@ static void fft_complex(int n, const float *re, const float *im, double *res)
fftw_execute(plan);
for (i = 0; i != n; i++) {
a = hypot(out[i][0], out[i][1])/n;
// a = a*a;
a = hypot(out[i][0], out[i][1]); // /n;
a = a*a/n;
res[i] = a;
}
}
@ -46,16 +46,18 @@ static void fft_real(int n, const float *re, const float *im, double *res)
double a ;
in = fftw_malloc(sizeof(double)*n);
(void) a;
for (i = 0; i != n; i++)
in[i] = hypot(re[i], im[i]);
for (i = 0; i != n; i++) {
a = hypot(re[i], im[i]);
in[i] = a*a;
}
plan = fftw_plan_r2r_1d(n, in, res, FFTW_REDFT10, FFTW_ESTIMATE);
fftw_execute(plan);
/* @@@ not sure at all about the scaling */
for (i = 0; i != n; i++)
res[i] /= n;
res[i] = res[i]/sqrt(n);
}