diff --git a/src/clap_proxy.cpp b/src/clap_proxy.cpp index 67867ff1..f0729057 100644 --- a/src/clap_proxy.cpp +++ b/src/clap_proxy.cpp @@ -501,10 +501,6 @@ const void* Plugin::clapExtension(const clap_host* /*host*/, const char* extensi { return &HostExt::tail; } - if (!strcmp(extension, CLAP_EXT_RENDER)) - { - // TODO: implement CLAP_EXT_RENDER - } if (!strcmp(extension, CLAP_EXT_STATE)) return &HostExt::state; if (!strcmp(extension, CLAP_EXT_CONTEXT_MENU)) return &HostExt::context_menu; diff --git a/src/wrapasvst3.cpp b/src/wrapasvst3.cpp index 6ce37dd5..43b18f8f 100644 --- a/src/wrapasvst3.cpp +++ b/src/wrapasvst3.cpp @@ -188,6 +188,22 @@ tresult PLUGIN_API ClapAsVst3::setupProcessing(Vst::ProcessSetup& newSetup) { return kResultFalse; } + if (_plugin->_ext._render) + { + if (_plugin->_ext._render->has_hard_realtime_requirement(_plugin->_plugin) && + newSetup.processMode != Vst::kRealtime) + { + return kResultFalse; + } + clap_plugin_render_mode new_render_mode = CLAP_RENDER_REALTIME; + if (newSetup.processMode == Vst::kOffline) + { + new_render_mode = CLAP_RENDER_OFFLINE; + } + // handling Vst::kPrefetch as Vst::kRealTime + + _plugin->_ext._render->set(_plugin->_plugin, new_render_mode); + } _plugin->setSampleRate(newSetup.sampleRate); _plugin->setBlockSizes(newSetup.maxSamplesPerBlock, newSetup.maxSamplesPerBlock); @@ -330,6 +346,39 @@ tresult PLUGIN_API ClapAsVst3::activateBus(Vst::MediaType type, Vst::BusDirectio return super::activateBus(type, dir, index, state); } +tresult PLUGIN_API ClapAsVst3::setIoMode(Vst::IoMode mode) +{ +#if 0 // disabled for now + // since there is always the override in setupProcessing, setting the mode here + // does not make much sense - even for a VST3 + // so for now this stays kUnimplemented until we find a proper use case + + auto rext = _plugin->_ext._render; + + if (rext) + { + auto mainthread = _plugin->AlwaysMainThread(); + + bool realtime_only = rext->has_hard_realtime_requirement(_plugin->_plugin); + switch (mode) + { + case Vst::kOfflineProcessing: + if (realtime_only) return kResultFalse; + return (rext->set(_plugin->_plugin, CLAP_RENDER_OFFLINE)) ? kResultOk : kResultFalse; + break; + case Vst::kSimple: + case Vst::kAdvanced: + // both does not make any difference + return (rext->set(_plugin->_plugin, CLAP_RENDER_REALTIME)) ? kResultOk : kResultFalse; + break; + default: + return kNotImplemented; + } + } +#endif + return super::setIoMode(mode); +} + //----------------------------------------------------------------------------- tresult PLUGIN_API ClapAsVst3::setComponentHandler(Vst::IComponentHandler* handler) diff --git a/src/wrapasvst3.h b/src/wrapasvst3.h index d6438a7a..b9fb6149 100644 --- a/src/wrapasvst3.h +++ b/src/wrapasvst3.h @@ -149,6 +149,8 @@ class ClapAsVst3 : public Steinberg::Vst::SingleComponentEffect, tresult PLUGIN_API activateBus(Vst::MediaType type, Vst::BusDirection dir, int32 index, TBool state) override; + tresult PLUGIN_API setIoMode(Vst::IoMode mode) override; + // from IEditController tresult PLUGIN_API setComponentHandler(Vst::IComponentHandler* handler) override;