From 2da314170660432db7a39ed2da8a7fe577181b71 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 19 Mar 2024 02:24:19 +0100 Subject: [PATCH] Consolidate plugin_factory, move to parent class --- libs/ardour/ardour/plug_insert_base.h | 2 + libs/ardour/ardour/plugin_insert.h | 1 - libs/ardour/plug_insert_base.cc | 80 +++++++++++++++++++++++++++ libs/ardour/plugin_insert.cc | 77 -------------------------- 4 files changed, 82 insertions(+), 78 deletions(-) diff --git a/libs/ardour/ardour/plug_insert_base.h b/libs/ardour/ardour/plug_insert_base.h index 4832791c2f..a4e9d542ef 100644 --- a/libs/ardour/ardour/plug_insert_base.h +++ b/libs/ardour/ardour/plug_insert_base.h @@ -104,6 +104,8 @@ public: }; protected: + static std::shared_ptr plugin_factory (std::shared_ptr); + bool parse_plugin_type (XMLNode const&, PluginType&, std::string&) const; std::shared_ptr find_and_load_plugin (Session&, XMLNode const&, PluginType&, std::string const&, bool& any_vst); diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index 2c76b3ce16..bde43d256c 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -404,7 +404,6 @@ private: bool check_inplace (); void mapping_changed (); - std::shared_ptr plugin_factory (std::shared_ptr); void add_plugin (std::shared_ptr); void plugin_removed (std::weak_ptr); diff --git a/libs/ardour/plug_insert_base.cc b/libs/ardour/plug_insert_base.cc index 24c9e893bb..73eecdecce 100644 --- a/libs/ardour/plug_insert_base.cc +++ b/libs/ardour/plug_insert_base.cc @@ -19,9 +19,30 @@ #include "ardour/plug_insert_base.h" #include "ardour/ardour.h" #include "ardour/automation_control.h" +#include "ardour/ladspa_plugin.h" #include "ardour/luaproc.h" #include "ardour/lv2_plugin.h" +#ifdef WINDOWS_VST_SUPPORT +#include "ardour/windows_vst_plugin.h" +#endif + +#ifdef LXVST_SUPPORT +#include "ardour/lxvst_plugin.h" +#endif + +#ifdef MACVST_SUPPORT +#include "ardour/mac_vst_plugin.h" +#endif + +#ifdef VST3_SUPPORT +#include "ardour/vst3_plugin.h" +#endif + +#ifdef AUDIOUNIT_SUPPORT +#include "ardour/audio_unit.h" +#endif + #include "pbd/i18n.h" using namespace PBD; @@ -201,6 +222,65 @@ PlugInsertBase::preset_load_set_value (uint32_t p, float v) /* ****************************************************************************/ +std::shared_ptr +PlugInsertBase::plugin_factory (std::shared_ptr other) +{ + std::shared_ptr lp; + std::shared_ptr lua; + std::shared_ptr lv2p; +#ifdef WINDOWS_VST_SUPPORT + std::shared_ptr vp; +#endif +#ifdef LXVST_SUPPORT + std::shared_ptr lxvp; +#endif +#ifdef MACVST_SUPPORT + std::shared_ptr mvp; +#endif +#ifdef VST3_SUPPORT + std::shared_ptr vst3; +#endif +#ifdef AUDIOUNIT_SUPPORT + std::shared_ptr ap; +#endif + + if ((lp = std::dynamic_pointer_cast (other)) != 0) { + return std::shared_ptr (new LadspaPlugin (*lp)); + } else if ((lua = std::dynamic_pointer_cast (other)) != 0) { + return std::shared_ptr (new LuaProc (*lua)); + } else if ((lv2p = std::dynamic_pointer_cast (other)) != 0) { + return std::shared_ptr (new LV2Plugin (*lv2p)); +#ifdef WINDOWS_VST_SUPPORT + } else if ((vp = std::dynamic_pointer_cast (other)) != 0) { + return std::shared_ptr (new WindowsVSTPlugin (*vp)); +#endif +#ifdef LXVST_SUPPORT + } else if ((lxvp = std::dynamic_pointer_cast (other)) != 0) { + return std::shared_ptr (new LXVSTPlugin (*lxvp)); +#endif +#ifdef MACVST_SUPPORT + } else if ((mvp = std::dynamic_pointer_cast (other)) != 0) { + return std::shared_ptr (new MacVSTPlugin (*mvp)); +#endif +#ifdef VST3_SUPPORT + } else if ((vst3 = std::dynamic_pointer_cast (other)) != 0) { + return std::shared_ptr (new VST3Plugin (*vst3)); +#endif +#ifdef AUDIOUNIT_SUPPORT + } else if ((ap = std::dynamic_pointer_cast (other)) != 0) { + return std::shared_ptr (new AUPlugin (*ap)); +#endif + } + + fatal << string_compose (_("programming error: %1"), + X_("unknown plugin type in PlugInsertBase::plugin_factory")) + << endmsg; + abort(); /*NOTREACHED*/ + return std::shared_ptr ((Plugin*) 0); +} + +/* ****************************************************************************/ + PlugInsertBase::PluginControl::PluginControl (Session& s, PlugInsertBase* p, const Evoral::Parameter& param, diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 5d01cb90e0..114ee3fc86 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -44,27 +44,6 @@ #include "ardour/plugin.h" #include "ardour/plugin_insert.h" #include "ardour/port.h" - -#ifdef WINDOWS_VST_SUPPORT -#include "ardour/windows_vst_plugin.h" -#endif - -#ifdef LXVST_SUPPORT -#include "ardour/lxvst_plugin.h" -#endif - -#ifdef MACVST_SUPPORT -#include "ardour/mac_vst_plugin.h" -#endif - -#ifdef VST3_SUPPORT -#include "ardour/vst3_plugin.h" -#endif - -#ifdef AUDIOUNIT_SUPPORT -#include "ardour/audio_unit.h" -#endif - #include "ardour/session.h" #include "ardour/types.h" @@ -1557,62 +1536,6 @@ PluginInsert::reset_parameters_to_default () return all; } -std::shared_ptr -PluginInsert::plugin_factory (std::shared_ptr other) -{ - std::shared_ptr lp; - std::shared_ptr lua; - std::shared_ptr lv2p; -#ifdef WINDOWS_VST_SUPPORT - std::shared_ptr vp; -#endif -#ifdef LXVST_SUPPORT - std::shared_ptr lxvp; -#endif -#ifdef MACVST_SUPPORT - std::shared_ptr mvp; -#endif -#ifdef VST3_SUPPORT - std::shared_ptr vst3; -#endif -#ifdef AUDIOUNIT_SUPPORT - std::shared_ptr ap; -#endif - - if ((lp = std::dynamic_pointer_cast (other)) != 0) { - return std::shared_ptr (new LadspaPlugin (*lp)); - } else if ((lua = std::dynamic_pointer_cast (other)) != 0) { - return std::shared_ptr (new LuaProc (*lua)); - } else if ((lv2p = std::dynamic_pointer_cast (other)) != 0) { - return std::shared_ptr (new LV2Plugin (*lv2p)); -#ifdef WINDOWS_VST_SUPPORT - } else if ((vp = std::dynamic_pointer_cast (other)) != 0) { - return std::shared_ptr (new WindowsVSTPlugin (*vp)); -#endif -#ifdef LXVST_SUPPORT - } else if ((lxvp = std::dynamic_pointer_cast (other)) != 0) { - return std::shared_ptr (new LXVSTPlugin (*lxvp)); -#endif -#ifdef MACVST_SUPPORT - } else if ((mvp = std::dynamic_pointer_cast (other)) != 0) { - return std::shared_ptr (new MacVSTPlugin (*mvp)); -#endif -#ifdef VST3_SUPPORT - } else if ((vst3 = std::dynamic_pointer_cast (other)) != 0) { - return std::shared_ptr (new VST3Plugin (*vst3)); -#endif -#ifdef AUDIOUNIT_SUPPORT - } else if ((ap = std::dynamic_pointer_cast (other)) != 0) { - return std::shared_ptr (new AUPlugin (*ap)); -#endif - } - - fatal << string_compose (_("programming error: %1"), - X_("unknown plugin type in PluginInsert::plugin_factory")) - << endmsg; - abort(); /*NOTREACHED*/ - return std::shared_ptr ((Plugin*) 0); -} void PluginInsert::set_input_map (uint32_t num, ChanMapping m) {