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.

41 lines
910B

  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. std::string label;
  15. std::string unit;
  16. void setup(float minValue, float maxValue, float defaultValue, std::string label = "", std::string unit = "", float displayBase = 0.f, float displayMultiplier = 1.f) {
  17. this->value = defaultValue;
  18. this->minValue = minValue;
  19. this->maxValue = maxValue;
  20. this->defaultValue = defaultValue;
  21. this->label = label;
  22. this->unit = unit;
  23. this->displayBase = displayBase;
  24. this->displayMultiplier = displayMultiplier;
  25. }
  26. json_t *toJson();
  27. void fromJson(json_t *rootJ);
  28. void reset();
  29. void randomize();
  30. };
  31. } // namespace rack