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.

ParamQuantity.hpp 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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;
  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 name;
  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. int displayPrecision = 5;
  31. /** An optional one-sentence description of the parameter. */
  32. std::string description;
  33. /** Enables parameter resetting when the module or parameter itself is reset.
  34. */
  35. bool resetEnabled = true;
  36. /** Enables parameter randomization when the module is randomized.
  37. Unbounded (infinite) parameters are not randomizable, regardless of this setting.
  38. */
  39. bool randomizeEnabled = true;
  40. /** Rounds values to the nearest integer. */
  41. bool snapEnabled = false;
  42. Param* getParam();
  43. /** Request to the engine to smoothly set the value */
  44. void setSmoothValue(float smoothValue);
  45. float getSmoothValue();
  46. void setValue(float value) override;
  47. float getValue() override;
  48. float getMinValue() override;
  49. float getMaxValue() override;
  50. float getDefaultValue() override;
  51. float getDisplayValue() override;
  52. void setDisplayValue(float displayValue) override;
  53. std::string getDisplayValueString() override;
  54. void setDisplayValueString(std::string s) override;
  55. int getDisplayPrecision() override;
  56. std::string getLabel() override;
  57. std::string getUnit() override;
  58. virtual std::string getDescription();
  59. };
  60. } // namespace engine
  61. } // namespace rack