🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

63 lines
1.6 KiB

  1. #ifndef FILTER_SPLITTER_H
  2. #define FILTER_SPLITTER_H
  3. #include "alMain.h"
  4. #include "almalloc.h"
  5. /* Band splitter. Splits a signal into two phase-matching frequency bands. */
  6. template<typename Real>
  7. class BandSplitterR {
  8. Real coeff{0.0f};
  9. Real lp_z1{0.0f};
  10. Real lp_z2{0.0f};
  11. Real ap_z1{0.0f};
  12. public:
  13. BandSplitterR() = default;
  14. BandSplitterR(const BandSplitterR&) = default;
  15. BandSplitterR(Real f0norm) { init(f0norm); }
  16. void init(Real f0norm);
  17. void clear() noexcept { lp_z1 = lp_z2 = ap_z1 = 0.0f; }
  18. void process(Real *hpout, Real *lpout, const Real *input, const int count);
  19. void applyHfScale(Real *samples, const Real hfscale, const int count);
  20. };
  21. using BandSplitter = BandSplitterR<float>;
  22. /* The all-pass portion of the band splitter. Applies the same phase shift
  23. * without splitting the signal.
  24. */
  25. template<typename Real>
  26. class SplitterAllpassR {
  27. Real coeff{0.0f};
  28. Real z1{0.0f};
  29. public:
  30. SplitterAllpassR() = default;
  31. SplitterAllpassR(const SplitterAllpassR&) = default;
  32. SplitterAllpassR(Real f0norm) { init(f0norm); }
  33. void init(Real f0norm);
  34. void clear() noexcept { z1 = 0.0f; }
  35. void process(Real *samples, int count);
  36. };
  37. using SplitterAllpass = SplitterAllpassR<float>;
  38. struct FrontStablizer {
  39. static constexpr size_t DelayLength{256u};
  40. alignas(16) float DelayBuf[MAX_OUTPUT_CHANNELS][DelayLength];
  41. SplitterAllpass APFilter;
  42. BandSplitter LFilter, RFilter;
  43. alignas(16) float LSplit[2][BUFFERSIZE];
  44. alignas(16) float RSplit[2][BUFFERSIZE];
  45. alignas(16) float TempBuf[BUFFERSIZE + DelayLength];
  46. DEF_NEWDEL(FrontStablizer)
  47. };
  48. #endif /* FILTER_SPLITTER_H */