comparison dsp/transforms/FFT.h @ 114:f6ccde089491 pvoc

Tidy real-to-complex FFT -- forward and inverse have different arguments, so make them separate functions; document
author Chris Cannam
date Wed, 02 Oct 2013 15:04:38 +0100
parents 6cb2b3cd5356
children 6ec45e85ed81
comparison
equal deleted inserted replaced
113:3cb359d043f0 114:f6ccde089491
10 #define FFT_H 10 #define FFT_H
11 11
12 class FFT 12 class FFT
13 { 13 {
14 public: 14 public:
15 FFT(unsigned int nsamples); 15 /**
16 * Construct an FFT object to carry out complex-to-complex
17 * transforms of size nsamples. nsamples must be a power of two in
18 * this implementation.
19 */
20 FFT(int nsamples);
16 ~FFT(); 21 ~FFT();
17 22
23 /**
24 * Carry out a forward or inverse transform (depending on the
25 * value of inverse) of size nsamples, where nsamples is the value
26 * provided to the constructor above.
27 *
28 * realIn and (where present) imagIn should contain nsamples each,
29 * and realOut and imagOut should point to enough space to receive
30 * nsamples each.
31 *
32 * imagIn may be NULL if the signal is real, but the other
33 * pointers must be valid.
34 *
35 * The inverse transform is scaled by 1/nsamples.
36 */
18 void process(bool inverse, 37 void process(bool inverse,
19 const double *realIn, const double *imagIn, 38 const double *realIn, const double *imagIn,
20 double *realOut, double *imagOut); 39 double *realOut, double *imagOut);
21 40
22 private: 41 private:
23 unsigned int m_n; 42 int m_n;
24 void *m_private;
25 }; 43 };
26 44
27 class FFTReal 45 class FFTReal
28 { 46 {
29 public: 47 public:
30 FFTReal(unsigned int nsamples); 48 /**
49 * Construct an FFT object to carry out real-to-complex transforms
50 * of size nsamples. nsamples must be a power of two in this
51 * implementation.
52 */
53 FFTReal(int nsamples);
31 ~FFTReal(); 54 ~FFTReal();
32 55
33 void process(bool inverse, 56 /**
34 const double *realIn, 57 * Carry out a forward real-to-complex transform of size nsamples,
58 * where nsamples is the value provided to the constructor above.
59 *
60 * realIn, realOut, and imagOut must point to (enough space for)
61 * nsamples values. For consistency with the FFT class above, and
62 * compatibility with existing code, the conjugate half of the
63 * output is returned even though it is redundant.
64 */
65 void forward(const double *realIn,
35 double *realOut, double *imagOut); 66 double *realOut, double *imagOut);
36 67
68 /**
69 * Carry out an inverse real transform (i.e. complex-to-real) of
70 * size nsamples, where nsamples is the value provided to the
71 * constructor above.
72 *
73 * realIn and imagIn should point to at least nsamples/2+1 values;
74 * if more are provided, only the first nsamples/2+1 values of
75 * each will be used (the conjugate half will always be deduced
76 * from the first nsamples/2+1 rather than being read from the
77 * input data). realOut should point to enough space to receive
78 * nsamples values.
79 *
80 * The inverse transform is scaled by 1/nsamples.
81 */
82 void inverse(const double *realIn, const double *imagIn,
83 double *realOut);
84
37 private: 85 private:
38 unsigned int m_n; 86 int m_n;
39 void *m_private; 87 FFT *m_fft;
88 double *m_r;
89 double *m_i;
90 double *m_discard;
40 }; 91 };
41 92
42 #endif 93 #endif