diff --git a/include/clap-juce-extensions/clap-juce-extensions.h b/include/clap-juce-extensions/clap-juce-extensions.h index 5cea719..7238bf5 100644 --- a/include/clap-juce-extensions/clap-juce-extensions.h +++ b/include/clap-juce-extensions/clap-juce-extensions.h @@ -290,6 +290,17 @@ struct clap_juce_audio_processor_capabilities onPresetLoadError(location_kind, location, load_key, os_error, message); } + /** + * The plugin should call this when it has loaded a preset (whether requested from the host, + * or from internally within the plugin). The provided information will help the host to + * keep it's preset browser in-sync with the plugin. + */ + void reportPresetLoaded(uint32_t location_kind, const char *location, const char *load_key) + { + if (onPresetLoaded != nullptr) + onPresetLoaded(location_kind, location, load_key); + } + /* * If you are working with a host that chooses to not implement cookies you will * need to look up parameters by param_id. Use this method to do so. @@ -320,6 +331,8 @@ struct clap_juce_audio_processor_capabilities std::function onPresetLoadError = nullptr; + std::function + onPresetLoaded = nullptr; std::function extensionGet = nullptr; friend const clap_plugin *ClapAdapter::clap_create_plugin(const struct clap_plugin_factory *, diff --git a/src/wrapper/clap-juce-wrapper.cpp b/src/wrapper/clap-juce-wrapper.cpp index b9119aa..2a73125 100644 --- a/src/wrapper/clap-juce-wrapper.cpp +++ b/src/wrapper/clap-juce-wrapper.cpp @@ -42,7 +42,7 @@ JUCE_BEGIN_IGNORE_WARNINGS_MSVC(4100 4127 4244) #include #include -#if CLAP_VERSION_LT(1,2,0) +#if CLAP_VERSION_LT(1, 2, 0) static_assert(false, "CLAP juce wrapper requires at least clap 1.2.0"); #endif @@ -442,6 +442,11 @@ class ClapJuceWrapper : public clap::helpers::Plugin< _host.presetLoadOnError(location_kind, location, load_key, os_error, msg.toRawUTF8()); }; + processorAsClapExtensions->onPresetLoaded = + [this](uint32_t location_kind, const char *location, const char *load_key) { + if (_host.canUsePresetLoad()) + _host.presetLoadLoaded(location_kind, location, load_key); + }; processorAsClapExtensions->extensionGet = [this](const char *name) { return _host.host()->get_extension(_host.host(), name); };