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.

39 lines
836B

  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) {
  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. }
  26. json_t *toJson();
  27. void fromJson(json_t *rootJ);
  28. };
  29. } // namespace rack