diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h index eb4b7ff142..4260429952 100644 --- a/libs/pbd/pbd/controllable.h +++ b/libs/pbd/pbd/controllable.h @@ -30,6 +30,9 @@ #include "pbd/statefuldestructible.h" +using std::min; +using std::max; + class XMLNode; namespace PBD { @@ -60,11 +63,25 @@ class LIBPBD_API Controllable : public PBD::StatefulDestructible { * but passed to the processor as a linear quantity. */ - /** Set `internal' value */ + /** Get and Set `internal' value */ virtual void set_value (double) = 0; - /** @return `internal' value */ virtual double get_value (void) const = 0; + /** 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_user (double i) const {return i;} //by default the internal value is the same as the user value + virtual double user_to_internal (double i) const {return i;} //by default the internal value is the same as the user value + + /** Get and Set `interface' value (typically, percent of knob travel) */ + virtual float get_interface() const { return (internal_to_interface(get_value())); } + virtual void set_interface (float percent) { percent = min( max(0.0f, percent), 1.0f); set_value(interface_to_internal(percent)); } + + /** Get and Set `user' value ( dB or milliseconds, etc. This MIGHT be the same as the internal value, but in a few cases it is not ) */ + virtual float get_user() const { return (internal_to_user(get_value())); } + virtual void set_user (float user_v) { set_value(user_to_internal(user_v)); } + virtual std::string get_user_string() const { return std::string(); } + PBD::Signal0 LearningFinished; static PBD::Signal3 CreateBinding; static PBD::Signal1 DeleteBinding; @@ -89,6 +106,7 @@ class LIBPBD_API Controllable : public PBD::StatefulDestructible { virtual double lower() const { return 0.0; } virtual double upper() const { return 1.0; } + virtual double normal() const { return 0.0; } //the default value Flag flags() const { return _flags; } void set_flags (Flag f); @@ -99,6 +117,8 @@ class LIBPBD_API Controllable : public PBD::StatefulDestructible { private: std::string _name; + std::string _units; + Flag _flags; bool _touching;