00001 /***************************************************************************** 00002 * * 00003 * DIGITAL SIGNAL PROCESSING TOOLS * 00004 * Version 1.01, 1999/11/07 * 00005 * (c) 1999 - Laurent de Soras * 00006 * * 00007 * FFTReal.h * 00008 * Fourier transformation of real number arrays. * 00009 * Portable ISO C++ * 00010 * * 00011 * Tab = 3 * 00012 *****************************************************************************/ 00013 00014 #if defined (FFTReal_CURRENT_HEADER) 00015 #error Recursive inclusion of FFTReal header file. 00016 #endif 00017 #define FFTReal_CURRENT_HEADER 00018 00019 #if ! defined (FFTReal_HEADER_INCLUDED) 00020 #define FFTReal_HEADER_INCLUDED 00021 00022 #if defined (_MSC_VER) 00023 #pragma pack (push, 8) 00024 #endif // _MSC_VER 00025 00026 class FFTReal { 00027 00028 /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 00029 00030 public: 00031 /* Change this typedef to use a different floating point type in your FFTs 00032 (i.e. float, double or long double). */ 00033 typedef float flt_t; 00034 00035 explicit FFTReal (const long length); 00036 ~FFTReal (); 00037 void do_fft (flt_t f [], const flt_t x []) const; 00038 void do_ifft (const flt_t f [], flt_t x []) const; 00039 void rescale (flt_t x []) const; 00040 00041 /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 00042 00043 private: 00044 00045 /* Bit-reversed look-up table nested class */ 00046 class BitReversedLUT 00047 { 00048 public: 00049 explicit BitReversedLUT (const int nbr_bits); 00050 ~BitReversedLUT (); 00051 const long * get_ptr () const 00052 { 00053 return (_ptr); 00054 } 00055 private: 00056 long * _ptr; 00057 }; 00058 00059 /* Trigonometric look-up table nested class */ 00060 class TrigoLUT 00061 { 00062 public: 00063 explicit TrigoLUT (const int nbr_bits); 00064 ~TrigoLUT (); 00065 const flt_t * get_ptr (const int level) const 00066 { 00067 return (_ptr + (1L << (level - 1)) - 4); 00068 }; 00069 private: 00070 flt_t * _ptr; 00071 }; 00072 00073 const BitReversedLUT _bit_rev_lut; 00074 const TrigoLUT _trigo_lut; 00075 const flt_t _sqrt2_2; 00076 const long _length; 00077 const int _nbr_bits; 00078 flt_t * _buffer_ptr; 00079 00080 /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 00081 00082 private: 00083 FFTReal (const FFTReal &other); 00084 const FFTReal& operator = (const FFTReal &other); 00085 int operator == (const FFTReal &other); 00086 int operator != (const FFTReal &other); 00087 }; 00088 00089 #if defined (_MSC_VER) 00090 #pragma pack (pop) 00091 #endif // _MSC_VER 00092 00093 #endif // FFTReal_HEADER_INCLUDED 00094 00095 #undef FFTReal_CURRENT_HEADER 00096 00097 /***************************************************************************** 00098 00099 LEGAL 00100 00101 Source code may be freely used for any purpose, including commercial 00102 applications. Programs must display in their "About" dialog-box (or 00103 documentation) a text telling they use these routines by Laurent de Soras. 00104 Modified source code can be distributed, but modifications must be clearly 00105 indicated. 00106 00107 CONTACT 00108 00109 Laurent de Soras 00110 92 avenue Albert 1er 00111 92500 Rueil-Malmaison 00112 France 00113 00114 ldesoras@club-internet.fr 00115 00116 *****************************************************************************/ 00117 00118 /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/