Issues with sidechain channel configuration in Cubase

Cubase tries to set for the main buses only its wanted bus Arrangements. If the Plug-in Returns kResultFalse, then the host has to ask the Plug-in for ist wanted (or possible) Arrangements.

The plug-in has to adapt its buses itself like this for example:

//------------------------------------------------------------------------
tresult PLUGIN_API AGainWithSideChain::setBusArrangements (SpeakerArrangement* inputs, int32 numIns,
                                                           SpeakerArrangement* outputs,
                                                           int32 numOuts)
{
	// the first input is the Main Input and the second is the SideChain Input
	if (numIns == 2 && numOuts == 1)
	{
		// the host wants Mono => Mono (or 1 channel -> 1 channel)
		if (SpeakerArr::getChannelCount (inputs[0]) == 1 &&
		    SpeakerArr::getChannelCount (outputs[0]) == 1)
		{
			auto* bus = FCast<AudioBus> (audioInputs.at (0));
			if (bus)
			{
				// check if we are Mono => Mono, if not we need to recreate the buses
				if (bus->getArrangement () != inputs[0])
				{
					removeAudioBusses ();
					addAudioInput (STR16 ("Mono In"), inputs[0]);
					addAudioOutput (STR16 ("Mono Out"), inputs[0]);

					// recreate the Mono SideChain input bus
					addAudioInput (STR16 ("Mono Aux In"), SpeakerArr::kMono, kAux, 0);
				}
				return kResultOk;
			}
		}
		// the host wants something else than Mono => Mono, in this case we are always Stereo =>
		// Stereo
		else
		{
			auto* bus = FCast<AudioBus> (audioInputs.at (0));
			if (bus)
			{
				tresult result = kResultFalse;

				// the host wants 2->2 (could be LsRs -> LsRs)
				if (SpeakerArr::getChannelCount (inputs[0]) == 2 &&
				    SpeakerArr::getChannelCount (outputs[0]) == 2)
				{
					removeAudioBusses ();
					addAudioInput (STR16 ("Stereo In"), inputs[0]);
					addAudioOutput (STR16 ("Stereo Out"), outputs[0]);

					// recreate the Stereo SideChain input bus
					addAudioInput (STR16 ("Stereo Aux In"), SpeakerArr::kStereo, kAux, 0);

					result = kResultTrue;
				}
				// the host want something different than 1->1 or 2->2 : in this case we want stereo
				else if (bus->getArrangement () != SpeakerArr::kStereo)
				{
					removeAudioBusses ();
					addAudioInput (STR16 ("Stereo In"), SpeakerArr::kStereo);
					addAudioOutput (STR16 ("Stereo Out"), SpeakerArr::kStereo);

					// recreate the Stereo SideChain input bus
					addAudioInput (STR16 ("Stereo Aux In"), SpeakerArr::kStereo, kAux, 0);

					result = kResultFalse;
				}

				return result;
			}
		}
	}
	return kResultFalse;
}