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