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.

43 lines
1.0KB

  1. #pragma once
  2. #include <JuceHeader.h>
  3. #include "WEFilters/EffectsProcessor.h"
  4. #include "WEFilters/AREnvelopeFollowerSquareLaw.h"
  5. #include "General/AudioSpinMutex.h"
  6. /**
  7. * Performs an FFT on the signal which can be provided to the UI to drive the visualiser.
  8. */
  9. class FFTProvider {
  10. public:
  11. static constexpr int FFT_ORDER {9};
  12. static constexpr int FFT_SIZE {(1 << FFT_ORDER) * 2};
  13. static constexpr int NUM_OUTPUTS { FFT_SIZE / 4 };
  14. FFTProvider();
  15. ~FFTProvider();
  16. void setSampleRate(double sampleRate);
  17. void reset();
  18. void processBlock(juce::AudioBuffer<float>& buffer);
  19. const float* getOutputs() { return _outputs; }
  20. void setIsStereo(bool val) { _isStereo = val; }
  21. float getBinWidth() const { return _binWidth; }
  22. private:
  23. float* _inputBuffer;
  24. float* _fftBuffer;
  25. float* _outputs;
  26. juce::dsp::FFT _fft;
  27. std::array<WECore::AREnv::AREnvelopeFollowerSquareLaw, NUM_OUTPUTS> _envs;
  28. WECore::AudioSpinMutex _fftMutex;
  29. bool _isStereo;
  30. float _binWidth;
  31. };