From 4bf6a81d6e38e16ef38db7c9689b9b35de56d94b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 24 Nov 2022 19:28:28 +0100 Subject: [PATCH 1/2] VST3 channel buffers are per bus Previously all inputs (num_channels) were assumed to be on the first bus. However Vst::ProcessData's input/output is an array pointing to instances of Vst::AudioBusBuffers (not a pointer to a single instance). This fixes CV ports (optional busses) for Cardinal VST3, and likely also sidechain inputs for other processors. --- distrho/src/DistrhoPluginVST3.cpp | 32 +++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp index b81c59593..647a500be 100644 --- a/distrho/src/DistrhoPluginVST3.cpp +++ b/distrho/src/DistrhoPluginVST3.cpp @@ -1446,13 +1446,17 @@ class PluginVst3 #if DISTRHO_PLUGIN_NUM_INPUTS > 0 if (data->inputs != nullptr) { - for (int32_t j = 0; j < data->inputs->num_channels; ++j) - { - while (!fEnabledInputs[i] && i < DISTRHO_PLUGIN_NUM_INPUTS) - inputs[i++] = fDummyAudioBuffer; + for (int32_t b = 0; b < data->num_input_buses; ++b) { + for (int32_t j = 0; j < data->inputs[b].num_channels; ++j) + { + DISTRHO_SAFE_ASSERT_INT_BREAK(i < DISTRHO_PLUGIN_NUM_INPUTS, i); + if (!fEnabledInputs[i] && i < DISTRHO_PLUGIN_NUM_INPUTS) { + inputs[i++] = fDummyAudioBuffer; + continue; + } - DISTRHO_SAFE_ASSERT_INT_BREAK(i < DISTRHO_PLUGIN_NUM_INPUTS, i); - inputs[i++] = data->inputs->channel_buffers_32[j]; + inputs[i++] = data->inputs[b].channel_buffers_32[j]; + } } } #endif @@ -1465,13 +1469,17 @@ class PluginVst3 #if DISTRHO_PLUGIN_NUM_OUTPUTS > 0 if (data->outputs != nullptr) { - for (int32_t j = 0; j < data->outputs->num_channels; ++j) - { - while (!fEnabledOutputs[i] && i < DISTRHO_PLUGIN_NUM_OUTPUTS) - outputs[i++] = fDummyAudioBuffer; + for (int32_t b = 0; b < data->num_output_buses; ++b) { + for (int32_t j = 0; j < data->outputs[b].num_channels; ++j) + { + DISTRHO_SAFE_ASSERT_INT_BREAK(i < DISTRHO_PLUGIN_NUM_OUTPUTS, i); + if (!fEnabledOutputs[i] && i < DISTRHO_PLUGIN_NUM_OUTPUTS) { + outputs[i++] = fDummyAudioBuffer; + continue; + } - DISTRHO_SAFE_ASSERT_INT_BREAK(i < DISTRHO_PLUGIN_NUM_OUTPUTS, i); - outputs[i++] = data->outputs->channel_buffers_32[j]; + outputs[i++] = data->outputs[b].channel_buffers_32[j]; + } } } #endif From e6d860041a0cc4dfad2958991e0e4da72bfdcd51 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 24 Nov 2022 19:31:33 +0100 Subject: [PATCH 2/2] Fix VST setAudioBusArrangement, en/disable individual ports Vst::SpeakerArrangement is a bitset with each bit corresponding to a port of the current bus. --- distrho/src/DistrhoPluginVST3.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp index 647a500be..6883bfe5c 100644 --- a/distrho/src/DistrhoPluginVST3.cpp +++ b/distrho/src/DistrhoPluginVST3.cpp @@ -2810,6 +2810,7 @@ class PluginVst3 // d_debug("setAudioBusArrangement %d %d | %d %lx", (int)isInput, numBuses, busId, arr); + size_t nth_speaker = 0; for (uint32_t i=0; i(busInfo, port.groupId, busId); - - // fail if host tries to map it to anything else - // FIXME should we allow to map speaker to zero as a way to disable it? - if (earr != arr /* && arr != 0 */) - { - ok = false; - continue; - } - - enabledPorts[i] = arr != 0; + v3_speaker_arrangement earr = (uint64_t)1 << nth_speaker; + enabledPorts[i] = 0 != (arr & earr); + ++nth_speaker; } }