Update Juce Bus Negotiation Docs Please

There is some doc here:

which shows an example of a plugin that has two input buses (quadraphonic, and stereo) and one output bus (LCR), but doesn’t actually show how to set this up in the code example afterwards (just stereo in / out), and also doesn’t show how to negotiate changes via the isBusesLayoutSupported on anything but the “main” input and output.

Could someone at Juce please update this doc to show that multiple calls to .withInput() would be needed on the BusesProperties() to add the extra buses?

Also the actual name .withInput() implies a bus isn’t being added, but that this replacing the input with whatever is being passed in, something like .withAddedInputBus() would be a lot clearer, or even just .addInputBus()

Even keeping .withInput() would be ok if any documentation existed to let the coder know that .withInput() actually calls addBus to add a new bus - currently the only way to know this is to look at the code itself!

Also in the current documentation the variable “layouts” is used to mean a singular layout, eg:

bool isBusesLayoutSupported (const BusesLayout& layouts) const

Where there are multiple buses in a single layout and the name of the function and the type of the parameter are singular “layout”, but the variable is plural, which is a little confusing.

Usually the one in the ctor is the default config

  : AudioProcessor(BusesProperties()
    .withInput("Input", juce::AudioChannelSet::stereo(), true)
    .withInput("Input2", juce::AudioChannelSet::stereo(), true)
    .withOutput("Output", juce::AudioChannelSet::createLCR(), true))

while isBusesLayoutSupported handle all other cases

just check getChannelSet on the layouts with busIndex to 1 to handle the extra bus

Like that

isBusesLayoutSupported (const BusesLayout& layouts) const
if (layouts.getChannelSet(false, 0) ==  juce::AudioChannelSet::createLCR() )
if (layouts.getChannelSet(true, 0) ==  juce::AudioChannelSet::stereo() || layouts.getChannelSet(true, 0) ==  juce::AudioChannelSet::quadrophonic())
  if (layouts.getChannelSet(true, 1) ==  juce::AudioChannelSet::stereo() || layouts.getChannelSet(true, 1) ==  juce::AudioChannelSet::quadrophonic())
     return true;
return false;

Thanks for the post. After looking at the code I already figured it out, but my point was that the documentation and the comments didn’t actually properly show / aren’t named properly so someone coming new can work it out without looking at the implementation.

Also, please be careful with language here, the constructor needs to be a config to use as the default one, but with enough buses added to both the input and the output to cover the maximum buses required for the plugin, but disabling extra buses if they aren’t wanted in the default layout.

So it would be great if your example was added to the documentation (but with qaudro I think added for the first bus), but also show how to also accept mono / stereo / other combinations that the plugin may want.

I also prefer the syntax of just calling layouts.inputBuses[i].something() rather than layouts.getChannelSet(true, i).something(), since true isn’t clear that you mean input without looking at headers to see what true means.

More singular / plural naming issues in juce::AudioProcessor:

virtual bool applyBusLayouts (const BusesLayout& layouts);

should be:

virtual bool applyBusesLayout (const BusesLayout& layout);