13
0

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.
This commit is contained in:
Robin Gareus 2019-10-07 05:07:55 +02:00
parent 85ea1250e1
commit c663a2d8ef
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 39 additions and 12 deletions

View File

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

View File

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

View File

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

View File

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

View File

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