JucePlugin_MaxNumInputChannels and Output macros


#1

I noticed that the two macros in the title are only currently referred to in the wrapper for the VST2 format, in the following bit of code:

void findMaxTotalChannels (int& maxTotalIns, int& maxTotalOuts)
{
   #if defined (JucePlugin_MaxNumInputChannels) && defined (JucePlugin_MaxNumOutputChannels)
    maxTotalIns  = JucePlugin_MaxNumInputChannels;
    maxTotalOuts = JucePlugin_MaxNumOutputChannels;
   #else
   /* code that infers maxTotalIns and maxTotalOuts using multi-bus API */
   #endif
}

To my understanding, those are old-style macros which go together with JucePlugin_PreferredChannelConfigurations and so I wonder: in the snippet of code above, wouldn’t it be better to infer maxTotalIns and maxTotalOuts directly looking at JucePlugin_PreferredChannelConfigurations rather than having two explicit macros for those values?

It is true that in Projucer those two macros are automatically added and removed from AppConfig.h depending on whether JucePlugin_PreferredChannelConfigurations is specified, but that is a source of problems for people who use Projucer only to bootstrap projects, or don’t use it at all.

In my case, I had an existing plug-in with main bus only, which therefore had definitions for JucePlugin_PreferredChannelConfigurations, JucePlugin_MaxNumOutputChannels and JucePlugin_MaxNumInputChannels.

To that plug-in I wished to add support for a sidechain bus, thus I followed directions and removed the JucePlugin_PreferredChannelConfigurations definition from AppConfig.h, replacing it with proper multi-bus callbacks in my AudioProcessor.

While that seemed to work in every other format, in VST2 I was unable to get the plug-in to accept more than 2 input channels (instead of the at least 3 implied by stereo main + mono sidechain which I expected), and the cause turned out to be the fact that I left JucePlugin_MaxNumInputChannels and JucePlugin_MaxNumOutputChannels defined in my AppConfig.h.

My suggestion is thus to deprecate those two macros, giving a warning if they are found to be defined, and in the code above only rely on the definition of JucePlugin_PreferredChannelConfigurations and its values to infer the max number of input and output channels.

That would also go in the direction of having less and less macros in AppConfig.h, which seems an (appreciated) trend nowadays


VST3 problem with current JUCE on master
#2

I’ve added this to the develop branch.


#3

Thanks, appreciated that, however it seems that there’s a little too much C++11 there for being easily built with older targets, can this be written in “older” C++?


#4

How old do you want to go? I can target 10.5 without any errors…