isOutputChannelStereoPair() function broken in VST3 Hosting code

Hi,

I just wanted to let you know about another issue I’ve found in the VST3 hosting code. This problem was discovered when testing the Pianoteq 6 demo VST3, which is downloadable here: https://www.pianoteq.com/try

The output channels of this plugin are organized this way:

Bus 0: Stereo, "Output"
Bus 1: Mono, "Aux1"
Bus 2: Mono, "Aux2"
Bus 3: Mono, “Aux3”

There are 5 output channels total, and 4 busses. If you want to know if each output channel is part of a stereo pair, you can call:

for (int ix = 0; ix < 5; ix++)
vst3->isOutputChannelStereoPair(ix);

The problem is that the VST3 implementation of this function first checks to make sure that the channel number is < 5, which it is, and then it returns getBusInfo(false, true).channelCount == 2. The problem is that getBusInfo() when called this way only checks the first bus, Bus 0, so it always returns true. In the for loop above, the call to isOutputChannelStereoPair() returns true each time, even though there are only 5 channels!

This same problem exists in the isInputChannelStereoPair() function as well.

I fixed this function with the following code:

bool isOutputChannelStereoPair (int channelIndex) const override
{
    // 9/18/17:  WARNING:  channelIndex is ignored in original Juce code!
    //return isPositiveAndBelow (channelIndex, getTotalNumOutputChannels())
    //         && getBusInfo (false, true).channelCount == 2;  

   if (!isPositiveAndBelow(channelIndex, getTotalNumOutputChannels()))
      return false;

   double bus = 0;
   bool isStereo = false;

   for (int ix = 0; ix <= channelIndex; ix++)
   {
      Steinberg::Vst::BusInfo info = getBusInfo(false, true, (int)bus);

      if (info.channelCount == 2)
      {
         bus += .5;
         isStereo = true;
      }
      else
      {
         bus += 1.0;
         isStereo = false;
      }
   }

   return isStereo;
}

…though I suspect you’ve got a more elegant solution in mind.

P.S. I understand this function might be deprecated, at least according to a comment I found in AudioProcessor. Nonetheless, I wanted you to know, since these functions still exist in the code.

Thank you for reporting. This issue is now fixed on develop with commit fcffaa6.

Great! Glad to help.