The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

122 lines
5.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A component containing controls to let the user change the audio settings of
  23. an AudioDeviceManager object.
  24. Very easy to use - just create one of these and show it to the user.
  25. @see AudioDeviceManager
  26. @tags{Audio}
  27. */
  28. class JUCE_API AudioDeviceSelectorComponent : public Component,
  29. private ChangeListener,
  30. private Timer
  31. {
  32. public:
  33. //==============================================================================
  34. /** Creates the component.
  35. If your app needs only output channels, you might ask for a maximum of 0 input
  36. channels, and the component won't display any options for choosing the input
  37. channels. And likewise if you're doing an input-only app.
  38. @param deviceManager the device manager that this component should control
  39. @param minAudioInputChannels the minimum number of audio input channels that the application needs
  40. @param maxAudioInputChannels the maximum number of audio input channels that the application needs
  41. @param minAudioOutputChannels the minimum number of audio output channels that the application needs
  42. @param maxAudioOutputChannels the maximum number of audio output channels that the application needs
  43. @param showMidiInputOptions if true, the component will allow the user to select which midi inputs are enabled
  44. @param showMidiOutputSelector if true, the component will let the user choose a default midi output device
  45. @param showChannelsAsStereoPairs if true, channels will be treated as pairs; if false, channels will be
  46. treated as a set of separate mono channels.
  47. @param hideAdvancedOptionsWithButton if true, only the minimum amount of UI components
  48. are shown, with an "advanced" button that shows the rest of them
  49. */
  50. AudioDeviceSelectorComponent (AudioDeviceManager& deviceManager,
  51. int minAudioInputChannels,
  52. int maxAudioInputChannels,
  53. int minAudioOutputChannels,
  54. int maxAudioOutputChannels,
  55. bool showMidiInputOptions,
  56. bool showMidiOutputSelector,
  57. bool showChannelsAsStereoPairs,
  58. bool hideAdvancedOptionsWithButton);
  59. /** Destructor */
  60. ~AudioDeviceSelectorComponent() override;
  61. /** The device manager that this component is controlling */
  62. AudioDeviceManager& deviceManager;
  63. /** Sets the standard height used for items in the panel. */
  64. void setItemHeight (int itemHeight);
  65. /** Returns the standard height used for items in the panel. */
  66. int getItemHeight() const noexcept { return itemHeight; }
  67. /** Returns the ListBox that's being used to show the midi inputs, or nullptr if there isn't one. */
  68. ListBox* getMidiInputSelectorListBox() const noexcept;
  69. //==============================================================================
  70. /** @internal */
  71. void resized() override;
  72. private:
  73. //==============================================================================
  74. void timerCallback() override;
  75. void handleBluetoothButton();
  76. void updateDeviceType();
  77. void updateMidiOutput();
  78. void changeListenerCallback (ChangeBroadcaster*) override;
  79. void updateAllControls();
  80. std::unique_ptr<ComboBox> deviceTypeDropDown;
  81. std::unique_ptr<Label> deviceTypeDropDownLabel;
  82. std::unique_ptr<Component> audioDeviceSettingsComp;
  83. String audioDeviceSettingsCompType;
  84. int itemHeight = 0;
  85. const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels;
  86. const bool showChannelsAsStereoPairs;
  87. const bool hideAdvancedOptionsWithButton;
  88. class MidiInputSelectorComponentListBox;
  89. Array<MidiDeviceInfo> currentMidiOutputs;
  90. std::unique_ptr<MidiInputSelectorComponentListBox> midiInputsList;
  91. std::unique_ptr<ComboBox> midiOutputSelector;
  92. std::unique_ptr<Label> midiInputsLabel, midiOutputLabel;
  93. std::unique_ptr<TextButton> bluetoothButton;
  94. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent)
  95. };
  96. } // namespace juce