c@225
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
c@225
|
2
|
c@225
|
3 /*
|
c@225
|
4 QM DSP Library
|
c@225
|
5
|
c@225
|
6 Centre for Digital Music, Queen Mary, University of London.
|
c@415
|
7
|
c@415
|
8 This program is free software; you can redistribute it and/or
|
c@415
|
9 modify it under the terms of the GNU General Public License as
|
c@415
|
10 published by the Free Software Foundation; either version 2 of the
|
c@415
|
11 License, or (at your option) any later version. See the file
|
c@415
|
12 COPYING included with this distribution for more information.
|
c@225
|
13 */
|
c@225
|
14
|
c@225
|
15 #ifndef FFT_H
|
c@225
|
16 #define FFT_H
|
c@225
|
17
|
c@225
|
18 class FFT
|
c@225
|
19 {
|
c@225
|
20 public:
|
c@339
|
21 /**
|
c@339
|
22 * Construct an FFT object to carry out complex-to-complex
|
c@355
|
23 * transforms of size nsamples. nsamples does not have to be a
|
c@355
|
24 * power of two.
|
c@339
|
25 */
|
c@339
|
26 FFT(int nsamples);
|
c@289
|
27 ~FFT();
|
c@225
|
28
|
c@339
|
29 /**
|
c@339
|
30 * Carry out a forward or inverse transform (depending on the
|
c@339
|
31 * value of inverse) of size nsamples, where nsamples is the value
|
c@339
|
32 * provided to the constructor above.
|
c@339
|
33 *
|
c@339
|
34 * realIn and (where present) imagIn should contain nsamples each,
|
c@339
|
35 * and realOut and imagOut should point to enough space to receive
|
c@339
|
36 * nsamples each.
|
c@339
|
37 *
|
c@339
|
38 * imagIn may be NULL if the signal is real, but the other
|
c@339
|
39 * pointers must be valid.
|
c@339
|
40 *
|
c@339
|
41 * The inverse transform is scaled by 1/nsamples.
|
c@339
|
42 */
|
c@289
|
43 void process(bool inverse,
|
c@289
|
44 const double *realIn, const double *imagIn,
|
c@289
|
45 double *realOut, double *imagOut);
|
c@289
|
46
|
c@289
|
47 private:
|
c@355
|
48 class D;
|
c@355
|
49 D *m_d;
|
c@225
|
50 };
|
c@225
|
51
|
c@289
|
52 class FFTReal
|
c@289
|
53 {
|
c@289
|
54 public:
|
c@339
|
55 /**
|
c@339
|
56 * Construct an FFT object to carry out real-to-complex transforms
|
c@355
|
57 * of size nsamples. nsamples does not have to be a power of two,
|
c@357
|
58 * but it does have to be even. (Use the complex-complex FFT above
|
c@357
|
59 * if you need an odd FFT size. This constructor will throw
|
c@357
|
60 * std::invalid_argument if nsamples is odd.)
|
c@339
|
61 */
|
c@339
|
62 FFTReal(int nsamples);
|
c@289
|
63 ~FFTReal();
|
c@289
|
64
|
c@339
|
65 /**
|
c@339
|
66 * Carry out a forward real-to-complex transform of size nsamples,
|
c@339
|
67 * where nsamples is the value provided to the constructor above.
|
c@339
|
68 *
|
c@339
|
69 * realIn, realOut, and imagOut must point to (enough space for)
|
c@339
|
70 * nsamples values. For consistency with the FFT class above, and
|
c@339
|
71 * compatibility with existing code, the conjugate half of the
|
c@339
|
72 * output is returned even though it is redundant.
|
c@339
|
73 */
|
c@339
|
74 void forward(const double *realIn,
|
c@289
|
75 double *realOut, double *imagOut);
|
c@289
|
76
|
c@339
|
77 /**
|
c@357
|
78 * Carry out a forward real-to-complex transform of size nsamples,
|
c@357
|
79 * where nsamples is the value provided to the constructor
|
c@357
|
80 * above. Return only the magnitudes of the complex output values.
|
c@357
|
81 *
|
c@357
|
82 * realIn and magOut must point to (enough space for) nsamples
|
c@357
|
83 * values. For consistency with the FFT class above, and
|
c@357
|
84 * compatibility with existing code, the conjugate half of the
|
c@357
|
85 * output is returned even though it is redundant.
|
c@357
|
86 */
|
c@357
|
87 void forwardMagnitude(const double *realIn, double *magOut);
|
c@357
|
88
|
c@357
|
89 /**
|
c@339
|
90 * Carry out an inverse real transform (i.e. complex-to-real) of
|
c@339
|
91 * size nsamples, where nsamples is the value provided to the
|
c@339
|
92 * constructor above.
|
c@339
|
93 *
|
c@339
|
94 * realIn and imagIn should point to at least nsamples/2+1 values;
|
c@339
|
95 * if more are provided, only the first nsamples/2+1 values of
|
c@339
|
96 * each will be used (the conjugate half will always be deduced
|
c@339
|
97 * from the first nsamples/2+1 rather than being read from the
|
c@339
|
98 * input data). realOut should point to enough space to receive
|
c@339
|
99 * nsamples values.
|
c@339
|
100 *
|
c@339
|
101 * The inverse transform is scaled by 1/nsamples.
|
c@339
|
102 */
|
c@339
|
103 void inverse(const double *realIn, const double *imagIn,
|
c@339
|
104 double *realOut);
|
c@339
|
105
|
c@289
|
106 private:
|
c@355
|
107 class D;
|
c@355
|
108 D *m_d;
|
c@289
|
109 };
|
c@289
|
110
|
c@225
|
111 #endif
|