How to detect sidechain in AU plugins

I’m making a spectrum analyzer plugin that uses optional sidechain input to allow users to compare a reference track on the same GUI display.

The sidechain part is working fine in VST3, but my AU builds have the following issues (in all hosts tested, incl. Logic, Ableton and Reaper):
– prepareToPlay() doesn’t get called when the user connects/disconnects sidechain input in the DAW.
– getTotalNumInputChannels() always returns 4 (if stereo), even if no sidechain connected.
– getBus(true, 1)->isEnabled() always returns 1, even if no sidechain connected.

So the plugin thinks a sidechain is always connected, leading to ~2x CPU burn in AU vs. VST3 in the no-sidechain scenario.

Is it possible in JUCE to determine if an AU plugin has sidechain connected?

I’m attaching a screenshot illustrating the issue. I can share code if helpful.

Update: Until I learn of a better approach, I’ve just added a button in the AU version so that the user can manually activate sidechain processing if needed.

A UI option to select an external sidechain is pretty common on the plugins I use. I’m not sure if I’ve seen any that do it automatically, but I don’t own all the plugins…