From 38c15f78338cfd4335f06b8156a8771c721a17e9 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sat, 9 Sep 2023 20:27:32 -0400 Subject: [PATCH] Add an AUv2 factory option for subtype etc... The subtype etc can be determined bu either cmake arguments, a hash of the id, or explicit sets of optiosn through a factor akin to the vst3 factory. This commit implements the latter. Once merged, conduit will use this to explicitly set its vst3 and auv2 options. --- cmake/enable_sdks.cmake | 18 ++++----- include/clapwrapper/auv2.h | 24 ++++++++++++ src/detail/auv2/build-helper/build-helper.cpp | 37 +++++++++++++++++-- src/detail/clap/fsutil.cpp | 3 ++ src/detail/clap/fsutil.h | 2 + 5 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 include/clapwrapper/auv2.h diff --git a/cmake/enable_sdks.cmake b/cmake/enable_sdks.cmake index 16178b8b..4a63e922 100644 --- a/cmake/enable_sdks.cmake +++ b/cmake/enable_sdks.cmake @@ -473,14 +473,6 @@ if (APPLE) message(FATAL_ERROR "clap-wrapper: auv2-target must be a target") endif() - if (NOT DEFINED AUV2_MANUFACTURER_NAME) - message(FATAL_ERROR "clap-wrapper: For now please specify AUV2 manufacturer name") - endif() - - if (NOT DEFINED AUV2_MANUFACTURER_CODE) - message(FATAL_ERROR "clap-wrapper: For now please specify AUV2 manufacturer code (4 chars)") - endif() - if (NOT DEFINED AUV2_BUNDLE_VERSION) message(WARNING "clap-wrapper: bundle version not defined. Chosing 1") set(AUV2_BUNDLE_VERSION 1) @@ -531,7 +523,15 @@ if (APPLE) endif() if (NOT DEFINED AUV2_SUBTYPE_CODE) - message(FATAL_ERROR "clap-wrapper: For now please specify AUV2 subtype code (4 chars)") + message(FATAL_ERROR "clap-wrapper: For nontarget build specify AUV2 subtype code (4 chars)") + endif() + + if (NOT DEFINED AUV2_MANUFACTURER_NAME) + message(FATAL_ERROR "clap-wrapper: For nontarget build specify AUV2 manufacturer name") + endif() + + if (NOT DEFINED AUV2_MANUFACTURER_CODE) + message(FATAL_ERROR "clap-wrapper: For nontarget build specify AUV2 manufacturer code (4 chars)") endif() if (NOT DEFINED AUV2_INSTRUMENT_TYPE) diff --git a/include/clapwrapper/auv2.h b/include/clapwrapper/auv2.h new file mode 100644 index 00000000..4f37dcb3 --- /dev/null +++ b/include/clapwrapper/auv2.h @@ -0,0 +1,24 @@ +#pragma once + +#include "clap/private/macros.h" +#include + +static const CLAP_CONSTEXPR char CLAP_PLUGIN_FACTORY_INFO_AUV2[] = + "clap.plugin-factory-info-as-auv2.draft0"; + +typedef struct clap_plugin_info_as_auv2 +{ + char au_type[5]; // the au_type. If empty (best choice) use the features[0] to aumu aufx aumi + char au_subt[5]; // the subtype. If empty (worst choice) we try a bad 32 bit hash of the id +} clap_plugin_info_as_auv2_t; + +typedef struct clap_plugin_factory_as_auv2 +{ + // optional values for the Steinberg::PFactoryInfo structure + const char *manufacturer_code; // your 'manu' field + const char *manufacturer_name; // your manufacturer display name + + // populate information about this particular auv2. Return false if we cannot. + bool(CLAP_ABI *get_auv2_info)(const clap_plugin_factory_as_auv2 *factory, uint32_t index, + clap_plugin_info_as_auv2_t *info); +} clap_plugin_factory_as_auv2_t; \ No newline at end of file diff --git a/src/detail/auv2/build-helper/build-helper.cpp b/src/detail/auv2/build-helper/build-helper.cpp index 67979773..fd77dc25 100644 --- a/src/detail/auv2/build-helper/build-helper.cpp +++ b/src/detail/auv2/build-helper/build-helper.cpp @@ -60,6 +60,7 @@ struct auInfo bool buildUnitsFromClap(const std::string &clapfile, const std::string &clapname, std::string &manu, std::string &manuName, std::vector &units) { + std::cout << "F " << manu << " " << manuName << std::endl; Clap::Library loader; if (!loader.load(clapfile.c_str())) { @@ -69,6 +70,19 @@ bool buildUnitsFromClap(const std::string &clapfile, const std::string &clapname int idx{0}; + if (manu.empty() && loader._pluginFactoryAUv2Info == nullptr) + { + std::cout << "[ERROR] No manufacturer provider and no auv2 info available" << std::endl; + return false; + } + + if (manu.empty()) + { + manu = loader._pluginFactoryAUv2Info->manufacturer_code; + manuName = loader._pluginFactoryAUv2Info->manufacturer_name; + std::cout << " - using factor manufacturer '" << manuName << "' (" << manu << ")" << std::endl; + } + static const char *encoder = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"; for (const auto *clapPlug : loader.plugins) @@ -95,7 +109,6 @@ bool buildUnitsFromClap(const std::string &clapfile, const std::string &clapname u.manu = manu; u.manunm = manuName; - auto f = clapPlug->features[0]; if (f == nullptr || strcmp(f, CLAP_PLUGIN_FEATURE_INSTRUMENT) == 0) { @@ -115,8 +128,24 @@ bool buildUnitsFromClap(const std::string &clapfile, const std::string &clapname u.type = "aumu"; } + if (loader._pluginFactoryAUv2Info) + { + clap_plugin_info_as_auv2_t v2inf; + auto res = loader._pluginFactoryAUv2Info->get_auv2_info(loader._pluginFactoryAUv2Info, + idx, + &v2inf); + if (v2inf.au_type[0] != 0) + { + u.type = v2inf.au_type; + } + if (v2inf.au_subt[0] != 0) + { + u.subt = v2inf.au_subt; + } + } units.push_back(u); + idx++; } return true; } @@ -152,7 +181,7 @@ int main(int argc, char **argv) } else if (std::string(argv[1]) == "--fromclap") { - if (argc != 6) + if (argc < 4) { std::cout << "[ERROR] Configuration incorrect. Got " << argc << " arguments in fromclap" << std::endl; return 6; @@ -160,8 +189,8 @@ int main(int argc, char **argv) int idx = 2; auto clapname = std::string(argv[idx++]); auto clapfile = std::string(argv[idx++]); - auto mcode = std::string(argv[idx++]); - auto mname = std::string(argv[idx++]); + auto mcode = (idx < argc) ? std::string(argv[idx++]) : std::string(); + auto mname = (idx < argc) ? std::string(argv[idx++]) : std::string(); try { auto p = fs::path{clapfile}; diff --git a/src/detail/clap/fsutil.cpp b/src/detail/clap/fsutil.cpp index cb9260e5..8d34b391 100644 --- a/src/detail/clap/fsutil.cpp +++ b/src/detail/clap/fsutil.cpp @@ -196,11 +196,14 @@ namespace Clap static_cast(_pluginEntry->get_factory(CLAP_PLUGIN_FACTORY_ID)); _pluginFactoryVst3Info = static_cast(_pluginEntry->get_factory(CLAP_PLUGIN_FACTORY_INFO_VST3)); + _pluginFactoryAUv2Info = + static_cast(_pluginEntry->get_factory(CLAP_PLUGIN_FACTORY_INFO_AUV2)); // detect plugins that do not check the CLAP_PLUGIN_FACTORY_ID if ((void*)_pluginFactory == (void*)_pluginFactoryVst3Info) { _pluginFactoryVst3Info = nullptr; + _pluginFactoryAUv2Info = nullptr; } auto count = _pluginFactory->get_plugin_count(_pluginFactory); diff --git a/src/detail/clap/fsutil.h b/src/detail/clap/fsutil.h index 597717e4..a825fa94 100644 --- a/src/detail/clap/fsutil.h +++ b/src/detail/clap/fsutil.h @@ -31,6 +31,7 @@ namespace fs = std::filesystem; #endif #include "clapwrapper/vst3.h" +#include "clapwrapper/auv2.h" #if MAC #include @@ -53,6 +54,7 @@ namespace Clap const clap_plugin_entry_t* _pluginEntry = nullptr; const clap_plugin_factory_t* _pluginFactory = nullptr; const clap_plugin_factory_as_vst3* _pluginFactoryVst3Info = nullptr; + const clap_plugin_factory_as_auv2* _pluginFactoryAUv2Info = nullptr; std::vector plugins; const clap_plugin_info_as_vst3_t* get_vst3_info(uint32_t index);