CMake + Channel Layout List

We’ve moved to JUCE6 + CMake but we’re having a little bit of trouble with channelLayoutList for constructing our AudioProcessor.

Previously, this layout list was provided by JUCE through a #define which came from the project configuration. When moving to CMake it didn’t seem like this was an option so we hardcoded the layout into our plugin.

However, this caused an issue with VST2 since our list started with {1, 2} and that resulted in VST2 to only be able to handle mono input. In order to combat this, we re-ordered our layout list so that the largest set of channels–{16,16}–was first in the list. This fixed the VST2 problem but has introduced other issues.

Is there a canonical way to handle this?

The canonical solution would be to avoid the channel layout list entirely, and instead to override isBusesLayoutSupported.

If this isn’t an option for some reason, you can just add JucePlugin_PreferredChannelConfigurations to your target_compile_definitions call. Note that due to the {} syntax, some generators have a difficult time escaping these strings correctly, but maybe the generators that you’re using won’t have this issue.

1 Like

been struggling to get JucePlugin_PreferredChannelConfigurations to work via target_compile_definitions, or in fact any way to set it safely so that it sets JucePlugin_MaxNumInputChannels or JucePlugin_MaxNumOutputChannels get set as well, any ideas?

JucePlugin_MaxNumInputChannels and JucePlugin_MaxNumOutputChannels are currently only set in Projucer builds. We can look at adding these to CMake builds, but in the meantime I’d strongly recommend investigating the new dynamic buses API (isBusesLayoutSupported, canAddBus, canRemoveBus etc.).

good to know, we have a design where a plugin can be “morphed” into different products via pre-processor definitions but maybe we have to change this design entirely

You can still do that, even with the new API: you can use your pre processor macros to select different behaviours for your isBusesLayoutSupported callback.