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

  1. #pragma once
  2. #include "common.hpp"
  3. #include <jansson.h>
  4. namespace rack {
  5. struct Param {
  6. float value = 0.f;
  7. float minValue = 0.f;
  8. float maxValue = 1.f;
  9. float defaultValue = 0.f;
  10. // For formatting/displaying the value
  11. /** Set to 0 for linear, nonzero for exponential */
  12. float displayBase = 0.f;
  13. float displayMultiplier = 1.f;
  14. int displayPrecision = 2;
  15. std::string label;
  16. std::string unit;
  17. void setup(float minValue, float maxValue, float defaultValue, std::string label = "", std::string unit = "", int displayPrecision = 2, float displayBase = 0.f, float displayMultiplier = 1.f) {
  18. this->value = defaultValue;
  19. this->minValue = minValue;
  20. this->maxValue = maxValue;
  21. this->defaultValue = defaultValue;
  22. this->label = label;
  23. this->unit = unit;
  24. this->displayPrecision = displayPrecision;
  25. this->displayBase = displayBase;
  26. this->displayMultiplier = displayMultiplier;
  27. }
  28. json_t *toJson();
  29. void fromJson(json_t *rootJ);
  30. void reset();
  31. void randomize();
  32. };
  33. } // namespace rack