1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-31 03:00:05 +00:00

Add pass-through of sidechain channel in NoiseGate example

This commit is contained in:
hogliux 2016-02-03 10:58:44 +00:00
parent e29e9ee2e3
commit 48ea4da185

View file

@ -21,7 +21,8 @@ public:
addParameter (alpha = new AudioParameterFloat ("alpha", "Alpha", 0.0f, 1.0f, 0.8f));
// add single side-chain bus
busArrangement.inputBuses. add (AudioProcessorBus ("Sidechain", AudioChannelSet::stereo()));
busArrangement.inputBuses. add (AudioProcessorBus ("Sidechain In", AudioChannelSet::stereo()));
busArrangement.outputBuses.add (AudioProcessorBus ("Sidechain Out", AudioChannelSet::stereo()));
}
~NoiseGate() {}
@ -30,13 +31,15 @@ public:
bool setPreferredBusArrangement (bool isInputBus, int busIndex, const AudioChannelSet& preferred) override
{
const int numChannels = preferred.size();
const bool isMainBus = (busIndex == 0);
// do not allow disabling channels
if (numChannels == 0) return false;
// only allow stereo on the side-chain bus
if (busIndex == 1 && numChannels != 2) return false;
// always have the same channel layout on both input and output on the main bus
if (isMainBus && (! AudioProcessor::setPreferredBusArrangement (! isInputBus, busIndex, preferred)))
if (! AudioProcessor::setPreferredBusArrangement (! isInputBus, busIndex, preferred))
return false;
return AudioProcessor::setPreferredBusArrangement (isInputBus, busIndex, preferred);