diff --git a/include/app/Knob.hpp b/include/app/Knob.hpp index 0a03cd8e..c5e3b36d 100644 --- a/include/app/Knob.hpp +++ b/include/app/Knob.hpp @@ -17,7 +17,7 @@ struct Knob : ParamWidget { bool horizontal = false; /** Enables per-sample value smoothing while dragging. */ bool smooth = true; - /** DEPRECATED. Use `ParamQuantity::snapEnabled`. */ + /** Enables value snapping to the nearest integer. */ bool snap = false; /** Multiplier for mouse movement to adjust knob value */ float speed = 1.f; diff --git a/include/engine/ParamQuantity.hpp b/include/engine/ParamQuantity.hpp index b2487226..d48301ef 100644 --- a/include/engine/ParamQuantity.hpp +++ b/include/engine/ParamQuantity.hpp @@ -58,6 +58,8 @@ struct ParamQuantity : Quantity { Unbounded (infinite) parameters are not randomizable, regardless of this setting. */ bool randomizeEnabled = true; + /** Enables per-sample Engine parameter smoothing when setSmoothValue() is called. */ + bool smoothEnabled = false; /** Rounds values to the nearest integer. */ bool snapEnabled = false; diff --git a/src/app/Knob.cpp b/src/app/Knob.cpp index 0af91850..6eec60d1 100644 --- a/src/app/Knob.cpp +++ b/src/app/Knob.cpp @@ -40,6 +40,8 @@ void Knob::initParamQuantity() { if (pq) { if (snap) pq->snapEnabled = true; + if (smooth) + pq->smoothEnabled = true; } } @@ -133,7 +135,7 @@ void Knob::onDragMove(const DragMoveEvent& e) { engine::ParamQuantity* pq = getParamQuantity(); if (pq) { - float value = smooth ? pq->getSmoothValue() : pq->getValue(); + float value = pq->getSmoothValue(); // Ratio between parameter value scale / (angle range / 2*pi) float rangeRatio; @@ -206,10 +208,7 @@ void Knob::onDragMove(const DragMoveEvent& e) { } // Set value - if (smooth) - pq->setSmoothValue(value); - else - pq->setValue(value); + pq->setSmoothValue(value); } ParamWidget::onDragMove(e); @@ -230,7 +229,7 @@ void Knob::onHoverScroll(const HoverScrollEvent& e) { if (settings::knobScroll) { engine::ParamQuantity* pq = getParamQuantity(); if (pq) { - float value = smooth ? pq->getSmoothValue() : pq->getValue(); + float value = pq->getSmoothValue(); float rangeRatio; if (pq->isBounded()) { @@ -254,10 +253,7 @@ void Knob::onHoverScroll(const HoverScrollEvent& e) { } value += delta; - if (smooth) - pq->setSmoothValue(value); - else - pq->setValue(value); + pq->setSmoothValue(value); e.consume(this); } diff --git a/src/app/Switch.cpp b/src/app/Switch.cpp index dc88d5c7..b0c3d84b 100644 --- a/src/app/Switch.cpp +++ b/src/app/Switch.cpp @@ -14,6 +14,7 @@ void Switch::initParamQuantity() { engine::ParamQuantity* pq = getParamQuantity(); if (pq) { pq->snapEnabled = true; + pq->smoothEnabled = false; if (momentary) { pq->resetEnabled = false; pq->randomizeEnabled = false; diff --git a/src/engine/ParamQuantity.cpp b/src/engine/ParamQuantity.cpp index 6cd1642b..c02fecd5 100644 --- a/src/engine/ParamQuantity.cpp +++ b/src/engine/ParamQuantity.cpp @@ -22,13 +22,19 @@ void ParamQuantity::setSmoothValue(float value) { value = math::clampSafe(value, getMinValue(), getMaxValue()); if (snapEnabled) value = std::round(value); - APP->engine->setParamSmoothValue(module, paramId, value); + if (smoothEnabled) + APP->engine->setParamSmoothValue(module, paramId, value); + else + APP->engine->setParamValue(module, paramId, value); } float ParamQuantity::getSmoothValue() { if (!module) return 0.f; - return APP->engine->getParamSmoothValue(module, paramId); + if (smoothEnabled) + return APP->engine->getParamSmoothValue(module, paramId); + else + return APP->engine->getParamValue(module, paramId); } void ParamQuantity::setSmoothScaledValue(float scaledValue) {