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@129
|
17 * transforms of size nsamples. nsamples does not have to be a
|
Chris@129
|
18 * power of two.
|
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@129
|
42 class D;
|
Chris@129
|
43 D *m_d;
|
cannam@0
|
44 };
|
cannam@0
|
45
|
cannam@64
|
46 class FFTReal
|
cannam@64
|
47 {
|
cannam@64
|
48 public:
|
Chris@114
|
49 /**
|
Chris@114
|
50 * Construct an FFT object to carry out real-to-complex transforms
|
Chris@129
|
51 * of size nsamples. nsamples does not have to be a power of two,
|
Chris@129
|
52 * but it does have to be even. (A std::invalid_argument exception
|
Chris@129
|
53 * will be thrown if nsamples is odd.)
|
Chris@114
|
54 */
|
Chris@114
|
55 FFTReal(int nsamples);
|
cannam@64
|
56 ~FFTReal();
|
cannam@64
|
57
|
Chris@114
|
58 /**
|
Chris@114
|
59 * Carry out a forward real-to-complex transform of size nsamples,
|
Chris@114
|
60 * where nsamples is the value provided to the constructor above.
|
Chris@114
|
61 *
|
Chris@114
|
62 * realIn, realOut, and imagOut must point to (enough space for)
|
Chris@114
|
63 * nsamples values. For consistency with the FFT class above, and
|
Chris@114
|
64 * compatibility with existing code, the conjugate half of the
|
Chris@114
|
65 * output is returned even though it is redundant.
|
Chris@114
|
66 */
|
Chris@114
|
67 void forward(const double *realIn,
|
cannam@64
|
68 double *realOut, double *imagOut);
|
cannam@64
|
69
|
Chris@114
|
70 /**
|
Chris@114
|
71 * Carry out an inverse real transform (i.e. complex-to-real) of
|
Chris@114
|
72 * size nsamples, where nsamples is the value provided to the
|
Chris@114
|
73 * constructor above.
|
Chris@114
|
74 *
|
Chris@114
|
75 * realIn and imagIn should point to at least nsamples/2+1 values;
|
Chris@114
|
76 * if more are provided, only the first nsamples/2+1 values of
|
Chris@114
|
77 * each will be used (the conjugate half will always be deduced
|
Chris@114
|
78 * from the first nsamples/2+1 rather than being read from the
|
Chris@114
|
79 * input data). realOut should point to enough space to receive
|
Chris@114
|
80 * nsamples values.
|
Chris@114
|
81 *
|
Chris@114
|
82 * The inverse transform is scaled by 1/nsamples.
|
Chris@114
|
83 */
|
Chris@114
|
84 void inverse(const double *realIn, const double *imagIn,
|
Chris@114
|
85 double *realOut);
|
Chris@114
|
86
|
cannam@64
|
87 private:
|
Chris@129
|
88 class D;
|
Chris@129
|
89 D *m_d;
|
cannam@64
|
90 };
|
cannam@64
|
91
|
cannam@0
|
92 #endif
|