Hi guys,
I’m having some problems with a plugin that needs a sidechain input. The plugin can be loaded either as mono or stereo.
I enabled the sidechain this way:
AudioProcessor (BusesProperties().withInput ("Input", AudioChannelSet::stereo(), true)
.withOutput ("Output", AudioChannelSet::stereo(), true)
.withInput ("Sidechain", AudioChannelSet::stereo(), true))
Now, since I’m using dsp::Oversampling, I use dsp::ProcessContextReplacing for the actual process and it’s called on each processBlock cycle. Since I need to pass a block containing both the main and the sidechain buses, I use a 4 channel buffer that I set this way:
(from processBlock)
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
//get buffers from inputs
auto mainInputOutput = getBusBuffer (buffer, true, 0);
auto sideChainInput = getBusBuffer (buffer, true, 1);
auto numSamples = buffer.getNumSamples();
/*
QUAD CHANNEL BUFFER FOR SIDECHAIN
Chan 0-1: main input/output
Chan 2-3: sidechain input/ouput
*/
quadBuffer.copyFrom(0, 0, mainInputOutput, 0, 0, numSamples);
quadBuffer.copyFrom(1, 0, mainInputOutput, (mainInputOutput.getNumChannels() > 1 ? 1 : 0), 0, numSamples);
if(useSideChain && sideChainInput.getNumChannels() > 0)
{
quadBuffer.copyFrom(2, 0, sideChainInput, 0, 0, numSamples);
quadBuffer.copyFrom(3, 0, sideChainInput, (sideChainInput.getNumChannels() > 1 ? 1 : 0), 0, numSamples);
}
else
{
quadBuffer.copyFrom(2, 0, mainInputOutput, 0, 0, numSamples);
quadBuffer.copyFrom(3, 0, mainInputOutput, (mainInputOutput.getNumChannels() > 1 ? 1 : 0), 0, numSamples);
}
The Oversampler is set to process up to 4 channels.
PROBLEM:
The sidechain seems to work, but as soon as Input Monitoring is enabled on any DAW, the sound shows a lot of glitches and “screams”. Disabling the Input Monitoring leads, then, to no audio coming out the plugin unless you don’t bypass it from the DAW and enable it again.
I suspected something went wrong with the quadBuffer above, but I tried forcing the process to a single channel only, without dealing with the sidechain channel and I get the same results.
If I move the processing away from ProcessContextReplacing back to processBlock (so dealing with the buffers instead of the AudioBlocks), everything works fine but I would lose the oversampling, since I rely on the dsp::Oversampler class.
Any advice?
Thanks