summaryrefslogtreecommitdiff
path: root/libs/ardour/automation_control.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/automation_control.cc')
-rw-r--r--libs/ardour/automation_control.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc
index bfa16f9e4a..21952038cf 100644
--- a/libs/ardour/automation_control.cc
+++ b/libs/ardour/automation_control.cc
@@ -139,3 +139,49 @@ AutomationControl::stop_touch(bool mark, double when)
}
}
}
+
+double
+AutomationControl::internal_to_interface (double val) const
+{
+ if (_desc.integer_step) {
+ // both upper and lower are inclusive.
+ val = (val - lower()) / (1 + upper() - lower());
+ } else {
+ val = (val - lower()) / (upper() - lower());
+ }
+
+ if (_desc.logarithmic) {
+ if (val > 0) {
+ val = pow (val, 1/1.5);
+ } else {
+ val = 0;
+ }
+ }
+
+ return val;
+}
+
+double
+AutomationControl::interface_to_internal (double val) const
+{
+ if (_desc.logarithmic) {
+ if (val <= 0) {
+ val = 0;
+ } else {
+ val = pow (val, 1.5);
+ }
+ }
+
+ if (_desc.integer_step) {
+ val = lower() + val * (1 + upper() - lower());
+ } else {
+ val = lower() + val * (upper() - lower());
+ }
+
+ if (val < lower()) val = lower();
+ if (val > upper()) val = upper();
+
+ return val;
+}
+
+