# Rout sidechain input according to user preference

**URL:** https://forum.juce.com/t/rout-sidechain-input-according-to-user-preference/38098
**Category:** Audio Plugins
**Created:** [March 15, 2020, 1:34pm UTC](https://forum.juce.com/t/rout-sidechain-input-according-to-user-preference/38098 "2020-03-15T13:34:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gilmo](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@gilmo](https://forum.juce.com/u/gilmo)
#### Post date: [March 15, 2020, 1:34pm UTC](https://forum.juce.com/t/rout-sidechain-input-according-to-user-preference/38098/1 "2020-03-15T13:34:18Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![ttg](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ttg/32/14456_2.png) [@ttg](https://forum.juce.com/u/ttg)
#### Post date: [March 15, 2020, 2:24pm UTC](https://forum.juce.com/t/rout-sidechain-input-according-to-user-preference/38098/2 "2020-03-15T14:24:18Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![gilmo](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@gilmo](https://forum.juce.com/u/gilmo)
#### Post date: [March 15, 2020, 3:06pm UTC](https://forum.juce.com/t/rout-sidechain-input-according-to-user-preference/38098/3 "2020-03-15T15:06:46Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ttg](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ttg/32/14456_2.png) [@ttg](https://forum.juce.com/u/ttg)
#### Post date: [March 15, 2020, 4:23pm UTC](https://forum.juce.com/t/rout-sidechain-input-according-to-user-preference/38098/4 "2020-03-15T16:23:37Z")

</div>

1. the order is as you’ve described it here:  
[https://docs.juce.com/master/tutorial\_audio\_bus\_layouts.html](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.
