From 085d1a38b916fe7b8601a7a55e79991446dccc8b Mon Sep 17 00:00:00 2001 From: Christoph Hart Date: Mon, 18 Nov 2024 15:15:13 +0100 Subject: [PATCH] - fix filter node enable parameter switching at 0.0 instead of 0.5 - fix harcoded FX corrupting XML when using Faust effects with invalid parameter IDs --- hi_core/hi_modules/effects/fx/SlotFX.cpp | 5 +++-- hi_core/hi_modules/effects/fx/SlotFX.h | 6 ++++++ hi_dsp_library/dsp_nodes/FilterNode.cpp | 3 +-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hi_core/hi_modules/effects/fx/SlotFX.cpp b/hi_core/hi_modules/effects/fx/SlotFX.cpp index 4c4393e08c..c555136e2f 100644 --- a/hi_core/hi_modules/effects/fx/SlotFX.cpp +++ b/hi_core/hi_modules/effects/fx/SlotFX.cpp @@ -810,7 +810,8 @@ void HardcodedSwappableEffect::restoreHardcodedData(const ValueTree& v) for (const auto& p : OpaqueNode::ParameterIterator(*opaqueNode)) { - auto value = v.getProperty(p.info.getId(), p.info.defaultValue); + auto id = getSanitizedParameterId(p.info.getId()); + auto value = v.getProperty(id, p.info.defaultValue); setHardcodedAttribute(p.info.index, value); } } @@ -835,7 +836,7 @@ ValueTree HardcodedSwappableEffect::writeHardcodedData(ValueTree& v) const { for (const auto& p : OpaqueNode::ParameterIterator(*opaqueNode)) { - auto id = p.info.getId(); + auto id = getSanitizedParameterId(p.info.getId()); if(auto ptr = getParameterPtr(p.info.index)) v.setProperty(id, *ptr, nullptr); diff --git a/hi_core/hi_modules/effects/fx/SlotFX.h b/hi_core/hi_modules/effects/fx/SlotFX.h index 0f5cbaccda..2d2364be91 100644 --- a/hi_core/hi_modules/effects/fx/SlotFX.h +++ b/hi_core/hi_modules/effects/fx/SlotFX.h @@ -43,6 +43,12 @@ class HardcodedSwappableEffect : public HotswappableProcessor, { public: + static Identifier getSanitizedParameterId(const String& id) + { + auto sanitized = id.removeCharacters(" \t\n/-+.,"); + return Identifier(sanitized); + } + virtual ~HardcodedSwappableEffect(); // ===================================================================================== Complex Data API calls diff --git a/hi_dsp_library/dsp_nodes/FilterNode.cpp b/hi_dsp_library/dsp_nodes/FilterNode.cpp index 9bdf378a52..107fe698f7 100644 --- a/hi_dsp_library/dsp_nodes/FilterNode.cpp +++ b/hi_dsp_library/dsp_nodes/FilterNode.cpp @@ -84,8 +84,7 @@ void FilterNodeBase::setFrequency(double newFrequency) template void FilterNodeBase::setEnabled(double isEnabled) { - enabled = isEnabled; - + enabled = isEnabled > 0.5; this->sendCoefficientUpdateMessage(); }