Side-chains

This commit is contained in:
Robin E. R. Davies
2025-09-30 19:59:47 -04:00
parent ca1d4bad69
commit 25494d6f3c
19 changed files with 723 additions and 180 deletions
+54 -1
View File
@@ -176,6 +176,60 @@ std::vector<float *> Lv2Pedalboard::PrepareItems(
auto bufferR = inputBuffers[1];
}
}
// Connect sidechain buffers.
if (pLv2Effect->GetNumberOfSidechainAudioBuffers() != 0)
{
if (item.sideChainInputId() == -2) // -2 means "use pedalboard inputs".
{
for (size_t i = 0; i < pLv2Effect->GetNumberOfSidechainAudioBuffers(); ++i)
{
if (i < this->pedalboardInputBuffers.size())
{
pLv2Effect->SetAudioSidechainBuffer(i, this->pedalboardInputBuffers[i]);
}
else
{
// just use the first output buffer for all sidechain inputs.
pLv2Effect->SetAudioSidechainBuffer(i, this->pedalboardInputBuffers[0]);
}
}
} else if (item.sideChainInputId() != -1) {
IEffect *pSideChainInput = GetEffect(item.sideChainInputId());
if (pSideChainInput)
{
for (size_t i = 0; i < pLv2Effect->GetNumberOfSidechainAudioBuffers(); ++i)
{
if (i < pSideChainInput->GetNumberOfOutputAudioBuffers())
{
pLv2Effect->SetAudioSidechainBuffer(i, pSideChainInput->GetAudioOutputBuffer(i));
}
else
{
// just use the first output buffer for all sidechain inputs.
pLv2Effect->SetAudioSidechainBuffer(i, pSideChainInput->GetAudioOutputBuffer(0));
}
}
} else {
throw std::runtime_error("Internal error: Sidechain input IEffect not found.");
}
}
else
{
// No sidechain input. Feed zero buffer to all sidechain audio ports..
for (size_t i = 0; i < pLv2Effect->GetNumberOfSidechainAudioBuffers(); ++i)
{
// just use one buffer for all plugins
if (!this->pedalboardSidechainBuffer)
{
this->pedalboardSidechainBuffer = CreateNewAudioBuffer();
}
pLv2Effect->SetAudioSidechainBuffer(i, this->pedalboardSidechainBuffer);
}
}
}
// check to see whether we need buffer staging.
bool requiresBufferStaging = false;
@@ -194,7 +248,6 @@ std::vector<float *> Lv2Pedalboard::PrepareItems(
}
}
if (!requiresBufferStaging)
{
this->processActions.push_back(