To add a sidechain audio input to the again VST3 plug-in is actually very simple.
You need to add the input in the initialize(…) method of the AGain class:
C++
-
addAudioInput (USTRING ("Sidechain Mono In"), SpeakerArr::kMono, kAux);
After that you can check in the process function if the sidechain is active :
C++
-
BusList* busList = getBusList (kAudio, kInput);
-
Bus* bus = busList ? (Bus*)busList->at (1) : 0;
-
if (bus && bus->isActive ())
-
{
-
// sidechain is active !!!
-
float* sidechainIn = data.inputs[1].channelBuffers32[0];
-
// do some processing with the input samples …
-
}
To get this all working with AGain there are some more change to be done in AGain::setBusArrangements(…):
C++
-
tresult PLUGIN_API AGain::setBusArrangements (SpeakerArrangement* inputs, int32 numIns, SpeakerArrangement* outputs, int32 numOuts)
-
{
-
if (numIns == 2 && numOuts == 1) // Sidechain chain, was: numIns == 1
-
{
-
if (inputs[0] == SpeakerArr::kMono && outputs[0] == SpeakerArr::kMono)
-
{
-
AudioBus* bus = (AudioBus*)(audioInputs.at (0));
-
if (bus)
-
{
-
if (bus->getArrangement () != SpeakerArr::kMono)
-
{
-
removeAudioBusses ();
-
addAudioInput (USTRING ("Mono In"), SpeakerArr::kMono);
-
addAudioOutput (USTRING ("Mono Out"), SpeakerArr::kMono);
-
addAudioInput (USTRING ("Sidechain Mono In"), SpeakerArr::kMono, kAux); // add sidechain, always mono
-
}
-
return kResultOk;
-
}
-
}
-
else
-
{
-
AudioBus* bus = (AudioBus*)(audioInputs.at (0));
-
if (bus)
-
{
-
if (bus->getArrangement () != SpeakerArr::kStereo)
-
{
-
removeAudioBusses ();
-
addAudioInput (USTRING ("Stereo In"), SpeakerArr::kStereo);
-
addAudioOutput (USTRING ("Stereo Out"), SpeakerArr::kStereo);
-
addAudioInput (USTRING ("Sidechain Mono In"), SpeakerArr::kMono, kAux); // add sidechain, always mono
-
}
-
return kResultOk;
-
}
-
}
-
}
-
return kResultFalse;
-
}