diff --git a/cmake/enable_sdks.cmake b/cmake/enable_sdks.cmake index 2640b771..19fd1713 100644 --- a/cmake/enable_sdks.cmake +++ b/cmake/enable_sdks.cmake @@ -167,8 +167,6 @@ function(DefineCLAPASVST3Sources) endif() set(wrappersources_vst3 - src/clap_proxy.h - src/clap_proxy.cpp src/wrapasvst3.h src/wrapasvst3.cpp src/wrapasvst3_entry.cpp @@ -660,7 +658,6 @@ if (APPLE) endif() endif() - # Define the extensions target if ( NOT TARGET clap-wrapper-extensions) add_library(clap-wrapper-extensions INTERFACE) @@ -668,6 +665,8 @@ if ( NOT TARGET clap-wrapper-extensions) endif() add_library(clap-wrapper-shared-detail STATIC + src/clap_proxy.h + src/clap_proxy.cpp src/detail/sha1.h src/detail/sha1.cpp src/detail/clap/fsutil.h diff --git a/src/clap_proxy.cpp b/src/clap_proxy.cpp index 3559d2db..2e4dbb23 100644 --- a/src/clap_proxy.cpp +++ b/src/clap_proxy.cpp @@ -1,6 +1,5 @@ #include "clap_proxy.h" #include "detail/clap/fsutil.h" -#include "public.sdk/source/main/pluginfactory.h" #if MAC || LIN #include @@ -116,6 +115,25 @@ const clap_host_tail tail = {tail_changed}; } // namespace HostExt +std::shared_ptr Plugin::createInstance(const clap_plugin_factory* fac, const std::string& id, + Clap::IHost* host) +{ + auto plug = std::shared_ptr(new Plugin(host)); + auto instance = fac->create_plugin(fac, plug->getClapHostInterface(), id.c_str()); + plug->connectClap(instance); + + return plug; +} + +std::shared_ptr Plugin::createInstance(const clap_plugin_factory* fac, size_t idx, + Clap::IHost* host) +{ + auto pc = fac->get_plugin_count(fac); + if (idx < 0 || idx >= pc) return nullptr; + auto desc = fac->get_plugin_descriptor(fac, idx); + return createInstance(fac, desc->id, host); +} + std::shared_ptr Plugin::createInstance(Clap::Library& library, size_t index, IHost* host) { if (library.plugins.size() > index) diff --git a/src/clap_proxy.h b/src/clap_proxy.h index e73a709a..3354f4df 100644 --- a/src/clap_proxy.h +++ b/src/clap_proxy.h @@ -124,7 +124,10 @@ class Raise class Plugin { public: - static std::shared_ptr createInstance(Clap::Library& library, size_t index, IHost* host); + static std::shared_ptr createInstance(const clap_plugin_factory*, const std::string& id, + IHost* host); + static std::shared_ptr createInstance(const clap_plugin_factory*, size_t idx, IHost* host); + static std::shared_ptr createInstance(Clap::Library& library, size_t idx, IHost* host); protected: // only the Clap::Library is allowed to create instances