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.

40 lines
1.1KB

  1. #pragma once
  2. //class FFTDataCpx;
  3. //class FFTDataReal;
  4. #include "FFTData.h"
  5. class ColoredNoiseSpec
  6. {
  7. public:
  8. float slope = 0;
  9. float highFreqCorner = 4000;
  10. float sampleRate = 44100;
  11. bool operator != (const ColoredNoiseSpec& other) const
  12. {
  13. return (slope != other.slope) ||
  14. (highFreqCorner != other.highFreqCorner) ||
  15. (sampleRate != other.sampleRate);
  16. }
  17. };
  18. class FFT
  19. {
  20. public:
  21. /** Forward FFT will do the 1/N scaling
  22. */
  23. static bool forward(FFTDataCpx* out, const FFTDataReal& in);
  24. static bool inverse(FFTDataReal* out, const FFTDataCpx& in);
  25. // static FFTDataCpx* makeNoiseFormula(float slope, float highFreqCorner, int frameSize);
  26. /**
  27. * Fills a complex FFT frame with frequency domain data describing noise
  28. */
  29. static void makeNoiseSpectrum(FFTDataCpx* output, const ColoredNoiseSpec&);
  30. static void normalize(FFTDataReal*, float maxValue);
  31. static double bin2Freq(int bin, double sampleRate, int numBins);
  32. static int freqToBin(double freq, double sampleRate, int numBins);
  33. };