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.

51 lines
852B

  1. #pragma once
  2. #include "WaveShaper.hpp"
  3. #include "HQTrig.hpp"
  4. // constants for Lockhart waveshaper model
  5. #define LOCKHART_RL 7.5e3
  6. #define LOCKHART_R 15e3
  7. #define LOCKHART_VT 25.864e-3
  8. #define LOCKHART_Is 10e-16
  9. #define LOCKHART_THRESHOLD 10e-10
  10. namespace dsp {
  11. /**
  12. * @brief Represents one stage of the Lockhart Wavefolder
  13. */
  14. struct LockhartWFStage {
  15. private:
  16. double fn1, xn1;
  17. double a, b, d;
  18. public:
  19. LockhartWFStage();
  20. double compute(double x);
  21. };
  22. /**
  23. * Lockhart Wavefolder class
  24. */
  25. struct LockhartWavefolder : WaveShaper {
  26. private:
  27. LockhartWFStage lh1, lh2, lh3, lh4;
  28. public:
  29. explicit LockhartWavefolder(float sr);
  30. void init() override;
  31. void invalidate() override;
  32. void process() override;
  33. double compute(double x) override;
  34. };
  35. }