Date:2011-03-03 09:53:42 (8 years 3 months ago)
Author:Werner Almesberger
Commit:fff1e1ed2f2c1654fa550107946c7858acd4484d
Message:usrp/fft.c: added Hamming, make dump easier to interpret

- fft.c (window, fft_complex): added Hamming window function
- fft.c (do_fft): shift dump output such that center frequency is in the
middle, not at the edges
Files: usrp/fft.c (3 diffs)

Change Details

usrp/fft.c
1212static int alg = 0;
1313
1414
15static double window(int i, int n)
16{
17    return 0.54-0.46*cos(M_PI*2*i/(n-1));
18}
19
20
1521static void fft_complex(int n, const float *re, const float *im, double *res)
1622{
1723    fftw_complex *in, *out;
...... 
2329    out = fftw_malloc(sizeof(fftw_complex)*n);
2430
2531    for (i = 0; i != n; i++) {
26        in[i][0] = re[i];
27        in[i][1] = im[i];
32        double w = window(i, n);
33        in[i][0] = re[i]*w;
34        in[i][1] = im[i]*w;
2835    }
2936
3037    plan = fftw_plan_dft_1d(n, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
...... 
127134
128135    if (dump) {
129136        for (i = 0; i < n; i += 1)
130            printf("%d %g\n", i, 10*log(res[i])/log(10));
137            printf("%d %g\n", i,
138                10*log(res[(i+n/2) % n])/log(10));
131139    } else {
132140        double s = 0;
133141        double db;

Archive Download the corresponding diff file



interactive