FFTRealFixLen.h (3252B)
1 /***************************************************************************** 2 3 FFTRealFixLen.h 4 By Laurent de Soras 5 6 --- Legal stuff --- 7 8 This program is free software. It comes without any warranty, to 9 the extent permitted by applicable law. You can redistribute it 10 and/or modify it under the terms of the Do What The Fuck You Want 11 To Public License, Version 2, as published by Sam Hocevar. See 12 http://sam.zoy.org/wtfpl/COPYING for more details. 13 14 *Tab=3***********************************************************************/ 15 16 17 18 #if ! defined (ffft_FFTRealFixLen_HEADER_INCLUDED) 19 #define ffft_FFTRealFixLen_HEADER_INCLUDED 20 21 #if defined (_MSC_VER) 22 #pragma once 23 #pragma warning (4 : 4250) // "Inherits via dominance." 24 #endif 25 26 27 28 /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 30 #include "ffft/Array.h" 31 #include "ffft/DynArray.h" 32 #include "ffft/FFTRealFixLenParam.h" 33 #include "ffft/OscSinCos.h" 34 35 36 37 namespace ffft 38 { 39 40 41 42 template <int LL2> 43 class FFTRealFixLen 44 { 45 typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1]; 46 typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1]; 47 48 /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 49 50 public: 51 52 typedef FFTRealFixLenParam::DataType DataType; 53 typedef OscSinCos <DataType> OscType; 54 55 enum { FFT_LEN_L2 = LL2 }; 56 enum { FFT_LEN = 1 << FFT_LEN_L2 }; 57 58 FFTRealFixLen (); 59 60 inline long get_length () const; 61 void do_fft (DataType f [], const DataType x []); 62 void do_ifft (const DataType f [], DataType x []); 63 void rescale (DataType x []) const; 64 65 66 67 /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 68 69 protected: 70 71 72 73 /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 74 75 private: 76 77 enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT }; 78 79 enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) }; 80 enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 }; 81 82 enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0) 83 ? (int)FFT_LEN_L2 84 : (int)TRIGO_BD_LIMIT }; 85 enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) }; 86 enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 }; 87 88 enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD }; 89 enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 }; 90 91 void build_br_lut (); 92 void build_trigo_lut (); 93 void build_trigo_osc (); 94 95 DynArray <DataType> 96 _buffer; 97 DynArray <long> 98 _br_data; 99 DynArray <DataType> 100 _trigo_data; 101 Array <OscType, TRIGO_OSC_ARR_SIZE> 102 _trigo_osc; 103 104 105 106 /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 107 108 private: 109 110 FFTRealFixLen (const FFTRealFixLen &other); 111 FFTRealFixLen& operator = (const FFTRealFixLen &other); 112 bool operator == (const FFTRealFixLen &other); 113 bool operator != (const FFTRealFixLen &other); 114 115 }; // class FFTRealFixLen 116 117 118 119 } // namespace ffft 120 121 122 123 #include "ffft/FFTRealFixLen.hpp" 124 125 126 127 #endif // ffft_FFTRealFixLen_HEADER_INCLUDED 128 129 130 131 /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/