Bus layouts

You should never call one of the set layout methods (i.e. setCurrentLayout, setCurrentLayoutWithoutEnabling, …) from within your plug-in. As a plug-in you cannot set your own layout - the host does. You can only tell the host which layouts you support (via isBusesLayoutSupported) and the number of buses and their default layouts (via your constructor).

To do what you want you should create a static method like this:

static BusesProperties getDefaultLayout()
{
    if (PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_AAX)
        return BusesProperties().withInput ("Input", AudioChannelSet::quadraphonic(), true)
																		   .withInput ("Sidechain", AudioChannelSet::mono(), true)
								 										   .withOutput ("Output", AudioChannelSet::stereo(), true);
    if (PluginHostType::getPluginLoadedAs() ==  ...)
    ...
}

and then in you call the above method in your constructor:

MyAudioProcessor::MyAudioProcessor() : AudioProcessor (getDefaultLayout())
{
    ...
}

@noahdayan wrote a fantastic tutorial explaining all this in a bit more detail:

https://docs.juce.com/master/tutorial_audio_bus_layouts.html

2 Likes