Mercurial > hg > silvet
comparison constant-q-cpp/src/dsp/FFT.h @ 366:5d0a2ebb4d17
Bring dependent libraries in to repo
author | Chris Cannam |
---|---|
date | Fri, 24 Jun 2016 14:47:45 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
365:112766f4c34b | 366:5d0a2ebb4d17 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 /* | |
3 Constant-Q library | |
4 Copyright (c) 2013-2014 Queen Mary, University of London | |
5 | |
6 Permission is hereby granted, free of charge, to any person | |
7 obtaining a copy of this software and associated documentation | |
8 files (the "Software"), to deal in the Software without | |
9 restriction, including without limitation the rights to use, copy, | |
10 modify, merge, publish, distribute, sublicense, and/or sell copies | |
11 of the Software, and to permit persons to whom the Software is | |
12 furnished to do so, subject to the following conditions: | |
13 | |
14 The above copyright notice and this permission notice shall be | |
15 included in all copies or substantial portions of the Software. | |
16 | |
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
22 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
24 | |
25 Except as contained in this notice, the names of the Centre for | |
26 Digital Music; Queen Mary, University of London; and Chris Cannam | |
27 shall not be used in advertising or otherwise to promote the sale, | |
28 use or other dealings in this Software without prior written | |
29 authorization. | |
30 */ | |
31 | |
32 #ifndef FFT_H | |
33 #define FFT_H | |
34 | |
35 class FFT | |
36 { | |
37 public: | |
38 /** | |
39 * Construct an FFT object to carry out complex-to-complex | |
40 * transforms of size nsamples. nsamples does not have to be a | |
41 * power of two. | |
42 */ | |
43 FFT(int nsamples); | |
44 ~FFT(); | |
45 | |
46 /** | |
47 * Carry out a forward or inverse transform (depending on the | |
48 * value of inverse) of size nsamples, where nsamples is the value | |
49 * provided to the constructor above. | |
50 * | |
51 * realIn and (where present) imagIn should contain nsamples each, | |
52 * and realOut and imagOut should point to enough space to receive | |
53 * nsamples each. | |
54 * | |
55 * imagIn may be NULL if the signal is real, but the other | |
56 * pointers must be valid. | |
57 * | |
58 * The inverse transform is scaled by 1/nsamples. | |
59 */ | |
60 void process(bool inverse, | |
61 const double *realIn, const double *imagIn, | |
62 double *realOut, double *imagOut); | |
63 | |
64 private: | |
65 class D; | |
66 D *m_d; | |
67 }; | |
68 | |
69 class FFTReal | |
70 { | |
71 public: | |
72 /** | |
73 * Construct an FFT object to carry out real-to-complex transforms | |
74 * of size nsamples. nsamples does not have to be a power of two, | |
75 * but it does have to be even. (Use the complex-complex FFT above | |
76 * if you need an odd FFT size. This constructor will throw | |
77 * std::invalid_argument if nsamples is odd.) | |
78 */ | |
79 FFTReal(int nsamples); | |
80 ~FFTReal(); | |
81 | |
82 /** | |
83 * Carry out a forward real-to-complex transform of size nsamples, | |
84 * where nsamples is the value provided to the constructor above. | |
85 * | |
86 * realIn, realOut, and imagOut must point to (enough space for) | |
87 * nsamples values. For consistency with the FFT class above, and | |
88 * compatibility with existing code, the conjugate half of the | |
89 * output is returned even though it is redundant. | |
90 */ | |
91 void forward(const double *realIn, | |
92 double *realOut, double *imagOut); | |
93 | |
94 /** | |
95 * Carry out a forward real-to-complex transform of size nsamples, | |
96 * where nsamples is the value provided to the constructor | |
97 * above. Return only the magnitudes of the complex output values. | |
98 * | |
99 * realIn and magOut must point to (enough space for) nsamples | |
100 * values. For consistency with the FFT class above, and | |
101 * compatibility with existing code, the conjugate half of the | |
102 * output is returned even though it is redundant. | |
103 */ | |
104 void forwardMagnitude(const double *realIn, double *magOut); | |
105 | |
106 /** | |
107 * Carry out an inverse real transform (i.e. complex-to-real) of | |
108 * size nsamples, where nsamples is the value provided to the | |
109 * constructor above. | |
110 * | |
111 * realIn and imagIn should point to at least nsamples/2+1 values; | |
112 * if more are provided, only the first nsamples/2+1 values of | |
113 * each will be used (the conjugate half will always be deduced | |
114 * from the first nsamples/2+1 rather than being read from the | |
115 * input data). realOut should point to enough space to receive | |
116 * nsamples values. | |
117 * | |
118 * The inverse transform is scaled by 1/nsamples. | |
119 */ | |
120 void inverse(const double *realIn, const double *imagIn, | |
121 double *realOut); | |
122 | |
123 private: | |
124 class D; | |
125 D *m_d; | |
126 }; | |
127 | |
128 #endif |