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.

79 lines
3.0KB

  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 to select
  19. an indexed, named choice from a list.
  20. @see AudioParameterFloat, AudioParameterInt, AudioParameterBool
  21. */
  22. class JUCE_API AudioParameterChoice : public AudioProcessorParameterWithID
  23. {
  24. public:
  25. /** Creates a AudioParameterChoice with an ID, name, and list of items.
  26. On creation, its value is set to the default index.
  27. */
  28. AudioParameterChoice (String parameterID, String name,
  29. const StringArray& choices,
  30. int defaultItemIndex);
  31. /** Destructor. */
  32. ~AudioParameterChoice();
  33. /** Returns the current index of the selected item. */
  34. int getIndex() const noexcept { return roundToInt (value); }
  35. /** Returns the current index of the selected item. */
  36. operator int() const noexcept { return getIndex(); }
  37. /** Returns the name of the currently selected item. */
  38. String getCurrentChoiceName() const noexcept { return choices[getIndex()]; }
  39. /** Returns the name of the currently selected item. */
  40. operator String() const noexcept { return getCurrentChoiceName(); }
  41. /** Changes the selected item to a new index. */
  42. AudioParameterChoice& operator= (int newValue);
  43. /** Provides access to the list of choices that this parameter is working with. */
  44. const StringArray choices;
  45. private:
  46. //==============================================================================
  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 (AudioParameterChoice)
  58. };