Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some auv2 changes for clap saw demo test case #121

Merged
merged 4 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions cmake/enable_sdks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ function(target_add_vst3_wrapper)

if (APPLE)
if ("${V3_BUNDLE_IDENTIFIER}" STREQUAL "")
set(V3_BUNDLE_IDENTIFIER "org.cleveraudio.wrapper.${outidentifier}.vst3")
string(REPLACE "_" "-" repout ${outidentifier})
set(V3_BUNDLE_IDENTIFIER "org.cleveraudio.wrapper.${repout}.vst3")
endif()

if ("${CLAP_WRAPPER_BUNDLE_VERSION}" STREQUAL "")
Expand All @@ -369,7 +370,7 @@ function(target_add_vst3_wrapper)
MACOSX_BUNDLE_INFO_PLIST ${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/cmake/VST3_Info.plist.in
)
if (NOT ${CMAKE_GENERATOR} STREQUAL "Xcode")
add_custom_command(TARGET ${V3_TARGET} POST_BUILD
add_custom_command(TARGET ${V3_TARGET} PRE_BUILD
WORKING_DIRECTORY $<TARGET_PROPERTY:${V3_TARGET},LIBRARY_OUTPUT_DIRECTORY>
COMMAND SetFile -a B "$<TARGET_PROPERTY:${V3_TARGET},LIBRARY_OUTPUT_NAME>.$<TARGET_PROPERTY:${V3_TARGET},BUNDLE_EXTENSION>"
)
Expand Down Expand Up @@ -551,6 +552,13 @@ if (APPLE)
)
endif()

string(MAKE_C_IDENTIFIER ${AUV2_OUTPUT_NAME} outidentifier)

if ("${AUV2_BUNDLE_IDENTIFIER}" STREQUAL "")
string(REPLACE "_" "-" repout ${outidentifier})
set(AUV2_BUNDLE_IDENTIFIER "org.cleveraudio.wrapper.${repout}.auv2")
endif()

set(AUV2_MANUFACTURER_NAME ${AUV2_MANUFACTURER_NAME} PARENT_SCOPE)
set(AUV2_MANUFACTURER_CODE ${AUV2_MANUFACTURER_CODE} PARENT_SCOPE)
configure_file(${bhsc}/auv2_infoplist_top.in
Expand All @@ -561,15 +569,15 @@ if (APPLE)

message(STATUS "clap-wrapper: Adding AUV2 Wrapper to target ${AUV2_TARGET} generating '${AUV2_OUTPUT_NAME}.component'")

string(MAKE_C_IDENTIFIER ${AUV2_OUTPUT_NAME} outidentifier)

# This is a placeholder dummy until we actually write the AUv2
# Similarly the subordinate library being an interface below
# is a placeholder. When we write it we will follow a similar
# split trick as for the vst3, mostly (but AUV2 is a bit different
# with info.plist and entrypoint-per-instance stuff)
target_sources(${AUV2_TARGET} PRIVATE
${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/wrapasauv2.cpp
${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/auv2/auv2_shared.h
${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/auv2/auv2_base_classes.h
${bhtgoutdir}/generated_entrypoints.hxx)


Expand All @@ -588,10 +596,6 @@ if (APPLE)
set_target_properties(${AUV2_TARGET} PROPERTIES LIBRARY_OUTPUT_NAME "${AUV2_OUTPUT_NAME}")
target_link_libraries(${AUV2_TARGET} PUBLIC ${AUV2_TARGET}-clap-wrapper-auv2-lib)

if ("${AUV2_BUNDLE_IDENTIFIER}" STREQUAL "")
set(AUV2_BUNDLE_IDENTIFIER "org.cleveraudio.wrapper.${outidentifier}.auv2")
endif()

if ("${CLAP_WRAPPER_BUNDLE_VERSION}" STREQUAL "")
set(CLAP_WRAPPER_BUNDLE_VERSION "1.0")
endif()
Expand Down
105 changes: 55 additions & 50 deletions src/detail/auv2/auv2_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,68 @@
#pragma once

#include "detail/clap/fsutil.h"
#include <iostream>

namespace free_audio::auv2_wrapper
{
struct ClapBridge
{
std::string _clapname;
std::string _clapid;
int _idx;
namespace free_audio::auv2_wrapper {
struct ClapBridge {
std::string _clapname;
std::string _clapid;
int _idx;

Clap::Library _library;
Clap::Library _library;

const clap_plugin_descriptor_t *_desc{nullptr};
const clap_plugin_descriptor_t *_desc{nullptr};

ClapBridge(const std::string &clapname,
const std::string &clapid,
int idx) : _clapname(clapname), _clapid(clapid), _idx(idx)
{
}

void initialize()
{
if (!_library.hasEntryPoint())
{
if (!_library.load(_clapname.c_str()))
{
std::cout << "[ERROR] cannot load either by internal entry nor _clapname" << std::endl;
return;
}
}
ClapBridge(const std::string &clapname, const std::string &clapid, int idx)
: _clapname(clapname), _clapid(clapid), _idx(idx) {
std::cout << "[clap-wraper] auv2: creating clap bridge nm=" << clapname
<< " id=" << clapid << " idx=" << idx << std::endl;
}

if (_clapid.empty())
{
if (_idx < 0 || _idx >= _library.plugins.size())
{
std::cout << "[ERROR] cannot load by index" << std::endl;
return;
}
_desc = _library.plugins[_idx];
}
else
{
for (auto *d : _library.plugins)
{
if (strcmp(d->id, _clapid.c_str()) == 0)
{
_desc = d;
}
}
}
void initialize() {
if (!_library.hasEntryPoint()) {
if (_clapname.empty()) {
std::cout << "[ERROR] _clapname (" << _clapname
<< ") empty and no internal entry point" << std::endl;
}
bool loaded{false};
auto csp = Clap::getValidCLAPSearchPaths();
for (auto &cs : csp) {
if (fs::is_directory(cs / (_clapname + ".clap")))
if (_library.load(_clapname.c_str())) {
std::cout << "[clap-wrapper] auv2 loaded clap from "
<< cs.u8string() << std::endl;
loaded = true;
break;
}
}
if (!loaded) {
std::cout << "[ERROR] cannot load clap" << std::endl;
return;
}
}

if (!_desc)
{
std::cout << "[ERROR] cannot determine plugin description" << std::endl;
return;
if (_clapid.empty()) {
if (_idx < 0 || _idx >= _library.plugins.size()) {
std::cout << "[ERROR] cannot load by index" << std::endl;
return;
}
_desc = _library.plugins[_idx];
} else {
for (auto *d : _library.plugins) {
if (strcmp(d->id, _clapid.c_str()) == 0) {
_desc = d;
}
}
}

std::cout << "[clap-wrapper] auv2: Initialized '" << _desc->id << "' / '" << _desc->name << "'" << std::endl;
if (!_desc) {
std::cout << "[ERROR] cannot determine plugin description" << std::endl;
return;
}

std::cout << "[clap-wrapper] auv2: Initialized '" << _desc->id << "' / '"
<< _desc->name << "'" << std::endl;
}
};
}
} // namespace free_audio::auv2_wrapper
2 changes: 1 addition & 1 deletion src/detail/auv2/build-helper/auv2_infoplist_top.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${AUV2_OUTPUT_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${AUV2_BUNDLE_VERSION}</string>
<string>${AUV2_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Loading