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
731B

  1. #include "RShaper.hpp"
  2. using namespace dsp;
  3. ReShaper::ReShaper(float sr) : WaveShaper(sr) {
  4. init();
  5. noise = new Noise;
  6. }
  7. void ReShaper::init() {
  8. WaveShaper::rs = new Resampler<1>(8, 16);
  9. }
  10. void ReShaper::process() {
  11. WaveShaper::process();
  12. }
  13. void ReShaper::invalidate() {}
  14. double ReShaper::compute(double x) {
  15. double out;
  16. double a = gain * 2.5;
  17. double in = clampd(x, -SHAPER_MAX_VOLTS, SHAPER_MAX_VOLTS);
  18. in += clampd(bias * 0.5, -SHAPER_MAX_BIAS / 4., SHAPER_MAX_BIAS / .4); // add bias
  19. in *= RSHAPER_GAIN;
  20. in = in * (fabs(in) + a) / (in * in + (a - 1) * fabs(in) + 1);
  21. in *= 1 / RSHAPER_GAIN * 0.5;
  22. if (blockDC) in = dc->filter(in);
  23. out = in;
  24. return out;
  25. }