FFTRealFixLen.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*****************************************************************************
  2. FFTRealFixLen.h
  3. By Laurent de Soras
  4. --- Legal stuff ---
  5. This program is free software. It comes without any warranty, to
  6. the extent permitted by applicable law. You can redistribute it
  7. and/or modify it under the terms of the Do What The Fuck You Want
  8. To Public License, Version 2, as published by Sam Hocevar. See
  9. http://sam.zoy.org/wtfpl/COPYING for more details.
  10. *Tab=3***********************************************************************/
  11. #if ! defined (ffft_FFTRealFixLen_HEADER_INCLUDED)
  12. #define ffft_FFTRealFixLen_HEADER_INCLUDED
  13. #if defined (_MSC_VER)
  14. #pragma once
  15. #pragma warning (4 : 4250) // "Inherits via dominance."
  16. #endif
  17. /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  18. #include "ffft/Array.h"
  19. #include "ffft/DynArray.h"
  20. #include "ffft/FFTRealFixLenParam.h"
  21. #include "ffft/OscSinCos.h"
  22. namespace ffft
  23. {
  24. template <int LL2>
  25. class FFTRealFixLen
  26. {
  27. typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1];
  28. typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1];
  29. /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  30. public:
  31. typedef FFTRealFixLenParam::DataType DataType;
  32. typedef OscSinCos <DataType> OscType;
  33. enum { FFT_LEN_L2 = LL2 };
  34. enum { FFT_LEN = 1 << FFT_LEN_L2 };
  35. FFTRealFixLen ();
  36. inline long get_length () const;
  37. void do_fft (DataType f [], const DataType x []);
  38. void do_ifft (const DataType f [], DataType x []);
  39. void rescale (DataType x []) const;
  40. /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  41. protected:
  42. /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  43. private:
  44. enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT };
  45. enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) };
  46. enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 };
  47. enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0)
  48. ? (int)FFT_LEN_L2
  49. : (int)TRIGO_BD_LIMIT };
  50. enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) };
  51. enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 };
  52. enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD };
  53. enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 };
  54. void build_br_lut ();
  55. void build_trigo_lut ();
  56. void build_trigo_osc ();
  57. DynArray <DataType>
  58. _buffer;
  59. DynArray <long>
  60. _br_data;
  61. DynArray <DataType>
  62. _trigo_data;
  63. Array <OscType, TRIGO_OSC_ARR_SIZE>
  64. _trigo_osc;
  65. /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
  66. private:
  67. FFTRealFixLen (const FFTRealFixLen &other);
  68. FFTRealFixLen& operator = (const FFTRealFixLen &other);
  69. bool operator == (const FFTRealFixLen &other);
  70. bool operator != (const FFTRealFixLen &other);
  71. }; // class FFTRealFixLen
  72. } // namespace ffft
  73. #include "ffft/FFTRealFixLen.hpp"
  74. #endif // ffft_FFTRealFixLen_HEADER_INCLUDED
  75. /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/