diff --git a/include/app.hpp b/include/app.hpp index 273a14e3..4e136f8b 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -217,6 +217,8 @@ struct ParamWidget : OpaqueWidget, QuantityWidget { To permanently disable or change randomization behavior, override the randomize() method instead of changing this. */ bool randomizable = true; + /** Apply per-sample smoothing in the engine */ + bool smooth = false; json_t *toJson(); void fromJson(json_t *rootJ); @@ -243,11 +245,10 @@ struct Knob : ParamWidget { /** Multiplier for mouse movement to adjust knob value */ float speed = 1.0; float dragValue; + Knob(); void onDragStart(EventDragStart &e) override; void onDragMove(EventDragMove &e) override; void onDragEnd(EventDragEnd &e) override; - /** Tell engine to smoothly vary this parameter */ - void onChange(EventChange &e) override; }; struct SpriteKnob : virtual Knob, SpriteWidget { diff --git a/include/componentlibrary.hpp b/include/componentlibrary.hpp index 70e5807b..fb151c6a 100644 --- a/include/componentlibrary.hpp +++ b/include/componentlibrary.hpp @@ -62,6 +62,7 @@ struct RoundHugeBlackKnob : RoundBlackKnob { struct RoundSmallBlackSnapKnob : RoundSmallBlackKnob { RoundSmallBlackSnapKnob() { snap = true; + smooth = false; } }; @@ -312,6 +313,7 @@ struct BefacoBigKnob : SVGKnob { struct BefacoBigSnapKnob : BefacoBigKnob { BefacoBigSnapKnob() { snap = true; + smooth = false; } }; diff --git a/src/app/Knob.cpp b/src/app/Knob.cpp index dab3154b..51d5288f 100644 --- a/src/app/Knob.cpp +++ b/src/app/Knob.cpp @@ -10,6 +10,10 @@ namespace rack { #define KNOB_SENSITIVITY 0.0015 +Knob::Knob() { + smooth = true; +} + void Knob::onDragStart(EventDragStart &e) { windowCursorLock(); dragValue = value; @@ -37,15 +41,5 @@ void Knob::onDragEnd(EventDragEnd &e) { randomizable = true; } -void Knob::onChange(EventChange &e) { - if (!module) - return; - - if (snap) - engineSetParam(module, paramId, value); - else - engineSetParamSmooth(module, paramId, value); -} - } // namespace rack diff --git a/src/app/ParamWidget.cpp b/src/app/ParamWidget.cpp index 7c56c34c..4ddf02eb 100644 --- a/src/app/ParamWidget.cpp +++ b/src/app/ParamWidget.cpp @@ -39,7 +39,10 @@ void ParamWidget::onChange(EventChange &e) { if (!module) return; - engineSetParam(module, paramId, value); + if (smooth) + engineSetParamSmooth(module, paramId, value); + else + engineSetParam(module, paramId, value); }