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.

23 lines
758B

  1. #include "AudioMath.h"
  2. const double AudioMath::Pi = 3.1415926535897932384626433832795028841971;
  3. const double AudioMath::Pi_2 = 1.5707963267948966192313216916397514420986;
  4. const double AudioMath::Ln2 = 0.693147180559945309417;
  5. const double AudioMath::Ln10 = 2.30258509299404568402;
  6. const double AudioMath::E = 2.71828182845904523536;
  7. std::function<double(double)> AudioMath::makeFunc_Sin()
  8. {
  9. return [](double x) {
  10. return std::sin(x * 2 * Pi);
  11. };
  12. }
  13. std::function<double(double)> AudioMath::makeFunc_Exp(double xMin, double xMax, double yMin, double yMax)
  14. {
  15. const double a = (std::log(yMax) - log(yMin)) / (xMax - xMin);
  16. const double b = log(yMin) - a * xMin;
  17. return [a, b](double d) {
  18. return std::exp(a * d + b);
  19. };
  20. }