dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
FFTReal.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  FFTReal.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 #if !defined(ffft_FFTReal_HEADER_INCLUDED)
17 #define ffft_FFTReal_HEADER_INCLUDED
18 
19 #if defined(_MSC_VER)
20 #pragma once
21 #pragma warning(4 : 4250) // "Inherits via dominance."
22 #endif
23 
24 /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
25 
26 #include "def.h"
27 #include "DynArray.h"
28 #include "OscSinCos.h"
29 
30 namespace ffft {
31 
32 template <class DT>
33 class FFTReal
34 {
35 
36  /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
37 
38 public:
39  enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int
40 
41  typedef DT DataType;
42 
43  explicit FFTReal(long length);
44  virtual ~FFTReal() {}
45 
46  long get_length() const;
47  void do_fft(DataType f[], const DataType x[]) const;
48  void do_ifft(const DataType f[], DataType x[]) const;
49  void rescale(DataType x[]) const;
50  DataType *use_buffer() const;
51 
52  /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
53 
54 protected:
55  /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
56 
57 private:
58  // Over this bit depth, we use direct calculation for sin/cos
59  enum { TRIGO_BD_LIMIT = 12 };
60 
61  typedef OscSinCos<DataType> OscType;
62 
63  void init_br_lut();
64  void init_trigo_lut();
65  void init_trigo_osc();
66 
67  ffft_FORCEINLINE const long *get_br_ptr() const;
68  ffft_FORCEINLINE const DataType *get_trigo_ptr(int level) const;
69  ffft_FORCEINLINE long get_trigo_level_index(int level) const;
70 
71  inline void compute_fft_general(DataType f[], const DataType x[]) const;
72  inline void compute_direct_pass_1_2(DataType df[], const DataType x[]) const;
73  inline void compute_direct_pass_3(DataType df[], const DataType sf[]) const;
74  inline void compute_direct_pass_n(DataType df[], const DataType sf[], int pass) const;
75  inline void compute_direct_pass_n_lut(DataType df[], const DataType sf[], int pass) const;
76  inline void compute_direct_pass_n_osc(DataType df[], const DataType sf[], int pass) const;
77 
78  inline void compute_ifft_general(const DataType f[], DataType x[]) const;
79  inline void compute_inverse_pass_n(DataType df[], const DataType sf[], int pass) const;
80  inline void compute_inverse_pass_n_osc(DataType df[], const DataType sf[], int pass) const;
81  inline void compute_inverse_pass_n_lut(DataType df[], const DataType sf[], int pass) const;
82  inline void compute_inverse_pass_3(DataType df[], const DataType sf[]) const;
83  inline void compute_inverse_pass_1_2(DataType x[], const DataType sf[]) const;
84 
85  const long _length;
86  const int _nbr_bits;
87  DynArray<long> _br_lut;
88  DynArray<DataType> _trigo_lut;
89  mutable DynArray<DataType> _buffer;
90  mutable DynArray<OscType> _trigo_osc;
91 
92  /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
93 
94 private:
95  FFTReal();
96  FFTReal(const FFTReal &other);
97  FFTReal &operator=(const FFTReal &other);
98  bool operator==(const FFTReal &other);
99  bool operator!=(const FFTReal &other);
100 
101 }; // class FFTReal
102 
103 } // namespace ffft
104 
105 #include "FFTReal.hpp"
106 
107 #endif // ffft_FFTReal_HEADER_INCLUDED
108 
109 /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
void do_fft(DataType f[], const DataType x[]) const
Definition: FFTReal.hpp:143
virtual ~FFTReal()
Definition: FFTReal.h:44
long get_length() const
Definition: FFTReal.hpp:119
DataType * use_buffer() const
Definition: FFTReal.hpp:310
void do_ifft(const DataType f[], DataType x[]) const
Definition: FFTReal.hpp:204
x
Definition: OPPlots.m:100
void rescale(DataType x[]) const
Definition: FFTReal.hpp:259