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) 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 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 (String parameterID, String name, bool defaultValue);
  28. /** Destructor. */
  29. ~AudioParameterBool();
  30. /** Returns the parameter's current boolean value. */
  31. bool get() const noexcept { return value >= 0.5f; }
  32. /** Returns the parameter's current boolean value. */
  33. operator bool() const noexcept { return get(); }
  34. /** Changes the parameter's current value to a new boolean. */
  35. AudioParameterBool& operator= (bool newValue);
  36. private:
  37. //==============================================================================
  38. float value, defaultValue;
  39. float getValue() const override;
  40. void setValue (float newValue) override;
  41. float getDefaultValue() const override;
  42. int getNumSteps() const override;
  43. String getText (float, int) const override;
  44. float getValueForText (const String&) const override;
  45. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterBool)
  46. };