aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-07-22 18:18:10 +0200
committerDavid Robillard <d@drobilla.net>2018-07-22 18:21:49 +0200
commitb1fb68fd3c6ee3535ca066b271150a9cdd54c975 (patch)
tree3df5f2335253bd12b43cfd79debe391cc0457038
parente7992e2c48fb558f0e58099b1e98b4d45fbb58ba (diff)
downloadjalv-b1fb68fd3c6ee3535ca066b271150a9cdd54c975.tar.gz
jalv-b1fb68fd3c6ee3535ca066b271150a9cdd54c975.tar.bz2
jalv-b1fb68fd3c6ee3535ca066b271150a9cdd54c975.zip
Fix stepped logarithmic controls in generic Qt UIs
-rw-r--r--src/jalv_qt.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/jalv_qt.cpp b/src/jalv_qt.cpp
index 38340b2..72f9f0a 100644
--- a/src/jalv_qt.cpp
+++ b/src/jalv_qt.cpp
@@ -14,8 +14,9 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <stdio.h>
-#include <math.h>
+#include <algorithm>
+#include <cmath>
+#include <cstdio>
#include "jalv_internal.h"
@@ -417,7 +418,7 @@ Control::Control(PortContainer portContainer, QWidget* parent)
LilvNode* stepsNode = lilv_port_get(plugin, lilvPort, nodes->pprops_rangeSteps);
if (lilv_node_is_int(stepsNode)) {
- steps = lilv_node_as_int(stepsNode);
+ steps = std::max(lilv_node_as_int(stepsNode), 2);
} else {
steps = DIAL_STEPS;
}
@@ -563,7 +564,7 @@ Control::getValue()
} else if (isInteger) {
return dial->value();
} else if (isLogarithmic) {
- return min * pow(max / min, (float)dial->value() / steps);
+ return min * pow(max / min, (float)dial->value() / (steps - 1));
} else {
return (float)dial->value() / steps;
}