What logic to use for isInputChannelStereoPair?


#1

I have a plugin that can accept both mono or stereo input. What should the implementation of isInputChannelStereoPair be like?

Always reporting the input as non-stereo (because it can also be mono):

bool Filter::isInputChannelStereoPair (int index) const { return false; }

Always reporting the input as stereo (as it is obviously non-stereo when there is only one input channel)

bool Filter::isInputChannelStereoPair (int index) const { return true; }
Reporting it to be stereo or mono depending on the number of input channels

bool Filter::isInputChannelStereoPair (int index) const { return getNumInputChannels() > 1; }

The last one looks like the most correct to me, but I wonder if I can safely assume that getNumInputChannels() will return the correct number no matter when it may end up being called within isInputChannelStereoPair, because the documentation states that the returned number is actually reliabel only in the processBlock or prepareToPlay calls.

The same question for the output, obviously…


#2

It’s just a hint for the wrapper, it doesn’t have to be correct in all cases. It’s just used for things like deciding whether a 2-channel RTAS is stereo or dual-mono. Nothing will break if you have one channel but still return true for this.


#3

I’ve come across some more details regarding this: if instert your stereo to stereo plug-in into Live, on a stereo track, it only works as expected if these functions return true. If they return false, the host will only send one channel to the plug-in (the left one) while the other is seen from the plug-in as silent.