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.

64 lines
2.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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 a boolean value.
  19. @see AudioParameterFloat, AudioParameterInt, AudioParameterChoice
  20. */
  21. class JUCE_API AudioParameterBool : public AudioProcessorParameterWithID
  22. {
  23. public:
  24. /** Creates a AudioParameterBool with an ID and name.
  25. On creation, its value is set to the default value.
  26. */
  27. AudioParameterBool (const String& parameterID, const String& name, bool defaultValue,
  28. const String& label = String());
  29. /** Destructor. */
  30. ~AudioParameterBool();
  31. /** Returns the parameter's current boolean value. */
  32. bool get() const noexcept { return value >= 0.5f; }
  33. /** Returns the parameter's current boolean value. */
  34. operator bool() const noexcept { return get(); }
  35. /** Changes the parameter's current value to a new boolean. */
  36. AudioParameterBool& operator= (bool newValue);
  37. private:
  38. //==============================================================================
  39. float value, defaultValue;
  40. float getValue() const override;
  41. void setValue (float newValue) override;
  42. float getDefaultValue() const override;
  43. int getNumSteps() const override;
  44. String getText (float, int) const override;
  45. float getValueForText (const String&) const override;
  46. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterBool)
  47. };