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.

50 lines
999B

  1. #pragma once
  2. class NoiseMessage;
  3. /**
  4. * This is a specialized gizmo just for fading between two
  5. * FFT frames
  6. */
  7. class FFTCrossFader
  8. {
  9. public:
  10. FFTCrossFader(int crossfadeSamples) : crossfadeSamples(crossfadeSamples)
  11. {
  12. }
  13. NoiseMessage * step(float* out);
  14. NoiseMessage * acceptData(NoiseMessage*);
  15. bool empty() const
  16. {
  17. return !dataFrames[0];
  18. }
  19. const NoiseMessage* playingMessage() const
  20. {
  21. // TODO: should return second, it exists?
  22. return dataFrames[0];
  23. }
  24. void enableMakeupGain(bool enable)
  25. {
  26. makeupGain = enable;
  27. }
  28. private:
  29. /**
  30. * The size of the crossfade, in samples
  31. */
  32. const int crossfadeSamples;
  33. bool makeupGain = false;
  34. /**
  35. * current playhead, relative to start of each buffer
  36. */
  37. int curPlayOffset[2] = {0, 0};
  38. NoiseMessage* dataFrames[2] = {nullptr, nullptr};
  39. /** Advance the play offset,
  40. * wrap on overflow.
  41. */
  42. void advance(int index);
  43. };