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.

71 lines
1.3KB

  1. #pragma once
  2. #include <random>
  3. #if !defined(M_PI)
  4. #define M_PI float(3.14159265358979323846264338327950288)
  5. #endif
  6. #ifdef __V1
  7. #include "math.hpp"
  8. #include "dsp/filter.hpp"
  9. #include "dsp/minblep.hpp"
  10. #else
  11. #include "util/math.hpp"
  12. #include "dsp/functions.hpp"
  13. #include "dsp/filter.hpp"
  14. #include "dsp/minblep.hpp"
  15. #endif
  16. #if 1
  17. /**
  18. * A wrapper around rack's math functions.
  19. * Mitigates some V1 vs V06 issues.
  20. */
  21. namespace sq
  22. {
  23. #ifdef __V1
  24. using RCFilter = rack::dsp::RCFilter;
  25. #else
  26. using RCFilter = rack::RCFilter;
  27. #endif
  28. inline float quadraticBipolar(float x)
  29. {
  30. #ifdef __V1
  31. return rack::dsp::quadraticBipolar(x);
  32. #else
  33. return rack::quadraticBipolar(x);
  34. #endif
  35. }
  36. inline float clamp(float a, float b, float c)
  37. {
  38. #ifdef __V1
  39. return rack::math::clamp(a, b, c);
  40. #else
  41. return rack::clamp(a, b, c);
  42. #endif
  43. }
  44. inline float interpolateLinear(float* a, float b)
  45. {
  46. #ifdef __V1
  47. return rack::math::interpolateLinear(a, b);
  48. #else
  49. return rack::interpolateLinear(a, b);
  50. #endif
  51. }
  52. inline float rescale(float a, float b, float c, float d, float e)
  53. {
  54. #ifdef __V1
  55. return rack::math::rescale(a, b, c, d, e);
  56. #else
  57. return rack::rescale(a, b, c, d, e);
  58. #endif
  59. }
  60. }
  61. #endif