Rout sidechain input according to user preference

I have a standalone host app wrapping a plugin, where the plugin has a mono main input + mono sidechain input. (it also has outputs, irrelevant for now).

In the preference window I’m letting the user select which of the device input channels is to be routed to the main input, and which is routed to the sidechain (including a “None” option).

I need processBlock() to deliver the input channels according to the preference, i.e. first the main input, then the sidechain input (Where the “None” option would deliver zeros). I couldn’t find how to do it.

By the way, using JUCE 4.2. The given NoiseGate example connects sidechain channels hardcodedly, so it didn’t help me get to the answer.

Any help would be great. Thanks!

You can’t change processBlock itself of course. this is being called for you.
You can however,
re-encapsulate the received AudioBuffer.
You’ll might find this useful for re-ordering pointers.
https://docs.juce.com/master/classHeapBlock.html#details

You can create a zeroed const array but I guess you’re code can understand if there’s “None” by the re-ordered AudioBuffer inputs size.

The question is in what order does processBlock deliver the channels in the first place, and if the order can be manipulated in any way so that processBlock delivers in the order requested.

  1. the order is as you’ve described it here:
    https://docs.juce.com/master/tutorial_audio_bus_layouts.html
    you should be familiar with the BusProperties concept.

  2. I’ve answered you above regarding ability to manipulate. it’s easy and when implemented properly should be very cheap and suitable for real-time performance.