Browse Source

Add `smooth` variable for ParamWidgets

tags/v0.6.0
Andrew Belt 6 years ago
parent
commit
4596d29f1c
4 changed files with 13 additions and 13 deletions
  1. +3
    -2
      include/app.hpp
  2. +2
    -0
      include/componentlibrary.hpp
  3. +4
    -10
      src/app/Knob.cpp
  4. +4
    -1
      src/app/ParamWidget.cpp

+ 3
- 2
include/app.hpp View File

@@ -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 {


+ 2
- 0
include/componentlibrary.hpp View File

@@ -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;
} }
}; };




+ 4
- 10
src/app/Knob.cpp View File

@@ -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

+ 4
- 1
src/app/ParamWidget.cpp View File

@@ -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);
} }






Loading…
Cancel
Save