The integer steps min/max are inclusive.
e.g the integer range -1 to +1 has three possible values (not two).
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;
+
const ParameterDescriptor& desc() const { return _desc; }
const ARDOUR::Session& session() const { return _session; }
double get_value (void) const;
XMLNode& get_state();
- double internal_to_interface (double) const;
- double interface_to_internal (double) const;
-
private:
PluginInsert* _plugin;
};
}
}
}
+
+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;
+}
+
+
AutomationControl::set_value (user_val);
}
-double
-PluginInsert::PluginControl::internal_to_interface (double val) const
-{
- val = Controllable::internal_to_interface(val);
-
- if (_desc.logarithmic) {
- if (val > 0) {
- val = pow (val, 1/1.5);
- } else {
- val = 0;
- }
- }
-
- return val;
-}
-
-double
-PluginInsert::PluginControl::interface_to_internal (double val) const
-{
- if (_desc.logarithmic) {
- if (val <= 0) {
- val = 0;
- } else {
- val = pow (val, 1.5);
- }
- }
-
- val = Controllable::interface_to_internal(val);
-
- return val;
-}
-
XMLNode&
PluginInsert::PluginControl::get_state ()
{