You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6KB

  1. #pragma once
  2. #include <complex>
  3. #include <vector>
  4. class FFT;
  5. /**
  6. * Our wrapper api uses std::complex, so we don't need to expose kiss_fft_cpx
  7. * outside. Our implementation assumes the two are equivalent, and that a
  8. * reinterpret_cast can bridge them.
  9. */
  10. using cpx = std::complex<float>;
  11. class FFTDataCpx
  12. {
  13. public:
  14. friend FFT;
  15. FFTDataCpx(int numBins);
  16. ~FFTDataCpx();
  17. cpx get(int bin) const;
  18. void set(int bin, cpx value);
  19. int size() const
  20. {
  21. return (int) buffer.size();
  22. }
  23. static int _count;
  24. private:
  25. std::vector<cpx> buffer;
  26. /**
  27. * we store this without type so that clients don't need
  28. * to pull in the kiss_fft headers. It's mutable so it can
  29. * be lazy created by FFT functions.
  30. * Note that the cfg has a "direction" baked into it. For
  31. * now we assume that all FFT with complex input will be inverse FFTs.
  32. */
  33. mutable void * kiss_cfg = 0;
  34. };
  35. /**
  36. * Holds an fft frame of real data.
  37. */
  38. class FFTDataReal
  39. {
  40. public:
  41. friend FFT;
  42. FFTDataReal(int numBins);
  43. ~FFTDataReal();
  44. float get(int numBin) const;
  45. void set(int numBin, float value);
  46. int size() const
  47. {
  48. return (int) buffer.size();
  49. }
  50. static int _count;
  51. private:
  52. std::vector<float> buffer;
  53. /**
  54. * we store this without type so that clients don't need
  55. * to pull in the kiss_fft headers. It's mutable so it can
  56. * be lazy created by FFT functions.
  57. * Note that the cfg has a "direction" baked into it. For
  58. * now we assume that all FFT with real input will be forward FFTs.
  59. */
  60. mutable void * kiss_cfg = 0;
  61. };