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