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.

39 lines
1.0KB

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