diff --git a/clients/clap-first/CMakeLists.txt b/clients/clap-first/CMakeLists.txt index a363c63b..9ecd16e7 100644 --- a/clients/clap-first/CMakeLists.txt +++ b/clients/clap-first/CMakeLists.txt @@ -3,8 +3,11 @@ project(scxt_clapfirst) message(STATUS "Shortcircuit XT building clap-first wrappers") set(name "Shortcircuit XT") set(IMPL_TARGET ${PROJECT_NAME}_impl) -add_library(${IMPL_TARGET} STATIC clap-config.cpp - scxt-plugin/scxt-plugin.cpp) +add_library(${IMPL_TARGET} STATIC + scxt-plugin/clap-helpers-config.cpp + scxt-plugin/scxt-plugin.cpp + scxt-plugin/scxt-clap-entry-impl.cpp +) target_link_libraries(${IMPL_TARGET} PUBLIC clap_juce_shim_headers diff --git a/clients/clap-first/scxt-clap-entry.cpp b/clients/clap-first/scxt-clap-entry.cpp index 57030392..c3e4a69a 100644 --- a/clients/clap-first/scxt-clap-entry.cpp +++ b/clients/clap-first/scxt-clap-entry.cpp @@ -25,99 +25,8 @@ * https://github.com/surge-synthesizer/shortcircuit-xt */ -/* - * This file provides the `clap_plugin_entry` entry point required in the DLL for all - * clap plugins. It also provides the basic functions for the resulting factory class - * which generates the plugin. In a single plugin case, this really is just plumbing - * through to expose polysynth::ConduitPolysynthConfig::getDescription() and create a polysynth - * plugin instance using the helper classes. - * - * For more information on this mechanism, see include/clap/entry.h - */ - -#include -#include -#include - #include -#include -#include - -#include "clapwrapper/vst3.h" -#include "clapwrapper/auv2.h" - -namespace scxt::clap_first -{ -namespace scxt_plugin -{ -extern const clap_plugin_descriptor *getDescription(); -extern const clap_plugin *makeSCXTPlugin(const clap_host *h); -} // namespace scxt_plugin - -uint32_t clap_get_plugin_count(const clap_plugin_factory *f) { return 1; } -const clap_plugin_descriptor *clap_get_plugin_descriptor(const clap_plugin_factory *f, uint32_t w) -{ - if (w == 0) - return scxt::clap_first::scxt_plugin::getDescription(); - - return nullptr; -} - -static const clap_plugin *clap_create_plugin(const clap_plugin_factory *f, const clap_host *host, - const char *plugin_id) -{ - - if (strcmp(plugin_id, scxt::clap_first::scxt_plugin::getDescription()->id) == 0) - { - return scxt_plugin::makeSCXTPlugin(host); - } - return nullptr; -} - -static bool clap_get_auv2_info(const clap_plugin_factory_as_auv2 *factory, uint32_t index, - clap_plugin_info_as_auv2_t *info) -{ - auto desc = clap_get_plugin_descriptor(nullptr, index); // we don't use the factory above - - auto plugin_id = desc->id; - - info->au_type[0] = 0; // use the features to determine the type - - if (strcmp(plugin_id, scxt::clap_first::scxt_plugin::getDescription()->id) == 0) - { - strncpy(info->au_subt, "ScXT", 5); - return true; - } - - return false; -} - -const struct clap_plugin_factory scxt_clap_factory = { - clap_get_plugin_count, - clap_get_plugin_descriptor, - clap_create_plugin, -}; - -const struct clap_plugin_factory_as_auv2 scxt_auv2_factory = {"SSTx", // manu - "Surge Synth Team", // manu name - clap_get_auv2_info}; - -static const void *get_factory(const char *factory_id) -{ - if (!strcmp(factory_id, CLAP_PLUGIN_FACTORY_ID)) - return &scxt_clap_factory; - - if (!strcmp(factory_id, CLAP_PLUGIN_FACTORY_INFO_AUV2)) - return &scxt_auv2_factory; - - return nullptr; -} - -// clap_init and clap_deinit are required to be fast, but we have nothing we need to do here -bool clap_init(const char *p) { return true; } -void clap_deinit() {} - -} // namespace scxt::clap_first +#include "scxt-plugin/scxt-clap-entry-impl.h" extern "C" { diff --git a/clients/clap-first/clap-config.cpp b/clients/clap-first/scxt-plugin/clap-helpers-config.cpp similarity index 92% rename from clients/clap-first/clap-config.cpp rename to clients/clap-first/scxt-plugin/clap-helpers-config.cpp index f544d335..a7984416 100644 --- a/clients/clap-first/clap-config.cpp +++ b/clients/clap-first/scxt-plugin/clap-helpers-config.cpp @@ -25,9 +25,10 @@ * https://github.com/surge-synthesizer/shortcircuit-xt */ -#include "clap-config.h" -#include "clap/helpers/plugin.hxx" -#include "clap/helpers/host-proxy.hxx" +#include "clap-helpers-config.h" + +#include +#include namespace sxcf = scxt::clap_first; namespace chlp = clap::helpers; diff --git a/clients/clap-first/clap-config.h b/clients/clap-first/scxt-plugin/clap-helpers-config.h similarity index 92% rename from clients/clap-first/clap-config.h rename to clients/clap-first/scxt-plugin/clap-helpers-config.h index 9f9a91f7..41c941c3 100644 --- a/clients/clap-first/clap-config.h +++ b/clients/clap-first/scxt-plugin/clap-helpers-config.h @@ -25,8 +25,8 @@ * https://github.com/surge-synthesizer/shortcircuit-xt */ -#ifndef CLIENTS_CLAP_FIRST_CLAP_CONFIG_H -#define CLIENTS_CLAP_FIRST_CLAP_CONFIG_H +#ifndef CLIENTS_CLAP_FIRST_SCXT_PLUGIN_CLAP_HELPERS_CONFIG_H +#define CLIENTS_CLAP_FIRST_SCXT_PLUGIN_CLAP_HELPERS_CONFIG_H #include diff --git a/clients/clap-first/scxt-plugin/scxt-clap-entry-impl.cpp b/clients/clap-first/scxt-plugin/scxt-clap-entry-impl.cpp new file mode 100644 index 00000000..0a5be9fa --- /dev/null +++ b/clients/clap-first/scxt-plugin/scxt-clap-entry-impl.cpp @@ -0,0 +1,112 @@ +/* + * Shortcircuit XT - a Surge Synth Team product + * + * A fully featured creative sampler, available as a standalone + * and plugin for multiple platforms. + * + * Copyright 2019 - 2024, Various authors, as described in the github + * transaction log. + * + * ShortcircuitXT is released under the Gnu General Public Licence + * V3 or later (GPL-3.0-or-later). The license is found in the file + * "LICENSE" in the root of this repository or at + * https://www.gnu.org/licenses/gpl-3.0.en.html + * + * Individual sections of code which comprises ShortcircuitXT in this + * repository may also be used under an MIT license. Please see the + * section "Licensing" in "README.md" for details. + * + * ShortcircuitXT is inspired by, and shares code with, the + * commercial product Shortcircuit 1 and 2, released by VemberTech + * in the mid 2000s. The code for Shortcircuit 2 was opensourced in + * 2020 at the outset of this project. + * + * All source for ShortcircuitXT is available at + * https://github.com/surge-synthesizer/shortcircuit-xt + */ + +#include "scxt-clap-entry-impl.h" + +#include +#include +#include + +#include +#include +#include + +#include "clapwrapper/vst3.h" +#include "clapwrapper/auv2.h" + +namespace scxt::clap_first +{ +namespace scxt_plugin +{ +extern const clap_plugin_descriptor *getDescription(); +extern const clap_plugin *makeSCXTPlugin(const clap_host *h); +} // namespace scxt_plugin + +uint32_t clap_get_plugin_count(const clap_plugin_factory *f) { return 1; } +const clap_plugin_descriptor *clap_get_plugin_descriptor(const clap_plugin_factory *f, uint32_t w) +{ + if (w == 0) + return scxt::clap_first::scxt_plugin::getDescription(); + + return nullptr; +} + +static const clap_plugin *clap_create_plugin(const clap_plugin_factory *f, const clap_host *host, + const char *plugin_id) +{ + + if (strcmp(plugin_id, scxt::clap_first::scxt_plugin::getDescription()->id) == 0) + { + return scxt_plugin::makeSCXTPlugin(host); + } + return nullptr; +} + +static bool clap_get_auv2_info(const clap_plugin_factory_as_auv2 *factory, uint32_t index, + clap_plugin_info_as_auv2_t *info) +{ + auto desc = clap_get_plugin_descriptor(nullptr, index); // we don't use the factory above + + auto plugin_id = desc->id; + + info->au_type[0] = 0; // use the features to determine the type + + if (strcmp(plugin_id, scxt::clap_first::scxt_plugin::getDescription()->id) == 0) + { + strncpy(info->au_subt, "ScXT", 5); + return true; + } + + return false; +} + +const struct clap_plugin_factory scxt_clap_factory = { + clap_get_plugin_count, + clap_get_plugin_descriptor, + clap_create_plugin, +}; + +const struct clap_plugin_factory_as_auv2 scxt_auv2_factory = {"SSTx", // manu + "Surge Synth Team", // manu name + clap_get_auv2_info}; + +const void *get_factory(const char *factory_id) +{ + if (!strcmp(factory_id, CLAP_PLUGIN_FACTORY_ID)) + return &scxt_clap_factory; + + if (!strcmp(factory_id, CLAP_PLUGIN_FACTORY_INFO_AUV2)) + return &scxt_auv2_factory; + + return nullptr; +} + +// clap_init and clap_deinit are required to be fast, but we have nothing we need to do here +bool clap_init(const char *p) { return true; } +void clap_deinit() {} + +} // namespace scxt::clap_first diff --git a/clients/clap-first/scxt-plugin/scxt-clap-entry-impl.h b/clients/clap-first/scxt-plugin/scxt-clap-entry-impl.h new file mode 100644 index 00000000..29ab1de7 --- /dev/null +++ b/clients/clap-first/scxt-plugin/scxt-clap-entry-impl.h @@ -0,0 +1,39 @@ +/* + * Shortcircuit XT - a Surge Synth Team product + * + * A fully featured creative sampler, available as a standalone + * and plugin for multiple platforms. + * + * Copyright 2019 - 2024, Various authors, as described in the github + * transaction log. + * + * ShortcircuitXT is released under the Gnu General Public Licence + * V3 or later (GPL-3.0-or-later). The license is found in the file + * "LICENSE" in the root of this repository or at + * https://www.gnu.org/licenses/gpl-3.0.en.html + * + * Individual sections of code which comprises ShortcircuitXT in this + * repository may also be used under an MIT license. Please see the + * section "Licensing" in "README.md" for details. + * + * ShortcircuitXT is inspired by, and shares code with, the + * commercial product Shortcircuit 1 and 2, released by VemberTech + * in the mid 2000s. The code for Shortcircuit 2 was opensourced in + * 2020 at the outset of this project. + * + * All source for ShortcircuitXT is available at + * https://github.com/surge-synthesizer/shortcircuit-xt + */ + +#ifndef CLIENTS_CLAP_FIRST_SCXT_PLUGIN_SCXT_CLAP_ENTRY_IMPL_H +#define CLIENTS_CLAP_FIRST_SCXT_PLUGIN_SCXT_CLAP_ENTRY_IMPL_H + +namespace scxt::clap_first +{ + +const void *get_factory(const char *factory_id); +bool clap_init(const char *p); +void clap_deinit(); + +} // namespace scxt::clap_first +#endif // SCXT_PLUGIN_ENTRY_IMPL_H diff --git a/clients/clap-first/scxt-plugin/scxt-plugin.h b/clients/clap-first/scxt-plugin/scxt-plugin.h index 459038f7..e827b2bf 100644 --- a/clients/clap-first/scxt-plugin/scxt-plugin.h +++ b/clients/clap-first/scxt-plugin/scxt-plugin.h @@ -47,7 +47,7 @@ #include "engine/engine.h" #include "voice/voice.h" -#include "clap-config.h" +#include "clap-helpers-config.h" #include "utils.h" static_assert((int)scxt::voice::Voice::ExpressionIDs::VOLUME == (int)CLAP_NOTE_EXPRESSION_VOLUME);