1 | /***************************************************************************** |
2 | |
3 | FFTRealFixLen.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 (FFTRealFixLen_HEADER_INCLUDED) |
27 | #define |
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 "Array.h" |
39 | #include "DynArray.h" |
40 | #include "FFTRealFixLenParam.h" |
41 | #include "OscSinCos.h" |
42 | |
43 | |
44 | |
45 | template <int LL2> |
46 | class FFTRealFixLen |
47 | { |
48 | typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1]; |
49 | typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1]; |
50 | |
51 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
52 | |
53 | public: |
54 | |
55 | typedef FFTRealFixLenParam::DataType DataType; |
56 | typedef OscSinCos <DataType> OscType; |
57 | |
58 | enum { FFT_LEN_L2 = LL2 }; |
59 | enum { FFT_LEN = 1 << FFT_LEN_L2 }; |
60 | |
61 | FFTRealFixLen (); |
62 | |
63 | inline long get_length () const; |
64 | void do_fft (DataType f [], const DataType x []); |
65 | void do_ifft (const DataType f [], DataType x []); |
66 | void rescale (DataType x []) const; |
67 | |
68 | |
69 | |
70 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
71 | |
72 | protected: |
73 | |
74 | |
75 | |
76 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
77 | |
78 | private: |
79 | |
80 | enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT }; |
81 | |
82 | enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) }; |
83 | enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 }; |
84 | |
85 | enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0) |
86 | ? (int)FFT_LEN_L2 |
87 | : (int)TRIGO_BD_LIMIT }; |
88 | enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) }; |
89 | enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 }; |
90 | |
91 | enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD }; |
92 | enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 }; |
93 | |
94 | void build_br_lut (); |
95 | void build_trigo_lut (); |
96 | void build_trigo_osc (); |
97 | |
98 | DynArray <DataType> |
99 | _buffer; |
100 | DynArray <long> |
101 | _br_data; |
102 | DynArray <DataType> |
103 | _trigo_data; |
104 | Array <OscType, TRIGO_OSC_ARR_SIZE> |
105 | _trigo_osc; |
106 | |
107 | |
108 | |
109 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
110 | |
111 | private: |
112 | |
113 | FFTRealFixLen (const FFTRealFixLen &other); |
114 | FFTRealFixLen& operator = (const FFTRealFixLen &other); |
115 | bool operator == (const FFTRealFixLen &other); |
116 | bool operator != (const FFTRealFixLen &other); |
117 | |
118 | }; // class FFTRealFixLen |
119 | |
120 | |
121 | |
122 | #include "FFTRealFixLen.hpp" |
123 | |
124 | |
125 | |
126 | #endif // FFTRealFixLen_HEADER_INCLUDED |
127 | |
128 | |
129 | |
130 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
131 | |