diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/amp.cc | 13 | ||||
-rw-r--r-- | libs/ardour/ardour/amp.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/monitor_processor.h | 11 | ||||
-rw-r--r-- | libs/ardour/ardour/proxy_controllable.h | 9 | ||||
-rw-r--r-- | libs/canvas/canvas/utils.h | 4 | ||||
-rw-r--r-- | libs/canvas/utils.cc | 33 | ||||
-rw-r--r-- | libs/pbd/pbd/controllable.h | 20 |
7 files changed, 90 insertions, 2 deletions
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index 29032525f2..2265c6de03 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -426,6 +426,19 @@ Amp::GainControl::internal_to_user (double v) const return accurate_coefficient_to_dB (v); } +double +Amp::GainControl::user_to_internal (double u) const +{ + return dB_to_coefficient (u); +} + +std::string +Amp::GainControl::get_user_string () const +{ + char theBuf[32]; sprintf( theBuf, "%3.1f dB", accurate_coefficient_to_dB (get_value())); + return std::string(theBuf); +} + /** Write gain automation for this cycle into the buffer previously passed in to * set_gain_automation_buffer (if we are in automation playback mode and the * transport is rolling). diff --git a/libs/ardour/ardour/amp.h b/libs/ardour/ardour/amp.h index f6a15666e9..c0e9dbc5b5 100644 --- a/libs/ardour/ardour/amp.h +++ b/libs/ardour/ardour/amp.h @@ -90,6 +90,8 @@ public: double internal_to_interface (double) const; double interface_to_internal (double) const; double internal_to_user (double) const; + double user_to_internal (double) const; + std::string get_user_string () const; Amp* _amp; }; diff --git a/libs/ardour/ardour/monitor_processor.h b/libs/ardour/ardour/monitor_processor.h index 33b3e9c366..2fe108a427 100644 --- a/libs/ardour/ardour/monitor_processor.h +++ b/libs/ardour/ardour/monitor_processor.h @@ -32,6 +32,8 @@ #include "ardour/types.h" #include "ardour/processor.h" +#include "ardour/dB.h" + class XMLNode; namespace ARDOUR { @@ -63,6 +65,15 @@ public: return (float) _value; } + double internal_to_user (double i) const { return accurate_coefficient_to_dB (i);} + double user_to_internal (double u) const { return dB_to_coefficient(u) ;} + + std::string get_user_string () const + { + char theBuf[32]; sprintf( theBuf, "%3.1f dB", accurate_coefficient_to_dB (get_value())); + return std::string(theBuf); + } + double lower () const { return _lower; } double upper () const { return _upper; } diff --git a/libs/ardour/ardour/proxy_controllable.h b/libs/ardour/ardour/proxy_controllable.h index 066f2aac81..522c3a2794 100644 --- a/libs/ardour/ardour/proxy_controllable.h +++ b/libs/ardour/ardour/proxy_controllable.h @@ -43,6 +43,15 @@ public: void set_value (double v) { if (_setter (v)) { Changed(); /* EMIT SIGNAL */ } } double get_value () const { return _getter (); } + double internal_to_user (double i) const { return accurate_coefficient_to_dB (i);} + double user_to_internal (double u) const { return dB_to_coefficient(u) ;} + + std::string get_user_string () const + { + char theBuf[32]; sprintf( theBuf, "%3.1f dB", accurate_coefficient_to_dB (get_value())); + return std::string(theBuf); + } + private: boost::function1<bool,double> _setter; boost::function0<double> _getter; diff --git a/libs/canvas/canvas/utils.h b/libs/canvas/canvas/utils.h index e269ca215c..947e57cc7c 100644 --- a/libs/canvas/canvas/utils.h +++ b/libs/canvas/canvas/utils.h @@ -29,6 +29,10 @@ namespace ArdourCanvas { extern LIBCANVAS_API Color rgba_to_color (double r, double g, double b, double a); extern LIBCANVAS_API void set_source_rgba (Cairo::RefPtr<Cairo::Context>, Color); + extern LIBCANVAS_API void set_source_rgb_a (Cairo::RefPtr<Cairo::Context>, Color, float alpha); //override the color's alpha + + extern LIBCANVAS_API void set_source_rgba (cairo_t*, Color); + extern LIBCANVAS_API void set_source_rgb_a (cairo_t*, Color, float alpha); //override the color's alpha Distance LIBCANVAS_API distance_to_segment_squared (Duple const & p, Duple const & p1, Duple const & p2, double& t, Duple& at); diff --git a/libs/canvas/utils.cc b/libs/canvas/utils.cc index 99516c849b..b7571a7844 100644 --- a/libs/canvas/utils.cc +++ b/libs/canvas/utils.cc @@ -154,6 +154,39 @@ ArdourCanvas::set_source_rgba (Cairo::RefPtr<Cairo::Context> context, Color colo ); } +void +ArdourCanvas::set_source_rgb_a (Cairo::RefPtr<Cairo::Context> context, Color color, float alpha) +{ + context->set_source_rgba ( + ((color >> 24) & 0xff) / 255.0, + ((color >> 16) & 0xff) / 255.0, + ((color >> 8) & 0xff) / 255.0, + alpha + ); +} + +void +ArdourCanvas::set_source_rgba (cairo_t *cr, Color color) +{ + cairo_set_source_rgba ( cr, + ((color >> 24) & 0xff) / 255.0, + ((color >> 16) & 0xff) / 255.0, + ((color >> 8) & 0xff) / 255.0, + ((color >> 0) & 0xff) / 255.0 + ); +} + +void +ArdourCanvas::set_source_rgb_a (cairo_t *cr, Color color, float alpha) +{ + cairo_set_source_rgba ( cr, + ((color >> 24) & 0xff) / 255.0, + ((color >> 16) & 0xff) / 255.0, + ((color >> 8) & 0xff) / 255.0, + alpha + ); +} + ArdourCanvas::Distance ArdourCanvas::distance_to_segment_squared (Duple const & p, Duple const & p1, Duple const & p2, double& t, Duple& at) { diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h index eb4b7ff142..fb8f79db09 100644 --- a/libs/pbd/pbd/controllable.h +++ b/libs/pbd/pbd/controllable.h @@ -60,11 +60,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 = std::min( std::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<void> LearningFinished; static PBD::Signal3<void,PBD::Controllable*,int,int> CreateBinding; static PBD::Signal1<void,PBD::Controllable*> DeleteBinding; @@ -99,6 +113,8 @@ class LIBPBD_API Controllable : public PBD::StatefulDestructible { private: std::string _name; + std::string _units; + Flag _flags; bool _touching; |