1 | /*****************************************************************************
|
---|
2 |
|
---|
3 | FFTReal.h
|
---|
4 | Copyright (c) 2005 Laurent de Soras
|
---|
5 |
|
---|
6 | --- Legal stuff ---
|
---|
7 |
|
---|
8 | This library is free software; you can redistribute it and/or
|
---|
9 | modify it under the terms of the GNU Lesser General Public
|
---|
10 | License as published by the Free Software Foundation; either
|
---|
11 | version 2.1 of the License, or (at your option) any later version.
|
---|
12 |
|
---|
13 | This library is distributed in the hope that it will be useful,
|
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
16 | Lesser General Public License for more details.
|
---|
17 |
|
---|
18 | You should have received a copy of the GNU Lesser General Public
|
---|
19 | License along with this library; if not, write to the Free Software
|
---|
20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
21 |
|
---|
22 | *Tab=3***********************************************************************/
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 | #if ! defined (FFTReal_HEADER_INCLUDED)
|
---|
27 | #define FFTReal_HEADER_INCLUDED
|
---|
28 |
|
---|
29 | #if defined (_MSC_VER)
|
---|
30 | #pragma once
|
---|
31 | #pragma warning (4 : 4250) // "Inherits via dominance."
|
---|
32 | #endif
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
---|
37 |
|
---|
38 | #include "def.h"
|
---|
39 | #include "DynArray.h"
|
---|
40 | #include "OscSinCos.h"
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 | template <class DT>
|
---|
45 | class FFTReal
|
---|
46 | {
|
---|
47 |
|
---|
48 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
---|
49 |
|
---|
50 | public:
|
---|
51 |
|
---|
52 | enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int
|
---|
53 |
|
---|
54 | typedef DT DataType;
|
---|
55 |
|
---|
56 | explicit FFTReal (long length);
|
---|
57 | virtual ~FFTReal () {}
|
---|
58 |
|
---|
59 | long get_length () const;
|
---|
60 | void do_fft (DataType f [], const DataType x []) const;
|
---|
61 | void do_ifft (const DataType f [], DataType x []) const;
|
---|
62 | void rescale (DataType x []) const;
|
---|
63 | DataType * use_buffer () const;
|
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
67 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
---|
68 |
|
---|
69 | protected:
|
---|
70 |
|
---|
71 |
|
---|
72 |
|
---|
73 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
---|
74 |
|
---|
75 | private:
|
---|
76 |
|
---|
77 | // Over this bit depth, we use direct calculation for sin/cos
|
---|
78 | enum { TRIGO_BD_LIMIT = 12 };
|
---|
79 |
|
---|
80 | typedef OscSinCos <DataType> OscType;
|
---|
81 |
|
---|
82 | void init_br_lut ();
|
---|
83 | void init_trigo_lut ();
|
---|
84 | void init_trigo_osc ();
|
---|
85 |
|
---|
86 | FORCEINLINE const long *
|
---|
87 | get_br_ptr () const;
|
---|
88 | FORCEINLINE const DataType *
|
---|
89 | get_trigo_ptr (int level) const;
|
---|
90 | FORCEINLINE long
|
---|
91 | get_trigo_level_index (int level) const;
|
---|
92 |
|
---|
93 | inline void compute_fft_general (DataType f [], const DataType x []) const;
|
---|
94 | inline void compute_direct_pass_1_2 (DataType df [], const DataType x []) const;
|
---|
95 | inline void compute_direct_pass_3 (DataType df [], const DataType sf []) const;
|
---|
96 | inline void compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const;
|
---|
97 | inline void compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const;
|
---|
98 | inline void compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const;
|
---|
99 |
|
---|
100 | inline void compute_ifft_general (const DataType f [], DataType x []) const;
|
---|
101 | inline void compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const;
|
---|
102 | inline void compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const;
|
---|
103 | inline void compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const;
|
---|
104 | inline void compute_inverse_pass_3 (DataType df [], const DataType sf []) const;
|
---|
105 | inline void compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const;
|
---|
106 |
|
---|
107 | const long _length;
|
---|
108 | const int _nbr_bits;
|
---|
109 | DynArray <long>
|
---|
110 | _br_lut;
|
---|
111 | DynArray <DataType>
|
---|
112 | _trigo_lut;
|
---|
113 | mutable DynArray <DataType>
|
---|
114 | _buffer;
|
---|
115 | mutable DynArray <OscType>
|
---|
116 | _trigo_osc;
|
---|
117 |
|
---|
118 |
|
---|
119 |
|
---|
120 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
---|
121 |
|
---|
122 | private:
|
---|
123 |
|
---|
124 | FFTReal ();
|
---|
125 | FFTReal (const FFTReal &other);
|
---|
126 | FFTReal & operator = (const FFTReal &other);
|
---|
127 | bool operator == (const FFTReal &other);
|
---|
128 | bool operator != (const FFTReal &other);
|
---|
129 |
|
---|
130 | }; // class FFTReal
|
---|
131 |
|
---|
132 |
|
---|
133 |
|
---|
134 | #include "FFTReal.hpp"
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 | #endif // FFTReal_HEADER_INCLUDED
|
---|
139 |
|
---|
140 |
|
---|
141 |
|
---|
142 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
---|