From 5aad9feadee9b4f8c603237a7c6c08423898448f Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 14 Aug 2024 05:52:29 -0400 Subject: [PATCH] Implement SingleComponentEffect::getBusInfo and fix Ardour (#285) Ardour uses getBusInfo to set up busses even though later we call setBusInfo, and so as a result didn't recieve the kDefaultActive flag we set when we setup processing. This meant that Ardour would not activate auxilliary busses in multi-out effects so our process loop would find an invalid configuration and not call the clap. Defacto this meant "no sound in shortcircuit xt in the wrapper in ardour". This imsplementation fixes the issue. --- src/detail/vst3/process.cpp | 12 ++++++++++-- src/wrapasvst3.cpp | 30 ++++++++++++++++++++++++++++++ src/wrapasvst3.h | 2 ++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/detail/vst3/process.cpp b/src/detail/vst3/process.cpp index 2427afab..c1d6412a 100644 --- a/src/detail/vst3/process.cpp +++ b/src/detail/vst3/process.cpp @@ -391,19 +391,27 @@ void ProcessAdapter::process(Steinberg::Vst::ProcessData& data) auto inbusses = _audioinputs->size(); for (auto i = 0U; i < inbusses; ++i) { - if (_vstdata->inputs[i].numChannels > 0) + if (_vstdata->inputs[i].numChannels == (Steinberg::int32)_input_ports[i].channel_count) + { _input_ports[i].data32 = _vstdata->inputs[i].channelBuffers32; + } else + { doProcess = false; + } } auto outbusses = _audiooutputs->size(); for (auto i = 0U; i < outbusses; ++i) { - if (_vstdata->outputs[i].numChannels > 0) + if (_vstdata->outputs[i].numChannels == (Steinberg::int32)_output_ports[i].channel_count) + { _output_ports[i].data32 = _vstdata->outputs[i].channelBuffers32; + } else + { doProcess = false; + } } if (doProcess) _plugin->process(_plugin, &_processData); diff --git a/src/wrapasvst3.cpp b/src/wrapasvst3.cpp index 9ab0dc20..f26b1af1 100644 --- a/src/wrapasvst3.cpp +++ b/src/wrapasvst3.cpp @@ -1486,3 +1486,33 @@ void ClapAsVst3::clearContextMenu() vst3ContextMenu.reset(); contextmenuitems.clear(); } + +tresult ClapAsVst3::getBusInfo(Vst::MediaType type, Vst::BusDirection dir, int32 index, + Vst::BusInfo& bus) +{ + if (_plugin->_ext._audioports) + { + if (type == Vst::kAudio) + { + clap_audio_port_info_t info; + if (_plugin->_ext._audioports->get(_plugin->_plugin, (uint32_t)index, (dir == Vst::kInput), &info)) + { + bus.mediaType = Vst::kAudio; + bus.channelCount = info.channel_count; + bus.direction = dir; + bus.busType = (info.flags & CLAP_AUDIO_PORT_IS_MAIN) ? Vst::kMain : Vst::kAux; + bus.flags = Vst::BusInfo::kDefaultActive; + + UString wrapper(&bus.name[0], str16BufferSize(Steinberg::Vst::String128)); + wrapper.assign(info.name, (Steinberg::int32)CLAP_NAME_SIZE); + + return kResultOk; + } + else + { + return kResultFalse; + } + } + } + return SingleComponentEffect::getBusInfo(type, dir, index, bus); +} diff --git a/src/wrapasvst3.h b/src/wrapasvst3.h index 251d9f3b..9444203a 100644 --- a/src/wrapasvst3.h +++ b/src/wrapasvst3.h @@ -152,6 +152,8 @@ class ClapAsVst3 : public Steinberg::Vst::SingleComponentEffect, Vst::SpeakerArrangement* outputs, int32 numOuts) override; tresult PLUGIN_API getBusArrangement(Vst::BusDirection dir, int32 index, Vst::SpeakerArrangement& arr) override; + tresult PLUGIN_API getBusInfo(Vst::MediaType type, Vst::BusDirection dir, int32 index, + Vst::BusInfo& bus) override; tresult PLUGIN_API activateBus(Vst::MediaType type, Vst::BusDirection dir, int32 index, TBool state) override;