@@ -140,29 +140,44 @@ class FloatParameter : public BaseParameter {
140
140
// //// slew rate stuff
141
141
uint32_t last_slewed_at = 0 ;
142
142
float last_slewed_value = 0 .0f ;
143
- // todo: make this control whether slew is enabled or disabled
144
- bool slew_enabled = false ;
145
- bool slewing = false ;
146
- // todo: tweak this slew value; make it configurable from the screen/modulation
147
- float slew_rate = (0 .001f ) / 10 .0f ;
148
- virtual float get_slew_rate () {
149
- return slew_rate;
150
- }
151
-
143
+
144
+ bool slew_enabled = false ; // enable/disable slewing
145
+ bool slewing = false ; // track whether we are currently slewing or not
146
+
147
+ // actual slew values - amount of change per millisecond (then divided by 10)
148
+ const float slowest_slew_rate = 0 .001f ;
149
+ const float fastest_slew_rate = 0 .1f ;
150
+ float slew_rate = (fastest_slew_rate) / 10 .0f ;
151
+
152
+ // normalised value for use by menus / modulation
153
+ float slew_rate_normal = 1 .0f ;
154
+
152
155
// weirdly, having this here seems to cause lockups when usb is connected..?
153
156
/* virtual void set_slew_rate(float slew_rate) {
154
- this->slew_rate = slew_rate;
157
+ //this->slew_rate = slew_rate;
158
+ this->slew_rate = map(slew_rate, 0.0f, 1.0f, slowest_slew_rate, fastest_slew_rate) / 10.0f;
155
159
}*/
160
+
161
+ virtual float get_slew_rate_normal () {
162
+ return slew_rate_normal;
163
+ }
164
+ virtual void set_slew_rate_normal (float slew_rate_normal) {
165
+ this ->slew_rate_normal = slew_rate_normal;
166
+ this ->slew_rate = map (slew_rate_normal, 0 .0f , 1 .0f , slowest_slew_rate, fastest_slew_rate) / 100 .0f ;
167
+ if (debug && Serial) Serial.printf (" %s#set_slew_rate_normal(%3.3f) - slew_rate is %3.3f\n " , this ->label , slew_rate_normal, this ->slew_rate );
168
+ }
169
+
156
170
virtual float get_slewed_value (float normal) {
157
- if (!slew_enabled) {
171
+ if (!slew_enabled || slew_rate_normal>= 1 . 0f ) {
158
172
last_slewed_value = normal;
159
173
return normal;
160
174
}
161
175
uint32_t delta = millis () - last_slewed_at;
162
176
last_slewed_at = millis ();
163
177
164
- // todo: make slew rate a function of the delta time
165
- float slew_rate = this ->get_slew_rate () * (float )delta;
178
+ if (debug && Serial) Serial.printf (" %s#get_slewed_value() - slewing enabled, slew_rate is %3.3f, slew_rate_normal is %3.3f\n " , this ->label , this ->slew_rate , this ->slew_rate_normal );
179
+
180
+ float slew_rate = this ->slew_rate * (float )delta;
166
181
float diff = normal - this ->lastRealOutputNormalValue ;
167
182
168
183
if (debug) {
0 commit comments