Browse Source

AudioPluginHost: Allow Audio IO window to display different channel layouts with matching channel counts

v6.1.6
reuk 3 years ago
parent
commit
c9c4d7a747
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
1 changed files with 26 additions and 31 deletions
  1. +26
    -31
      extras/AudioPluginHost/Source/Plugins/IOConfigurationWindow.cpp

+ 26
- 31
extras/AudioPluginHost/Source/Plugins/IOConfigurationWindow.cpp View File

@@ -171,7 +171,6 @@ private:
//============================================================================== //==============================================================================
class IOConfigurationWindow::InputOutputConfig : public Component, class IOConfigurationWindow::InputOutputConfig : public Component,
private ComboBox::Listener,
private Button::Listener, private Button::Listener,
private NumberedBoxes::Listener private NumberedBoxes::Listener
{ {
@@ -187,7 +186,6 @@ public:
layoutLabel.setFont (layoutLabel.getFont().withStyle (Font::bold)); layoutLabel.setFont (layoutLabel.getFont().withStyle (Font::bold));
enabledToggle.setClickingTogglesState (true); enabledToggle.setClickingTogglesState (true);
layouts.addListener (this);
enabledToggle.addListener (this); enabledToggle.addListener (this);
addAndMakeVisible (layoutLabel); addAndMakeVisible (layoutLabel);
@@ -262,26 +260,32 @@ private:
{ {
name.setText (bus->getName(), NotificationType::dontSendNotification); name.setText (bus->getName(), NotificationType::dontSendNotification);
int i;
for (i = 1; i < AudioChannelSet::maxChannelsOfNamedLayout; ++i)
if ((layouts.indexOfItemId(i) == -1) != bus->supportedLayoutWithChannels (i).isDisabled())
break;
// supported layouts have changed // supported layouts have changed
if (i < AudioChannelSet::maxChannelsOfNamedLayout)
{
layouts.clear();
layouts.clear (dontSendNotification);
auto* menu = layouts.getRootMenu();
auto itemId = 1;
auto selectedId = -1;
for (i = 1; i < AudioChannelSet::maxChannelsOfNamedLayout; ++i)
for (auto i = 1; i < AudioChannelSet::maxChannelsOfNamedLayout; ++i)
{
for (const auto& set : AudioChannelSet::channelSetsWithNumberOfChannels (i))
{ {
auto set = bus->supportedLayoutWithChannels (i);
if (bus->isLayoutSupported (set))
{
menu->addItem (PopupMenu::Item { set.getDescription() }
.setAction ([this, set] { applyBusLayout (set); })
.setID (itemId));
}
if (! set.isDisabled())
layouts.addItem (set.getDescription(), i);
if (bus->getCurrentLayout() == set)
selectedId = itemId;
++itemId;
} }
} }
layouts.setSelectedId (bus->getLastEnabledLayout().size());
layouts.setSelectedId (selectedId);
const bool canBeDisabled = bus->isNumberOfChannelsSupported (0); const bool canBeDisabled = bus->isNumberOfChannelsSupported (0);
@@ -294,27 +298,18 @@ private:
} }
//============================================================================== //==============================================================================
void comboBoxChanged (ComboBox* combo) override
void applyBusLayout (const AudioChannelSet& set)
{ {
if (combo == &layouts)
if (auto* p = owner.getAudioProcessor())
{ {
if (auto* p = owner.getAudioProcessor())
if (auto* bus = p->getBus (isInput, currentBus))
{ {
if (auto* bus = p->getBus (isInput, currentBus))
if (bus->setCurrentLayoutWithoutEnabling (set))
{ {
auto selectedNumChannels = layouts.getSelectedId();
if (selectedNumChannels != bus->getLastEnabledLayout().size())
{
if (isPositiveAndBelow (selectedNumChannels, AudioChannelSet::maxChannelsOfNamedLayout)
&& bus->setCurrentLayoutWithoutEnabling (bus->supportedLayoutWithChannels (selectedNumChannels)))
{
if (auto* config = owner.getConfig (! isInput))
config->updateBusLayout();
if (auto* config = owner.getConfig (! isInput))
config->updateBusLayout();
owner.update();
}
}
owner.update();
} }
} }
} }


Loading…
Cancel
Save