Audio plugin host https://kx.studio/carla
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.

juce_AudioParameterInt.h 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. /**
  18. Provides a class of AudioProcessorParameter that can be used as an
  19. integer value with a given range.
  20. @see AudioParameterFloat, AudioParameterBool, AudioParameterChoice
  21. */
  22. class JUCE_API AudioParameterInt : public AudioProcessorParameterWithID
  23. {
  24. public:
  25. /** Creates an AudioParameterInt with an ID, name, and range.
  26. Note that the min and max range values are inclusive.
  27. On creation, its value is set to the default value.
  28. */
  29. AudioParameterInt (String parameterID, String name,
  30. int minValue, int maxValue,
  31. int defaultValue);
  32. /** Destructor. */
  33. ~AudioParameterInt();
  34. /** Returns the parameter's current value as an integer. */
  35. int get() const noexcept { return roundToInt (value); }
  36. /** Returns the parameter's current value as an integer. */
  37. operator int() const noexcept { return get(); }
  38. /** Changes the parameter's current value to a new integer.
  39. The value passed in will be snapped to the permitted range before being used.
  40. */
  41. AudioParameterInt& operator= (int newValue);
  42. /** Returns the parameter's range. */
  43. Range<int> getRange() const noexcept { return Range<int> (minValue, maxValue); }
  44. private:
  45. //==============================================================================
  46. int minValue, maxValue;
  47. float value, defaultValue;
  48. float getValue() const override;
  49. void setValue (float newValue) override;
  50. float getDefaultValue() const override;
  51. int getNumSteps() const override;
  52. String getText (float, int) const override;
  53. float getValueForText (const String&) const override;
  54. int limitRange (int) const noexcept;
  55. float convertTo0to1 (int) const noexcept;
  56. int convertFrom0to1 (float) const noexcept;
  57. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterInt)
  58. };