cannam@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
cannam@0
|
2
|
cannam@0
|
3 /*
|
cannam@0
|
4 QM DSP Library
|
cannam@0
|
5
|
cannam@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
cannam@0
|
7 */
|
cannam@0
|
8
|
cannam@0
|
9 #ifndef FFT_H
|
cannam@0
|
10 #define FFT_H
|
cannam@0
|
11
|
cannam@0
|
12 class FFT
|
cannam@0
|
13 {
|
cannam@0
|
14 public:
|
Chris@114
|
15 /**
|
Chris@114
|
16 * Construct an FFT object to carry out complex-to-complex
|
Chris@114
|
17 * transforms of size nsamples. nsamples must be a power of two in
|
Chris@114
|
18 * this implementation.
|
Chris@114
|
19 */
|
Chris@114
|
20 FFT(int nsamples);
|
cannam@64
|
21 ~FFT();
|
cannam@0
|
22
|
Chris@114
|
23 /**
|
Chris@114
|
24 * Carry out a forward or inverse transform (depending on the
|
Chris@114
|
25 * value of inverse) of size nsamples, where nsamples is the value
|
Chris@114
|
26 * provided to the constructor above.
|
Chris@114
|
27 *
|
Chris@114
|
28 * realIn and (where present) imagIn should contain nsamples each,
|
Chris@114
|
29 * and realOut and imagOut should point to enough space to receive
|
Chris@114
|
30 * nsamples each.
|
Chris@114
|
31 *
|
Chris@114
|
32 * imagIn may be NULL if the signal is real, but the other
|
Chris@114
|
33 * pointers must be valid.
|
Chris@114
|
34 *
|
Chris@114
|
35 * The inverse transform is scaled by 1/nsamples.
|
Chris@114
|
36 */
|
cannam@64
|
37 void process(bool inverse,
|
cannam@64
|
38 const double *realIn, const double *imagIn,
|
cannam@64
|
39 double *realOut, double *imagOut);
|
cannam@64
|
40
|
cannam@64
|
41 private:
|
Chris@114
|
42 int m_n;
|
cannam@0
|
43 };
|
cannam@0
|
44
|
cannam@64
|
45 class FFTReal
|
cannam@64
|
46 {
|
cannam@64
|
47 public:
|
Chris@114
|
48 /**
|
Chris@114
|
49 * Construct an FFT object to carry out real-to-complex transforms
|
Chris@114
|
50 * of size nsamples. nsamples must be a power of two in this
|
Chris@114
|
51 * implementation.
|
Chris@114
|
52 */
|
Chris@114
|
53 FFTReal(int nsamples);
|
cannam@64
|
54 ~FFTReal();
|
cannam@64
|
55
|
Chris@114
|
56 /**
|
Chris@114
|
57 * Carry out a forward real-to-complex transform of size nsamples,
|
Chris@114
|
58 * where nsamples is the value provided to the constructor above.
|
Chris@114
|
59 *
|
Chris@114
|
60 * realIn, realOut, and imagOut must point to (enough space for)
|
Chris@114
|
61 * nsamples values. For consistency with the FFT class above, and
|
Chris@114
|
62 * compatibility with existing code, the conjugate half of the
|
Chris@114
|
63 * output is returned even though it is redundant.
|
Chris@114
|
64 */
|
Chris@114
|
65 void forward(const double *realIn,
|
cannam@64
|
66 double *realOut, double *imagOut);
|
cannam@64
|
67
|
Chris@114
|
68 /**
|
Chris@114
|
69 * Carry out an inverse real transform (i.e. complex-to-real) of
|
Chris@114
|
70 * size nsamples, where nsamples is the value provided to the
|
Chris@114
|
71 * constructor above.
|
Chris@114
|
72 *
|
Chris@114
|
73 * realIn and imagIn should point to at least nsamples/2+1 values;
|
Chris@114
|
74 * if more are provided, only the first nsamples/2+1 values of
|
Chris@114
|
75 * each will be used (the conjugate half will always be deduced
|
Chris@114
|
76 * from the first nsamples/2+1 rather than being read from the
|
Chris@114
|
77 * input data). realOut should point to enough space to receive
|
Chris@114
|
78 * nsamples values.
|
Chris@114
|
79 *
|
Chris@114
|
80 * The inverse transform is scaled by 1/nsamples.
|
Chris@114
|
81 */
|
Chris@114
|
82 void inverse(const double *realIn, const double *imagIn,
|
Chris@114
|
83 double *realOut);
|
Chris@114
|
84
|
cannam@64
|
85 private:
|
Chris@114
|
86 int m_n;
|
Chris@114
|
87 FFT *m_fft;
|
Chris@114
|
88 double *m_r;
|
Chris@114
|
89 double *m_i;
|
Chris@114
|
90 double *m_discard;
|
cannam@64
|
91 };
|
cannam@64
|
92
|
cannam@0
|
93 #endif
|