Skip to content

Commit

Permalink
Add an AUv2 factory option for subtype etc...
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
baconpaul committed Sep 10, 2023
1 parent dd5e512 commit 38c15f7
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 13 deletions.
18 changes: 9 additions & 9 deletions cmake/enable_sdks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions include/clapwrapper/auv2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include "clap/private/macros.h"
#include <cstdint>

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;
37 changes: 33 additions & 4 deletions src/detail/auv2/build-helper/build-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct auInfo

bool buildUnitsFromClap(const std::string &clapfile, const std::string &clapname, std::string &manu, std::string &manuName, std::vector<auInfo> &units)
{
std::cout << "F " << manu << " " << manuName << std::endl;
Clap::Library loader;
if (!loader.load(clapfile.c_str()))
{
Expand All @@ -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)
Expand All @@ -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)
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -152,16 +181,16 @@ 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;
}
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};
Expand Down
3 changes: 3 additions & 0 deletions src/detail/clap/fsutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,14 @@ namespace Clap
static_cast<const clap_plugin_factory *>(_pluginEntry->get_factory(CLAP_PLUGIN_FACTORY_ID));
_pluginFactoryVst3Info =
static_cast<const clap_plugin_factory_as_vst3*>(_pluginEntry->get_factory(CLAP_PLUGIN_FACTORY_INFO_VST3));
_pluginFactoryAUv2Info =
static_cast<const clap_plugin_factory_as_auv2*>(_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);
Expand Down
2 changes: 2 additions & 0 deletions src/detail/clap/fsutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace fs = std::filesystem;
#endif

#include "clapwrapper/vst3.h"
#include "clapwrapper/auv2.h"

#if MAC
#include <CoreFoundation/CoreFoundation.h>
Expand All @@ -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<const clap_plugin_descriptor_t*> plugins;
const clap_plugin_info_as_vst3_t* get_vst3_info(uint32_t index);

Expand Down

0 comments on commit 38c15f7

Please sign in to comment.