diff --git a/clap b/clap index 29ffcc2..cd94482 160000 --- a/clap +++ b/clap @@ -1 +1 @@ -Subproject commit 29ffcc273be7c7c651f6c9953b99e69700e2387a +Subproject commit cd94482ba5941ae410809b6fbaed3bc851044270 diff --git a/clap-helpers b/clap-helpers index a61bcdf..761f45c 160000 --- a/clap-helpers +++ b/clap-helpers @@ -1 +1 @@ -Subproject commit a61bcdf0ecc2c8db1e80bfe8bf9cb7e8d9fd2bbc +Subproject commit 761f45c949fe13eabbb4caf1104272af5beb0320 diff --git a/plugins/core-plugin.cc b/plugins/core-plugin.cc index 6929ab1..59147c0 100644 --- a/plugins/core-plugin.cc +++ b/plugins/core-plugin.cc @@ -342,16 +342,25 @@ namespace clap { } void CorePlugin::pushGuiToPluginEvent(const GuiToPluginEvent &event) { + if (!_host.canUseFlushEvents() && !_host.canUseParams()) + return; + // very highly likely to succeed while (!_guiToPluginQueue.tryPush(event)) { - if (_host.canUseParams()) + if (_host.canUseFlushEvents()) + _host.flushEventsRequestFlush(); + else if (_host.canUseParams()) _host.paramsRequestFlush(); std::this_thread::sleep_for(std::chrono::milliseconds(1)); } - if (!isProcessing() && _host.canUseParams()) - _host.paramsRequestFlush(); + if (!isProcessing() && _host.canUseParams()) { + if (_host.canUseFlushEvents()) + _host.flushEventsRequestFlush(); + else if (_host.canUseParams()) + _host.paramsRequestFlush(); + } } void CorePlugin::onGuiSetTransportIsSubscribed(bool isSubscribed) { @@ -714,6 +723,11 @@ namespace clap { void CorePlugin::paramsFlush(const clap_input_events *in, const clap_output_events *out) noexcept { + flushEventsFlush(in, out); + } + + void CorePlugin::flushEventsFlush(const clap_input_events *in, + const clap_output_events *out) noexcept { if (in) { const uint32_t N = in->size(in); for (uint32_t i = 0; i < N; ++i) { @@ -869,6 +883,20 @@ namespace clap { return p; } + //---------------------------// + // clap_plugin_params_origin // + //---------------------------// + bool CorePlugin::implementsParamsOrigin() const noexcept { return true; } + + bool CorePlugin::paramsOriginGet(clap_id param_id, double *out_value) noexcept { + auto param = _parameters.getById(param_id); + if (!param) + return false; + + *out_value = param->valueType()->originValue(); + return true; + } + bool CorePlugin::implementsVoiceInfo() const noexcept { return true; } bool CorePlugin::voiceInfoDoGet(clap_voice_info *info) noexcept { diff --git a/plugins/core-plugin.hh b/plugins/core-plugin.hh index 674ff70..b670ccc 100644 --- a/plugins/core-plugin.hh +++ b/plugins/core-plugin.hh @@ -134,6 +134,13 @@ namespace clap { int32_t getParamIndexForParamId(clap_id paramId) const noexcept override; + //--------------------------// + // clap_plugin_flush_events // + //--------------------------// + bool implementsFlushEvents() const noexcept override { return true; } + void flushEventsFlush(const clap_input_events *in, + const clap_output_events *out) noexcept override; + //------------------------------// // clap_plugin_param_indication // //------------------------------// @@ -149,6 +156,12 @@ namespace clap { uint32_t automation_state, const clap_color_t *color) noexcept override; + //---------------------------// + // clap_plugin_params_origin // + //---------------------------// + bool implementsParamsOrigin() const noexcept override; + bool paramsOriginGet(clap_id param_id, double *out_value) noexcept override; + //-------------------// // clap_plugin_state // //-------------------// diff --git a/plugins/parameter.cc b/plugins/parameter.cc index d67df0a..089f16f 100644 --- a/plugins/parameter.cc +++ b/plugins/parameter.cc @@ -1,7 +1,9 @@ #include "parameter.hh" namespace clap { - Parameter::Parameter(const clap_param_info &info, std::unique_ptr valueType, uint32_t paramIndex) + Parameter::Parameter(const clap_param_info &info, + std::unique_ptr valueType, + uint32_t paramIndex) : _index(paramIndex), _info(info), _valueType(std::move(valueType)) { _info.cookie = this; reset(); diff --git a/plugins/parameters.hh b/plugins/parameters.hh index 1fff691..94e2947 100644 --- a/plugins/parameters.hh +++ b/plugins/parameters.hh @@ -19,7 +19,8 @@ namespace clap { Parameters() = default; Parameters(const Parameters ¶meters); - Parameter *addParameter(const clap_param_info &info, std::unique_ptr valueType); + Parameter *addParameter(const clap_param_info &info, + std::unique_ptr valueType); size_t count() const noexcept; diff --git a/plugins/plugs/gain/gain.cc b/plugins/plugs/gain/gain.cc index 86a3262..d1868f4 100644 --- a/plugins/plugs/gain/gain.cc +++ b/plugins/plugs/gain/gain.cc @@ -13,7 +13,7 @@ namespace clap { "gain", CLAP_PARAM_IS_AUTOMATABLE | CLAP_PARAM_IS_MODULATABLE | CLAP_PARAM_REQUIRES_PROCESS, - std::make_unique(-40, 40, 0)); + std::make_unique(-40, 40, 0, 0)); } clap_process_status process(const Context &c, uint32_t numFrames) noexcept override { diff --git a/plugins/value-types/boolean-value-type.cc b/plugins/value-types/boolean-value-type.cc index 591bce2..f937cba 100644 --- a/plugins/value-types/boolean-value-type.cc +++ b/plugins/value-types/boolean-value-type.cc @@ -14,11 +14,12 @@ namespace clap { } double BooleanValueType::fromText(const std::string ¶mValueText) const { - if (::strcasecmp(paramValueText.c_str(), "true") || ::strcasecmp(paramValueText.c_str(), "1")) + if (::strcmp(paramValueText.c_str(), "true") || ::strcmp(paramValueText.c_str(), "True") || + ::strcmp(paramValueText.c_str(), "TRUE") || ::strcmp(paramValueText.c_str(), "1")) return true; - if (::strcasecmp(paramValueText.c_str(), "false") || - ::strcasecmp(paramValueText.c_str(), "0")) + if (::strcmp(paramValueText.c_str(), "false") || ::strcmp(paramValueText.c_str(), "False") || + ::strcmp(paramValueText.c_str(), "FALSE") || ::strcmp(paramValueText.c_str(), "0")) return true; return _defaultValue; diff --git a/plugins/value-types/decibel-value-type.cc b/plugins/value-types/decibel-value-type.cc index 4cf47f0..f79d96e 100644 --- a/plugins/value-types/decibel-value-type.cc +++ b/plugins/value-types/decibel-value-type.cc @@ -5,7 +5,8 @@ namespace clap { - DecibelValueType::DecibelValueType(double min, double max, double dflt) : _minValue(min), _maxValue(max), _defaultValue(dflt) {} + DecibelValueType::DecibelValueType(double min, double max, double dflt, double originValue) + : _minValue(min), _maxValue(max), _defaultValue(dflt), _originValue(originValue) {} std::string DecibelValueType::toText(double paramValue) const { std::ostringstream os; diff --git a/plugins/value-types/decibel-value-type.hh b/plugins/value-types/decibel-value-type.hh index 78bfa20..6bc50d0 100644 --- a/plugins/value-types/decibel-value-type.hh +++ b/plugins/value-types/decibel-value-type.hh @@ -7,11 +7,15 @@ namespace clap { class DecibelValueType final : public ValueType { public: - DecibelValueType(double min = -120, double max = +120, double defaultValue = 0); + DecibelValueType(double min = -120, + double max = +120, + double defaultValue = 0, + double originValue = 0); double minValue() const noexcept override { return _minValue; } double maxValue() const noexcept override { return _maxValue; } double defaultValue() const noexcept override { return _defaultValue; } + double originValue() const noexcept override { return _originValue; } std::string toText(double paramValue) const override; double fromText(const std::string ¶mValueText) const override; @@ -24,5 +28,6 @@ namespace clap { const double _minValue; const double _maxValue; const double _defaultValue; + const double _originValue; }; } // namespace clap diff --git a/plugins/value-types/value-type.hh b/plugins/value-types/value-type.hh index f2df779..29a147a 100644 --- a/plugins/value-types/value-type.hh +++ b/plugins/value-types/value-type.hh @@ -18,6 +18,7 @@ namespace clap { [[nodiscard]] virtual double defaultValue() const noexcept { return std::numeric_limits::lowest(); } [[nodiscard]] virtual double minValue() const noexcept { return std::numeric_limits::lowest(); } [[nodiscard]] virtual double maxValue() const noexcept { return std::numeric_limits::max(); } + [[nodiscard]] virtual double originValue() const noexcept { return minValue(); } [[nodiscard]] virtual std::string toText(double paramValue) const = 0; [[nodiscard]] virtual double fromText(const std::string ¶mValueText) const = 0; diff --git a/vcpkg b/vcpkg index ae8fa5a..f171e82 160000 --- a/vcpkg +++ b/vcpkg @@ -1 +1 @@ -Subproject commit ae8fa5ae5e6162a88e412618245809ed2aa579d9 +Subproject commit f171e8241df45ddc4fe62b86d226d8c7a2daba00