From 4f51997d405e1992ac8aff1c94d17ecb6592c7d1 Mon Sep 17 00:00:00 2001 From: jatin Date: Sat, 30 Dec 2023 14:31:50 -0800 Subject: [PATCH 1/9] Setting up extensions for CLAP preset discovery and loading --- .../chowdsp_CLAPPresetDiscoveryProviders.cpp | 117 ++++++++++++++++++ .../chowdsp_CLAPPresetDiscoveryProviders.h | 64 ++++++++++ .../chowdsp_clap_extensions.cpp | 7 ++ .../chowdsp_clap_extensions.h | 4 + .../PluginBase/chowdsp_PluginBase.h | 13 ++ .../Files/chowdsp_FileListener.cpp | 6 +- .../Files/chowdsp_FileListener.h | 9 +- .../Backend/chowdsp_PresetManager.cpp | 41 ++++++ .../Backend/chowdsp_PresetManager.h | 5 + 9 files changed, 262 insertions(+), 4 deletions(-) create mode 100644 modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp create mode 100644 modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h create mode 100644 modules/plugin/chowdsp_clap_extensions/chowdsp_clap_extensions.cpp diff --git a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp new file mode 100644 index 000000000..85d2c3efc --- /dev/null +++ b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp @@ -0,0 +1,117 @@ +#include "chowdsp_CLAPPresetDiscoveryProviders.h" + +#include + +JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter") +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4100) +#include +#include +JUCE_END_IGNORE_WARNINGS_MSVC +JUCE_END_IGNORE_WARNINGS_GCC_LIKE + +namespace chowdsp::presets::discovery +{ +EmbeddedPresetsProvider::EmbeddedPresetsProvider (const clap_plugin_id& this_plug_id, + const clap_preset_discovery_provider_descriptor& desc, + const clap_preset_discovery_location& location, + const clap_preset_discovery_indexer* indexer) + : CLAPPresetsProviderBase (&desc, indexer), + this_plugin_id (this_plug_id), + discoveryLocation (location) +{ + // CLAP requires that a location containing embedded presets must be nullptr + jassert (discoveryLocation.location == nullptr); +} + +std::vector EmbeddedPresetsProvider::getPresets() { return {}; } + +bool EmbeddedPresetsProvider::init() noexcept +{ + indexer()->declare_location (indexer(), &discoveryLocation); + return true; +} + +bool EmbeddedPresetsProvider::getMetadata (uint32_t location_kind, + [[maybe_unused]] const char* location, + const clap_preset_discovery_metadata_receiver_t* metadata_receiver) noexcept +{ + if (location_kind != CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN) + return false; + + for (const auto& factoryPreset : getPresets()) + { + DBG ("Indexing factory preset: " + factoryPreset.getName()); + if (metadata_receiver->begin_preset (metadata_receiver, factoryPreset.getName().toRawUTF8(), factoryPreset.getName().toRawUTF8())) + { + metadata_receiver->add_plugin_id (metadata_receiver, &this_plugin_id); + metadata_receiver->add_creator (metadata_receiver, factoryPreset.getVendor().toRawUTF8()); + + if (factoryPreset.getCategory().isNotEmpty()) + metadata_receiver->add_feature (metadata_receiver, factoryPreset.getCategory().toRawUTF8()); + } + else + { + break; + } + } + + return true; +} + +//============================================================================== +FilePresetsProvider::FilePresetsProvider (const clap_plugin_id& this_plug_id, + const clap_preset_discovery_provider_descriptor& desc, + const clap_preset_discovery_filetype& filetype, + const clap_preset_discovery_indexer* indexer) + : CLAPPresetsProviderBase (&desc, indexer), + this_plugin_id (this_plug_id), + presets_filetype (filetype) +{ +} + +bool FilePresetsProvider::init() noexcept +{ + indexer()->declare_filetype (indexer(), &presets_filetype); + + discoveryLocation.flags = CLAP_PRESET_DISCOVERY_IS_USER_CONTENT; + discoveryLocation.kind = CLAP_PRESET_DISCOVERY_LOCATION_FILE; + if (! fillInLocation (discoveryLocation)) + return false; + + indexer()->declare_location (indexer(), &discoveryLocation); + + return true; +} + +bool FilePresetsProvider::getMetadata (uint32_t location_kind, + const char* location, + const clap_preset_discovery_metadata_receiver_t* metadata_receiver) noexcept +{ + if (location_kind != CLAP_PRESET_DISCOVERY_LOCATION_FILE || location == nullptr) + return false; + + const auto userPresetFile = juce::File { location }; + if (! userPresetFile.existsAsFile()) + return false; + + Preset preset { userPresetFile }; + if (! preset.isValid()) + return false; + + DBG ("Indexing user preset: " + preset.getName() + ", from path: " + userPresetFile.getFullPathName()); + if (metadata_receiver->begin_preset (metadata_receiver, userPresetFile.getFullPathName().toRawUTF8(), "")) + { + metadata_receiver->add_plugin_id (metadata_receiver, &this_plugin_id); + metadata_receiver->add_creator (metadata_receiver, preset.getVendor().toRawUTF8()); + + if (preset.getCategory().isNotEmpty()) + metadata_receiver->add_feature (metadata_receiver, preset.getCategory().toRawUTF8()); + + metadata_receiver->set_timestamps (metadata_receiver, + (clap_timestamp_t) userPresetFile.getCreationTime().toMilliseconds() / 1000, + (clap_timestamp_t) userPresetFile.getLastModificationTime().toMilliseconds() / 1000); + } + + return true; +} +} // namespace chowdsp::presets::discovery diff --git a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h new file mode 100644 index 000000000..907dde8db --- /dev/null +++ b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h @@ -0,0 +1,64 @@ +#pragma once + + +JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter") +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4100) +#include +JUCE_END_IGNORE_WARNINGS_MSVC +JUCE_END_IGNORE_WARNINGS_GCC_LIKE + +namespace chowdsp::presets +{ +class Preset; +} + +namespace chowdsp::presets::discovery +{ +using CLAPPresetsProviderBase = +#if JUCE_DEBUG + clap::helpers::PresetDiscoveryProvider; +#else + clap::helpers::PresetDiscoveryProvider; +#endif + +/** A CLAP preset provider for presets that are embedded in the plugin's binary data. */ +struct EmbeddedPresetsProvider : CLAPPresetsProviderBase +{ + const clap_plugin_id& this_plugin_id; + const clap_preset_discovery_location& discoveryLocation {}; + + EmbeddedPresetsProvider (const clap_plugin_id& this_plug_id, + const clap_preset_discovery_provider_descriptor& desc, + const clap_preset_discovery_location& location, + const clap_preset_discovery_indexer* indexer); + + /** Users are expected to override this method to provide the relevant presets. */ + virtual std::vector getPresets(); + + bool init() noexcept override; + bool getMetadata (uint32_t location_kind, + const char* location, + const clap_preset_discovery_metadata_receiver_t* metadata_receiver) noexcept override; +}; + +/** A CLAP preset provider for presets that are stored in the user's filesystem. */ +struct FilePresetsProvider : CLAPPresetsProviderBase +{ + const clap_plugin_id& this_plugin_id; + const clap_preset_discovery_filetype& presets_filetype; + clap_preset_discovery_location discoveryLocation {}; + + FilePresetsProvider (const clap_plugin_id& this_plug_id, + const clap_preset_discovery_provider_descriptor& desc, + const clap_preset_discovery_filetype& filetype, + const clap_preset_discovery_indexer* indexer); + + /** Users are expected to override this method to fill in the location name and path. */ + virtual bool fillInLocation (clap_preset_discovery_location&) = 0; + + bool init() noexcept override; + bool getMetadata (uint32_t location_kind, + const char* location, + const clap_preset_discovery_metadata_receiver_t* metadata_receiver) noexcept override; +}; +} // namespace chowdsp::presets::discovery diff --git a/modules/plugin/chowdsp_clap_extensions/chowdsp_clap_extensions.cpp b/modules/plugin/chowdsp_clap_extensions/chowdsp_clap_extensions.cpp new file mode 100644 index 000000000..fc642a16b --- /dev/null +++ b/modules/plugin/chowdsp_clap_extensions/chowdsp_clap_extensions.cpp @@ -0,0 +1,7 @@ +#include "chowdsp_clap_extensions.h" + +// LCOV_EXCL_START +#if JUCE_MODULE_AVAILABLE_chowdsp_presets_v2 +#include "PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp" +#endif +// LCOV_EXCL_END diff --git a/modules/plugin/chowdsp_clap_extensions/chowdsp_clap_extensions.h b/modules/plugin/chowdsp_clap_extensions/chowdsp_clap_extensions.h index 8d30728bf..19c85b356 100644 --- a/modules/plugin/chowdsp_clap_extensions/chowdsp_clap_extensions.h +++ b/modules/plugin/chowdsp_clap_extensions/chowdsp_clap_extensions.h @@ -44,4 +44,8 @@ namespace CLAPExtensions // LCOV_EXCL_START #include "ParameterExtensions/chowdsp_ModParamMixin.h" #include "PluginExtensions/chowdsp_CLAPInfoExtensions.h" + +#if JUCE_MODULE_AVAILABLE_chowdsp_presets_v2 +#include "PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h" +#endif // LCOV_EXCL_END diff --git a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h index bd01a51e3..b1063c0fe 100644 --- a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h +++ b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h @@ -117,6 +117,11 @@ class PluginBase : public juce::AudioProcessor virtual juce::String getWrapperTypeString() const; bool supportsParameterModulation() const; +#if HAS_CLAP_JUCE_EXTENSIONS && JUCE_MODULE_AVAILABLE_chowdsp_presets_v2 + bool supportsPresetLoad() const noexcept override { return presetManager != nullptr; } + bool presetLoadFromLocation (uint32_t location_kind, const char* location, const char* load_key) noexcept override; +#endif + protected: #if JUCE_MODULE_AVAILABLE_chowdsp_plugin_state PluginStateType state; @@ -311,4 +316,12 @@ bool PluginBase

::supportsParameterModulation() const return false; #endif } + +template +bool PluginBase

::presetLoadFromLocation (uint32_t location_kind, const char* location, const char* load_key) noexcept +{ + if (presetManager == nullptr) + return false; + return presetManager->loadCLAPPreset (location_kind, location, load_key); +} } // namespace chowdsp diff --git a/modules/plugin/chowdsp_plugin_utils/Files/chowdsp_FileListener.cpp b/modules/plugin/chowdsp_plugin_utils/Files/chowdsp_FileListener.cpp index c1461e4e2..36228be1e 100644 --- a/modules/plugin/chowdsp_plugin_utils/Files/chowdsp_FileListener.cpp +++ b/modules/plugin/chowdsp_plugin_utils/Files/chowdsp_FileListener.cpp @@ -5,12 +5,14 @@ namespace chowdsp FileListener::FileListener (const juce::File& file, int timerSeconds) : fileToListenTo (file) { fileModificationTime = fileToListenTo.getLastModificationTime().toMilliseconds(); - startTimer (timerSeconds * 1000); + if (timerSeconds > 0) + startTimer (timerSeconds * 1000); } FileListener::~FileListener() { - stopTimer(); + if (isTimerRunning()) + stopTimer(); } void FileListener::timerCallback() diff --git a/modules/plugin/chowdsp_plugin_utils/Files/chowdsp_FileListener.h b/modules/plugin/chowdsp_plugin_utils/Files/chowdsp_FileListener.h index 1e0574131..1dd3768f7 100644 --- a/modules/plugin/chowdsp_plugin_utils/Files/chowdsp_FileListener.h +++ b/modules/plugin/chowdsp_plugin_utils/Files/chowdsp_FileListener.h @@ -3,10 +3,15 @@ namespace chowdsp { /** Abstract class to allow the derived class to listen for changes to a file. */ -class FileListener : private juce::Timer +class FileListener : public juce::Timer { public: - /** Initialize this FileListener for a given file and update time. */ + /** + * Initialize this FileListener for a given file and update time. + * + * If the given update time is less than or equal to zero, then + * the timer will not be started. + */ FileListener (const juce::File& file, int timerSeconds); ~FileListener() override; diff --git a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp index 0f4b209ed..de97c88da 100644 --- a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp +++ b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp @@ -1,5 +1,13 @@ #include "chowdsp_PresetManager.h" +#if HAS_CLAP_JUCE_EXTENSIONS +JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter") +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4100) +#include +JUCE_END_IGNORE_WARNINGS_MSVC +JUCE_END_IGNORE_WARNINGS_GCC_LIKE +#endif + namespace chowdsp::presets { PresetManager::PresetManager (PluginState& state, @@ -124,4 +132,37 @@ void PresetManager::loadUserPresetsFromFolder (const juce::File& file) addPresets (std::move (presets), false); } + +#if HAS_CLAP_JUCE_EXTENSIONS +bool PresetManager::loadCLAPPreset (uint32_t location_kind, const char* location, const char* load_key) noexcept +{ + if (location_kind == CLAP_PRESET_DISCOVERY_LOCATION_FILE) + { + const auto presetFile = juce::File { location }; + if (! presetFile.existsAsFile()) + return false; + + const auto preset = Preset { presetFile }; + if (! preset.isValid()) + return false; + + loadPreset (preset); + return true; + } + + if (location_kind == CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN) + { + for (const auto& preset : getFactoryPresets()) + { + if (preset.getName() == load_key) + { + loadPreset (preset); + return true; + } + } + } + + return false; +} +#endif } // namespace chowdsp::presets diff --git a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h index 336500c30..c0cda4dc2 100644 --- a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h +++ b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h @@ -17,6 +17,11 @@ class PresetManager /** Loads a preset by reference. */ void loadPreset (const Preset& preset) { saverLoader.loadPreset (preset); } +#if HAS_CLAP_JUCE_EXTENSIONS + /** Loads a preset based on information provided by the CLAP preset-load extension. */ + virtual bool loadCLAPPreset (uint32_t location_kind, const char* location, const char* load_key) noexcept; +#endif + /** Returns the currently loaded preset, or nullptr if no preset is loaded. */ [[nodiscard]] const Preset* getCurrentPreset() const { return saverLoader.getCurrentPreset(); } From 979dbdcb8d36cf888f40946a12f0c1bff4a56a1a Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 22 Jan 2024 10:44:10 -0800 Subject: [PATCH 2/9] Update CLAP note name API --- .../plugin/chowdsp_plugin_base/PluginBase/chowdsp_SynthBase.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_SynthBase.h b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_SynthBase.h index 11c1bb71e..161ddb7e4 100644 --- a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_SynthBase.h +++ b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_SynthBase.h @@ -44,8 +44,8 @@ class SynthBase : public PluginBase { return true; } - int noteNameCount() noexcept override { return 0; } - bool noteNameGet (int /*index*/, clap_note_name* /*noteName*/) noexcept override { return false; } + uint32_t noteNameCount() noexcept override { return 0; } + bool noteNameGet (uint32_t /*index*/, clap_note_name* /*noteName*/) noexcept override { return false; } #endif private: From e8effdd92cf0d3c1ba1a0d34d976711d20bc45c1 Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 22 Jan 2024 11:58:14 -0800 Subject: [PATCH 3/9] Add missing HAS_CLAP check --- .../plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h index b1063c0fe..b1813a5a4 100644 --- a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h +++ b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h @@ -317,6 +317,7 @@ bool PluginBase

::supportsParameterModulation() const #endif } +#if HAS_CLAP_JUCE_EXTENSIONS && JUCE_MODULE_AVAILABLE_chowdsp_presets_v2 template bool PluginBase

::presetLoadFromLocation (uint32_t location_kind, const char* location, const char* load_key) noexcept { @@ -324,4 +325,5 @@ bool PluginBase

::presetLoadFromLocation (uint32_t location_kind, const char* return false; return presetManager->loadCLAPPreset (location_kind, location, load_key); } +#endif } // namespace chowdsp From 137724b4bb3f80dbc1b7e4c77a36f04ff3d80713 Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 29 Jan 2024 00:04:21 -0800 Subject: [PATCH 4/9] More presets/CLAP interop updates --- .../chowdsp_CLAPPresetDiscoveryProviders.cpp | 8 ++++---- .../chowdsp_CLAPPresetDiscoveryProviders.h | 8 ++++---- .../Backend/chowdsp_PresetManager.cpp | 15 +++++++++++++++ .../Backend/chowdsp_PresetManager.h | 4 +++- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp index 85d2c3efc..919ac72d2 100644 --- a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp +++ b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp @@ -11,7 +11,7 @@ JUCE_END_IGNORE_WARNINGS_GCC_LIKE namespace chowdsp::presets::discovery { -EmbeddedPresetsProvider::EmbeddedPresetsProvider (const clap_plugin_id& this_plug_id, +EmbeddedPresetsProvider::EmbeddedPresetsProvider (const clap_universal_plugin_id& this_plug_id, const clap_preset_discovery_provider_descriptor& desc, const clap_preset_discovery_location& location, const clap_preset_discovery_indexer* indexer) @@ -59,7 +59,7 @@ bool EmbeddedPresetsProvider::getMetadata (uint32_t location_kind, } //============================================================================== -FilePresetsProvider::FilePresetsProvider (const clap_plugin_id& this_plug_id, +FilePresetsProvider::FilePresetsProvider (const clap_universal_plugin_id& this_plug_id, const clap_preset_discovery_provider_descriptor& desc, const clap_preset_discovery_filetype& filetype, const clap_preset_discovery_indexer* indexer) @@ -108,8 +108,8 @@ bool FilePresetsProvider::getMetadata (uint32_t location_kind, metadata_receiver->add_feature (metadata_receiver, preset.getCategory().toRawUTF8()); metadata_receiver->set_timestamps (metadata_receiver, - (clap_timestamp_t) userPresetFile.getCreationTime().toMilliseconds() / 1000, - (clap_timestamp_t) userPresetFile.getLastModificationTime().toMilliseconds() / 1000); + (clap_timestamp) userPresetFile.getCreationTime().toMilliseconds() / 1000, + (clap_timestamp) userPresetFile.getLastModificationTime().toMilliseconds() / 1000); } return true; diff --git a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h index 907dde8db..0a47b4758 100644 --- a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h +++ b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h @@ -24,10 +24,10 @@ using CLAPPresetsProviderBase = /** A CLAP preset provider for presets that are embedded in the plugin's binary data. */ struct EmbeddedPresetsProvider : CLAPPresetsProviderBase { - const clap_plugin_id& this_plugin_id; + const clap_universal_plugin_id& this_plugin_id; const clap_preset_discovery_location& discoveryLocation {}; - EmbeddedPresetsProvider (const clap_plugin_id& this_plug_id, + EmbeddedPresetsProvider (const clap_universal_plugin_id& this_plug_id, const clap_preset_discovery_provider_descriptor& desc, const clap_preset_discovery_location& location, const clap_preset_discovery_indexer* indexer); @@ -44,11 +44,11 @@ struct EmbeddedPresetsProvider : CLAPPresetsProviderBase /** A CLAP preset provider for presets that are stored in the user's filesystem. */ struct FilePresetsProvider : CLAPPresetsProviderBase { - const clap_plugin_id& this_plugin_id; + const clap_universal_plugin_id& this_plugin_id; const clap_preset_discovery_filetype& presets_filetype; clap_preset_discovery_location discoveryLocation {}; - FilePresetsProvider (const clap_plugin_id& this_plug_id, + FilePresetsProvider (const clap_universal_plugin_id& this_plug_id, const clap_preset_discovery_provider_descriptor& desc, const clap_preset_discovery_filetype& filetype, const clap_preset_discovery_indexer* indexer); diff --git a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp index de97c88da..05152588b 100644 --- a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp +++ b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp @@ -133,6 +133,21 @@ void PresetManager::loadUserPresetsFromFolder (const juce::File& file) addPresets (std::move (presets), false); } +void PresetManager::loadPreset (const Preset& preset) +{ + saverLoader.loadPreset (preset); + +#if HAS_CLAP_JUCE_EXTENSIONS + if (preset.getPresetFile() == juce::File {}) + clapPresetLoadedBroadcaster (CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN, + nullptr, + preset.getName().toRawUTF8()); + clapPresetLoadedBroadcaster (CLAP_PRESET_DISCOVERY_LOCATION_FILE, + preset.getPresetFile().getFullPathName().toRawUTF8(), + nullptr); +#endif +} + #if HAS_CLAP_JUCE_EXTENSIONS bool PresetManager::loadCLAPPreset (uint32_t location_kind, const char* location, const char* load_key) noexcept { diff --git a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h index c0cda4dc2..a0f760f70 100644 --- a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h +++ b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h @@ -15,11 +15,13 @@ class PresetManager virtual ~PresetManager() = default; /** Loads a preset by reference. */ - void loadPreset (const Preset& preset) { saverLoader.loadPreset (preset); } + void loadPreset (const Preset& preset); #if HAS_CLAP_JUCE_EXTENSIONS /** Loads a preset based on information provided by the CLAP preset-load extension. */ virtual bool loadCLAPPreset (uint32_t location_kind, const char* location, const char* load_key) noexcept; + + Broadcaster clapPresetLoadedBroadcaster {}; #endif /** Returns the currently loaded preset, or nullptr if no preset is loaded. */ From cf1e34b7f8800a58dbe525f0207a67979ca93db1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 29 Jan 2024 17:53:19 +0000 Subject: [PATCH 5/9] Apply clang-format --- .../PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h | 1 - .../chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h | 5 ++++- .../chowdsp_presets_v2/Backend/chowdsp_PresetManager.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h index 0a47b4758..c0cff783d 100644 --- a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h +++ b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.h @@ -1,6 +1,5 @@ #pragma once - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter") JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4100) #include diff --git a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h index b1813a5a4..62032e49a 100644 --- a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h +++ b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h @@ -118,7 +118,10 @@ class PluginBase : public juce::AudioProcessor bool supportsParameterModulation() const; #if HAS_CLAP_JUCE_EXTENSIONS && JUCE_MODULE_AVAILABLE_chowdsp_presets_v2 - bool supportsPresetLoad() const noexcept override { return presetManager != nullptr; } + bool supportsPresetLoad() const noexcept override + { + return presetManager != nullptr; + } bool presetLoadFromLocation (uint32_t location_kind, const char* location, const char* load_key) noexcept override; #endif diff --git a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h index a0f760f70..24eb55184 100644 --- a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h +++ b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.h @@ -21,7 +21,7 @@ class PresetManager /** Loads a preset based on information provided by the CLAP preset-load extension. */ virtual bool loadCLAPPreset (uint32_t location_kind, const char* location, const char* load_key) noexcept; - Broadcaster clapPresetLoadedBroadcaster {}; + Broadcaster clapPresetLoadedBroadcaster {}; #endif /** Returns the currently loaded preset, or nullptr if no preset is loaded. */ From d89a21f84484c4cfeb8173a9f27a6468bb07a193 Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 29 Jan 2024 10:05:51 -0800 Subject: [PATCH 6/9] Update CHE version for building examples --- examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 71453009e..714d57489 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ CPMAddPackage( CPMAddPackage( NAME clap-juce-extensions GITHUB_REPOSITORY free-audio/clap-juce-extensions - GIT_TAG 10bc7d4ddb82eab4796b1ce7d1d2dadd46552f27 + GIT_TAG e72d59a870ab6dea156d4912cbd004b715fca5f7 ) include(AddJUCEModules) From 1b7a77e7b3aac52213758bb65ec4a95282dc9a5f Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 29 Jan 2024 10:30:44 -0800 Subject: [PATCH 7/9] Trying to fix test compiler errors --- .../chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h | 2 +- tests/plugin_tests/CMakeLists.txt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h index 62032e49a..65551a5f2 100644 --- a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h +++ b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h @@ -117,7 +117,7 @@ class PluginBase : public juce::AudioProcessor virtual juce::String getWrapperTypeString() const; bool supportsParameterModulation() const; -#if HAS_CLAP_JUCE_EXTENSIONS && JUCE_MODULE_AVAILABLE_chowdsp_presets_v2 +#if 1 // HAS_CLAP_JUCE_EXTENSIONS && JUCE_MODULE_AVAILABLE_chowdsp_presets_v2 bool supportsPresetLoad() const noexcept override { return presetManager != nullptr; diff --git a/tests/plugin_tests/CMakeLists.txt b/tests/plugin_tests/CMakeLists.txt index dd4025dff..104ee7962 100644 --- a/tests/plugin_tests/CMakeLists.txt +++ b/tests/plugin_tests/CMakeLists.txt @@ -13,7 +13,11 @@ setup_juce_lib(plugin_tests_lib ) if(TARGET clap_juce_extensions) - target_link_libraries(plugin_tests_lib PUBLIC clap_juce_extensions) + target_link_libraries(plugin_tests_lib + PUBLIC + clap_juce_extensions + chowdsp::chowdsp_clap_extensions + ) endif() target_compile_definitions(plugin_tests_lib From 2be81bf08dc66281955b78fc02bab313aba8393f Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 29 Jan 2024 10:35:00 -0800 Subject: [PATCH 8/9] Undo temp thing --- .../plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h index 65551a5f2..62032e49a 100644 --- a/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h +++ b/modules/plugin/chowdsp_plugin_base/PluginBase/chowdsp_PluginBase.h @@ -117,7 +117,7 @@ class PluginBase : public juce::AudioProcessor virtual juce::String getWrapperTypeString() const; bool supportsParameterModulation() const; -#if 1 // HAS_CLAP_JUCE_EXTENSIONS && JUCE_MODULE_AVAILABLE_chowdsp_presets_v2 +#if HAS_CLAP_JUCE_EXTENSIONS && JUCE_MODULE_AVAILABLE_chowdsp_presets_v2 bool supportsPresetLoad() const noexcept override { return presetManager != nullptr; From 5b64b1a4d7ab81e00306483b070b18d97fd3b596 Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 29 Jan 2024 10:53:52 -0800 Subject: [PATCH 9/9] Trying to fix warnings on Windows --- .../PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp index 919ac72d2..95afe1e72 100644 --- a/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp +++ b/modules/plugin/chowdsp_clap_extensions/PresetExtensions/chowdsp_CLAPPresetDiscoveryProviders.cpp @@ -3,7 +3,7 @@ #include JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter") -JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4100) +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4100 4127) #include #include JUCE_END_IGNORE_WARNINGS_MSVC