Why is buslayout not discrete? Causes VST3 debug stop

The following code (in the Faust->Juce interface) generates bus with a layout of a specific number of channels:

return BusesProperties()
.withInput(“Input”, juce::AudioChannelSet::discreteChannels(std::min(2, FAUST_INPUTS)), true)
.withOutput(“Output”, juce::AudioChannelSet::discreteChannels(std::min(2, FAUST_OUTPUTS)), true);

Where FAUST_INPUTS = 2 and FAUST_OUTPUTS = 2

When running the code in a debugger, a stop is generated because bool checkBusFormatsAreNotDiscrete() returns false (layout.isDiscreteLayout() is false).

Why does this happen? The function is litterally creating “discreteChannels” and isDescreteLayout returns false.

If discreteChannels is replaced with canonicalChannelSet no errors are generated (when FAUST_OUTPUTS <= 8).

Note: the code does run with no stops outside the debugger, but seems to cause some problem where audio stops after running for a while.

The comment next to the assertion explains the problem. VST3 requires bus layouts to be non-discrete. Channel layouts created with AudioChannelSet::discreteChannels can’t be converted to VST3-compatible layouts.

Is there a simple function like canonicalChannelSet(n) that will return a valid VST3 channel layout up to n=64? I looked at the functions available, and it was not clear what to use.

No, such a function can’t really be implemented. VST3 only defines 61 different speaker types, so it’s not possible to define layouts with 62+ channels. Due to the way VST3 speaker layouts work, some channel layouts with fewer than 61 channels would have conflicting semantics and should be avoided, e.g. a channel layout with 37 channels would have to include both ambisonic and non-ambisonic speaker types, and most hosts won’t know how to work with such layouts.

If you need discrete channel layouts and/or arbitrary channel counts in a VST3 plugin, I’d recommend contacting Steinberg and asking whether they’d consider adding this to the VST3 specification.