summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-10-07 05:07:55 +0200
committerRobin Gareus <robin@gareus.org>2019-10-07 05:07:55 +0200
commitc663a2d8ef6669054eac817c86d70552580f2138 (patch)
treece042183c86193dd130437236f1f6006d45d02ea /libs
parent85ea1250e1c5be9b941cd0966127facf871c53ac (diff)
Invert Pan-Azimuth (up means left)
It's a well established convention that pan y-axis automation, or vertical uses (top) +1 for left. This special cases rotary knobs (and horizontal sliders) to retain a clockwise movement (or movement to the right) for panning to the right.
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/automation_control.h4
-rw-r--r--libs/ardour/ardour/parameter_descriptor.h12
-rw-r--r--libs/ardour/automation_control.cc8
-rw-r--r--libs/ardour/parameter_descriptor.cc16
-rw-r--r--libs/pbd/pbd/controllable.h11
5 files changed, 39 insertions, 12 deletions
diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h
index 245c70b915..99252f2552 100644
--- a/libs/ardour/ardour/automation_control.h
+++ b/libs/ardour/ardour/automation_control.h
@@ -113,8 +113,8 @@ public:
double normal() const { return _desc.normal; }
bool toggled() const { return _desc.toggled; }
- double internal_to_interface (double i) const;
- double interface_to_internal (double i) const;
+ double internal_to_interface (double, bool rotary = false) const;
+ double interface_to_internal (double, bool rotary = false) const;
virtual std::string get_user_string() const;
diff --git a/libs/ardour/ardour/parameter_descriptor.h b/libs/ardour/ardour/parameter_descriptor.h
index e0df2f9537..e531133b15 100644
--- a/libs/ardour/ardour/parameter_descriptor.h
+++ b/libs/ardour/ardour/parameter_descriptor.h
@@ -61,8 +61,12 @@ struct LIBARDOUR_API ParameterDescriptor : public Evoral::ParameterDescriptor
* interface value, using settings from Evoral::ParameterDescriptor.
*
* default for AutomationControl::internal_to_interface ();
+ *
+ * @param v the control-value to convert
+ * @param rotary set to true if the GUI control is a rotary knob
+ * @return interface value in range 0..1
*/
- float to_interface (float) const;
+ float to_interface (float v, bool rotary = false) const;
/** normalized [0..1] to control-value range
*
@@ -70,8 +74,12 @@ struct LIBARDOUR_API ParameterDescriptor : public Evoral::ParameterDescriptor
* using settings from Evoral::ParameterDescriptor.
*
* default for AutomationControl::interface_to_internal ();
+ *
+ * @param v the value in range 0..1 to on convert
+ * @param rotary set to true if the GUI control is a rotary knob
+ * @return control-value in range lower..upper
*/
- float from_interface (float) const;
+ float from_interface (float v, bool rotary = false) const;
bool is_linear () const;
float compute_delta (float from, float to) const;
diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc
index b8d5226b29..eda77f64b2 100644
--- a/libs/ardour/automation_control.cc
+++ b/libs/ardour/automation_control.cc
@@ -337,23 +337,23 @@ AutomationControl::commit_transaction (bool did_write)
/* take control-value and return UI range [0..1] */
double
-AutomationControl::internal_to_interface (double val) const
+AutomationControl::internal_to_interface (double val, bool rotary) const
{
// XXX maybe optimize. _desc.from_interface() has
// a switch-statement depending on AutomationType.
- return _desc.to_interface (val);
+ return _desc.to_interface (val, rotary);
}
/* map GUI range [0..1] to control-value */
double
-AutomationControl::interface_to_internal (double val) const
+AutomationControl::interface_to_internal (double val, bool rotary) const
{
if (!isfinite_local (val)) {
assert (0);
val = 0;
}
// XXX maybe optimize. see above.
- return _desc.from_interface (val);
+ return _desc.from_interface (val, rotary);
}
std::string
diff --git a/libs/ardour/parameter_descriptor.cc b/libs/ardour/parameter_descriptor.cc
index c86be207f2..1269d69d1a 100644
--- a/libs/ardour/parameter_descriptor.cc
+++ b/libs/ardour/parameter_descriptor.cc
@@ -306,7 +306,7 @@ ParameterDescriptor::midi_note_num (const std::string& name)
}
float
-ParameterDescriptor::to_interface (float val) const
+ParameterDescriptor::to_interface (float val, bool rotary) const
{
val = std::min (upper, std::max (lower, val));
switch(type) {
@@ -323,6 +323,12 @@ ParameterDescriptor::to_interface (float val) const
}
break;
case PanAzimuthAutomation:
+ if (rotary) {
+ val = val;
+ } else {
+ val = 1.0 - val;
+ }
+ break;
case PanElevationAutomation:
val = val;
break;
@@ -356,7 +362,7 @@ ParameterDescriptor::to_interface (float val) const
}
float
-ParameterDescriptor::from_interface (float val) const
+ParameterDescriptor::from_interface (float val, bool rotary) const
{
val = std::max (0.f, std::min (1.f, val));
@@ -374,6 +380,12 @@ ParameterDescriptor::from_interface (float val) const
}
break;
case PanAzimuthAutomation:
+ if (rotary) {
+ val = val;
+ } else {
+ val = 1.0 - val;
+ }
+ break;
case PanElevationAutomation:
val = val;
break;
diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h
index 62127fb048..a83a42bcb3 100644
--- a/libs/pbd/pbd/controllable.h
+++ b/libs/pbd/pbd/controllable.h
@@ -119,8 +119,15 @@ public:
virtual double get_save_value () const { return get_value(); }
/** Conversions between `internal', 'interface', and 'user' values */
- virtual double internal_to_interface (double i) const {return (i-lower())/(upper() - lower());} //by default, the interface range is just a linear interpolation between lower and upper values
- virtual double interface_to_internal (double i) const {return lower() + i*(upper() - lower());}
+ virtual double internal_to_interface (double i, bool rotary = false) const {
+ /* by default, the interface range is just a linear
+ * interpolation between lower and upper values */
+ return (i-lower())/(upper() - lower());
+ }
+
+ virtual double interface_to_internal (double i, bool rotary = false) const {
+ return lower() + i*(upper() - lower());
+ }
/** Get and Set `interface' value (typically, fraction of knob travel) */
virtual float get_interface() const { return (internal_to_interface(get_value())); }