Browse Source

Fixed a bug where the VST3 plug-in wrapper would not respect the legacy layout field when disabling/enabling buses

tags/2021-05-28
hogliux 9 years ago
parent
commit
63a71ff20d
2 changed files with 50 additions and 1 deletions
  1. +47
    -1
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp
  2. +3
    -0
      modules/juce_audio_processors/processors/juce_AudioProcessor.cpp

+ 47
- 1
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp View File

@@ -1538,11 +1538,32 @@ public:
return true;
}
//==============================================================================
int getNumAudioBuses (bool isInput) const
{
int busCount = pluginInstance->getBusCount (isInput);
#ifdef JucePlugin_PreferredChannelConfigurations
short configs[][2] = {JucePlugin_PreferredChannelConfigurations};
const int numConfigs = sizeof (configs) / sizeof (short[2]);
bool hasOnlyZeroChannels = true;
for (int i = 0; i < numConfigs && hasOnlyZeroChannels == true; ++i)
if (configs[i][isInput ? 0 : 1] != 0)
hasOnlyZeroChannels = false;
busCount = jmin (busCount, hasOnlyZeroChannels ? 0 : 1);
#endif
return busCount;
}
//==============================================================================
Steinberg::int32 PLUGIN_API getBusCount (Vst::MediaType type, Vst::BusDirection dir) override
{
if (type == Vst::kAudio)
return pluginInstance->getBusCount (dir == Vst::kInput);
return getNumAudioBuses (dir == Vst::kInput);
if (type == Vst::kEvent)
{
@@ -1561,6 +1582,9 @@ public:
{
if (type == Vst::kAudio)
{
if (index < 0 || index >= getNumAudioBuses (dir == Vst::kInput))
return kResultFalse;
if (const AudioProcessor::Bus* bus = pluginInstance->getBus (dir == Vst::kInput, index))
{
info.mediaType = Vst::kAudio;
@@ -1628,8 +1652,30 @@ public:
}
if (type == Vst::kAudio)
{
if (index < 0 || index >= getNumAudioBuses (dir == Vst::kInput))
return kResultFalse;
if (AudioProcessor::Bus* bus = pluginInstance->getBus (dir == Vst::kInput, index))
{
#ifdef JucePlugin_PreferredChannelConfigurations
AudioProcessor::BusesLayout newLayout = pluginInstance->getBusesLayout();
AudioChannelSet targetLayout
= (state != 0 ? bus->getLastEnabledLayout() : AudioChannelSet::disabled());
(dir == Vst::kInput ? newLayout.inputBuses : newLayout.outputBuses).getReference (index) = targetLayout;
short configs[][2] = {JucePlugin_PreferredChannelConfigurations};
AudioProcessor::BusesLayout compLayout
= pluginInstance->getNextBestLayoutInLayoutList (newLayout, configs);
if ((dir == Vst::kInput ? compLayout.inputBuses : compLayout.outputBuses).getReference (index) != targetLayout)
return kResultFalse;
#endif
return (bus->enable (state != 0) ? kResultTrue : kResultFalse);
}
}
return kResultFalse;
}


+ 3
- 0
modules/juce_audio_processors/processors/juce_AudioProcessor.cpp View File

@@ -769,7 +769,10 @@ AudioProcessor::BusesLayout AudioProcessor::getNextBestLayoutInList (const Buses
hasInputs = true;
break;
}
}
for (int i = 0; i < numChannelConfigs; ++i)
{
if (legacyLayouts[i].outChannels > 0)
{
hasOutputs = true;


Loading…
Cancel
Save