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.

63 lines
1.7KB

  1. #pragma once
  2. #include "Quantity.hpp"
  3. #include "engine/Param.hpp"
  4. namespace rack {
  5. namespace engine {
  6. struct Module;
  7. /** A Quantity that wraps an engine::Param. */
  8. struct ParamQuantity : Quantity {
  9. Module *module = NULL;
  10. int paramId = 0;
  11. /** The minimum allowed value. */
  12. float minValue = 0.f;
  13. /** The maximum allowed value. Must be greater than minValue. */
  14. float maxValue = 1.f;
  15. /** The initial value. */
  16. float defaultValue = 0.f;
  17. /** The name of the parameter, using sentence capitalization.
  18. e.g. "Frequency", "Pulse width", "Alternative mode"
  19. */
  20. std::string label;
  21. /** The numerical unit of measurement appended to the value.
  22. Unit words and abbreviations should have a space to separate the numerical value from the number (e.g. " semitones", " V", " ms").
  23. Unit symbols should have no space (e.g. "%", "ยบ").
  24. */
  25. std::string unit;
  26. /** Set to 0 for linear, positive for exponential, negative for logarithmic. */
  27. float displayBase = 0.f;
  28. float displayMultiplier = 1.f;
  29. float displayOffset = 0.f;
  30. /** An optional one-sentence description of the parameter. */
  31. std::string description;
  32. Param *getParam();
  33. /** Request to the engine to smoothly set the value */
  34. void setSmoothValue(float smoothValue);
  35. float getSmoothValue();
  36. void setValue(float value) override;
  37. float getValue() override;
  38. float getMinValue() override;
  39. float getMaxValue() override;
  40. float getDefaultValue() override;
  41. float getDisplayValue() override;
  42. void setDisplayValue(float displayValue) override;
  43. std::string getDisplayValueString() override;
  44. void setDisplayValueString(std::string s) override;
  45. int getDisplayPrecision() override;
  46. std::string getLabel() override;
  47. std::string getUnit() override;
  48. };
  49. } // namespace engine
  50. } // namespace rack