From d116af22db3c0e0cf6aeff6194a689d8bfad7c8c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 27 Jan 2011 18:48:33 +0000 Subject: virtualize the way that AutomationController gets strings to display values, so that we can callback through the owner of an AutomationControl, not just rely on the value from the AutomationControl; make pan automation tracks use this to display more audio-centric values git-svn-id: svn://localhost/ardour2/branches/3.0@8590 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/automation_controller.cc | 21 +++++---------------- gtk2_ardour/automation_controller.h | 3 ++- gtk2_ardour/automation_time_axis.cc | 2 +- libs/ardour/ardour/automatable.h | 1 + libs/ardour/ardour/pannable.h | 2 ++ libs/ardour/ardour/panner.h | 1 + libs/ardour/automatable.cc | 20 ++++++++++++++++++++ libs/ardour/pannable.cc | 12 ++++++++++-- libs/ardour/panner.cc | 6 ++++++ libs/gtkmm2ext/gtkmm2ext/barcontroller.h | 2 ++ libs/panners/1in2out/panner_1in2out.cc | 24 ++++++++++++++++++++++++ libs/panners/1in2out/panner_1in2out.h | 1 + libs/panners/2in2out/panner_2in2out.cc | 27 +++++++++++++++++++++++++++ libs/panners/2in2out/panner_2in2out.h | 1 + libs/panners/vbap/vbap.cc | 18 ++++++++++++++++++ libs/panners/vbap/vbap.h | 1 + 16 files changed, 122 insertions(+), 20 deletions(-) diff --git a/gtk2_ardour/automation_controller.cc b/gtk2_ardour/automation_controller.cc index f09fae905b..540612c8d4 100644 --- a/gtk2_ardour/automation_controller.cc +++ b/gtk2_ardour/automation_controller.cc @@ -19,6 +19,7 @@ */ #include +#include #include "pbd/error.h" @@ -40,10 +41,10 @@ using namespace ARDOUR; using namespace Gtk; - -AutomationController::AutomationController(boost::shared_ptr ac, Adjustment* adj) +AutomationController::AutomationController(boost::shared_ptr owner, boost::shared_ptr ac, Adjustment* adj) : BarController (*adj, ac) , _ignore_change(false) + , _owner (owner) , _controllable(ac) , _adjustment(adj) { @@ -80,30 +81,18 @@ AutomationController::create( } else { assert(ac->parameter() == param); } - return boost::shared_ptr(new AutomationController(ac, adjustment)); + return boost::shared_ptr(new AutomationController(parent, ac, adjustment)); } std::string AutomationController::get_label (int&) { - std::stringstream s; - - // Hack to display CC rounded to int - if (_controllable->parameter().type() == MidiCCAutomation) { - s << (int)_controllable->get_value(); - } else { - s << std::fixed << std::setprecision(3) << _controllable->get_value(); - } - - return s.str (); + return _owner->value_as_string (_controllable); } void AutomationController::display_effective_value() { - //if ( ! _controllable->list()->automation_playback()) - // return; - float value = _controllable->get_value(); if (_adjustment->get_value() != value) { diff --git a/gtk2_ardour/automation_controller.h b/gtk2_ardour/automation_controller.h index a2168700e2..814f716f13 100644 --- a/gtk2_ardour/automation_controller.h +++ b/gtk2_ardour/automation_controller.h @@ -54,7 +54,7 @@ public: void stop_updating (); private: - AutomationController (boost::shared_ptr ac, Gtk::Adjustment* adj); + AutomationController (boost::shared_ptr parent, boost::shared_ptr ac, Gtk::Adjustment* adj); std::string get_label (int&); void start_touch(); @@ -64,6 +64,7 @@ private: void automation_state_changed(); bool _ignore_change; + boost::shared_ptr _owner; boost::shared_ptr _controllable; Gtk::Adjustment* _adjustment; sigc::connection _screen_update_connection; diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index e0a2cd0970..2cdb6f7de9 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -148,6 +148,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session* s, boost::shared_ptrset_name (X_("TrackPlugName")); plugname->show(); - name_label.set_name (X_("TrackParameterName")); controls_table.remove (name_hbox); controls_table.attach (*plugname, 1, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND); plugname_packed = true; diff --git a/libs/ardour/ardour/automatable.h b/libs/ardour/ardour/automatable.h index c9e900e6a9..1abfb4faf1 100644 --- a/libs/ardour/ardour/automatable.h +++ b/libs/ardour/ardour/automatable.h @@ -63,6 +63,7 @@ public: virtual void transport_stopped (framepos_t now); virtual std::string describe_parameter(Evoral::Parameter param); + virtual std::string value_as_string (boost::shared_ptr) const; AutoState get_parameter_automation_state (Evoral::Parameter param); virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState); diff --git a/libs/ardour/ardour/pannable.h b/libs/ardour/ardour/pannable.h index dff64cec4b..3dc4ccb8fd 100644 --- a/libs/ardour/ardour/pannable.h +++ b/libs/ardour/ardour/pannable.h @@ -65,6 +65,8 @@ struct Pannable : public PBD::Stateful, public Automatable, public SessionHandle return ((_auto_state & Write) || ((_auto_state & Touch) && touching())); } + std::string value_as_string (boost::shared_ptr) const; + void start_touch (double when); void stop_touch (bool mark, double when); bool touching() const { return g_atomic_int_get (&_touching); } diff --git a/libs/ardour/ardour/panner.h b/libs/ardour/ardour/panner.h index f43be2dbbc..c26d1a6a2c 100644 --- a/libs/ardour/ardour/panner.h +++ b/libs/ardour/ardour/panner.h @@ -93,6 +93,7 @@ class Panner : public PBD::Stateful, public PBD::ScopedConnectionList virtual std::set what_can_be_automated() const; virtual std::string describe_parameter (Evoral::Parameter); + virtual std::string value_as_string (boost::shared_ptr) const; bool touching() const; diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index 0d24135710..20dc910f61 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -492,3 +492,23 @@ Automatable::clear_controls () _control_connections.drop_connections (); ControlSet::clear_controls (); } + +string +Automatable::value_as_string (boost::shared_ptr ac) const +{ + std::stringstream s; + + /* this is a the default fallback for this virtual method. Derived Automatables + are free to override this to display the values of their parameters/controls + in different ways. + */ + + // Hack to display CC as integer value, rather than double + if (ac->parameter().type() == MidiCCAutomation) { + s << lrint (ac->get_value()); + } else { + s << std::fixed << std::setprecision(3) << ac->get_value(); + } + + return s.str (); +} diff --git a/libs/ardour/pannable.cc b/libs/ardour/pannable.cc index 4243ab45df..1e2d5f5594 100644 --- a/libs/ardour/pannable.cc +++ b/libs/ardour/pannable.cc @@ -23,9 +23,11 @@ #include "ardour/automation_control.h" #include "ardour/automation_list.h" #include "ardour/pannable.h" +#include "ardour/panner.h" #include "ardour/pan_controllable.h" #include "ardour/session.h" +using namespace std; using namespace PBD; using namespace ARDOUR; @@ -245,6 +247,12 @@ Pannable::set_state (const XMLNode& root, int /*version - not used*/) return 0; } +string +Pannable::value_as_string (boost::shared_ptr ac) const +{ + if (_panner) { + return _panner->value_as_string (ac); + } - - + return Automatable::value_as_string (ac); +} diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index bfee68a342..1cb5e310aa 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -161,3 +161,9 @@ Panner::describe_parameter (Evoral::Parameter p) { return _pannable->describe_parameter (p); } + +string +Panner::value_as_string (boost::shared_ptr ac) const +{ + return _pannable->value_as_string (ac); +} diff --git a/libs/gtkmm2ext/gtkmm2ext/barcontroller.h b/libs/gtkmm2ext/gtkmm2ext/barcontroller.h index e0e14f1c26..c65d8abe81 100644 --- a/libs/gtkmm2ext/gtkmm2ext/barcontroller.h +++ b/libs/gtkmm2ext/gtkmm2ext/barcontroller.h @@ -82,6 +82,8 @@ class BarController : public Gtk::Frame Gtk::SpinButton spinner; bool use_parent; bool logarithmic; + sigc::slot _label_slot; + bool _use_slot; virtual std::string get_label (int& /*x*/) { return ""; diff --git a/libs/panners/1in2out/panner_1in2out.cc b/libs/panners/1in2out/panner_1in2out.cc index 7a59aa04cc..cce2ec9b71 100644 --- a/libs/panners/1in2out/panner_1in2out.cc +++ b/libs/panners/1in2out/panner_1in2out.cc @@ -362,3 +362,27 @@ Panner1in2out::describe_parameter (Evoral::Parameter p) return _pannable->describe_parameter (p); } } + +string +Panner1in2out::value_as_string (boost::shared_ptr ac) const +{ + /* DO NOT USE LocaleGuard HERE */ + double val = ac->get_value(); + + switch (ac->parameter().type()) { + case PanAzimuthAutomation: + /* We show the position of the center of the image relative to the left & right. + This is expressed as a pair of percentage values that ranges from (100,0) + (hard left) through (50,50) (hard center) to (0,100) (hard right). + + This is pretty wierd, but its the way audio engineers expect it. Just remember that + the center of the USA isn't Kansas, its (50LA, 50NY) and it will all make sense. + */ + + return string_compose (_("L:%1 R:%2"), (int) rint (100.0 * (1.0 - val)), + (int) rint (100.0 * val)); + + default: + return _pannable->value_as_string (ac); + } +} diff --git a/libs/panners/1in2out/panner_1in2out.h b/libs/panners/1in2out/panner_1in2out.h index ced467c11b..ffc67ac54d 100644 --- a/libs/panners/1in2out/panner_1in2out.h +++ b/libs/panners/1in2out/panner_1in2out.h @@ -60,6 +60,7 @@ class Panner1in2out : public Panner static Panner* factory (boost::shared_ptr, Speakers&); std::string describe_parameter (Evoral::Parameter); + std::string value_as_string (boost::shared_ptr) const; XMLNode& state (bool full_state); XMLNode& get_state (void); diff --git a/libs/panners/2in2out/panner_2in2out.cc b/libs/panners/2in2out/panner_2in2out.cc index 2c2856361c..30d971d118 100644 --- a/libs/panners/2in2out/panner_2in2out.cc +++ b/libs/panners/2in2out/panner_2in2out.cc @@ -473,3 +473,30 @@ Panner2in2out::describe_parameter (Evoral::Parameter p) return _pannable->describe_parameter (p); } } + +string +Panner2in2out::value_as_string (boost::shared_ptr ac) const +{ + /* DO NOT USE LocaleGuard HERE */ + double val = ac->get_value(); + + switch (ac->parameter().type()) { + case PanAzimuthAutomation: + /* We show the position of the center of the image relative to the left & right. + This is expressed as a pair of percentage values that ranges from (100,0) + (hard left) through (50,50) (hard center) to (0,100) (hard right). + + This is pretty wierd, but its the way audio engineers expect it. Just remember that + the center of the USA isn't Kansas, its (50LA, 50NY) and it will all make sense. + */ + + return string_compose (_("L:%1 R:%2"), (int) rint (100.0 * (1.0 - val)), + (int) rint (100.0 * val)); + + case PanWidthAutomation: + return string_compose (_("Width: %1%%"), (int) floor (100.0 * val)); + + default: + return _pannable->value_as_string (ac); + } +} diff --git a/libs/panners/2in2out/panner_2in2out.h b/libs/panners/2in2out/panner_2in2out.h index 0bb38fa27f..2014bb032e 100644 --- a/libs/panners/2in2out/panner_2in2out.h +++ b/libs/panners/2in2out/panner_2in2out.h @@ -60,6 +60,7 @@ class Panner2in2out : public Panner static Panner* factory (boost::shared_ptr, Speakers&); std::string describe_parameter (Evoral::Parameter); + std::string value_as_string (boost::shared_ptr) const; XMLNode& state (bool full_state); XMLNode& get_state (void); diff --git a/libs/panners/vbap/vbap.cc b/libs/panners/vbap/vbap.cc index 6088a2d0d6..239a253f19 100644 --- a/libs/panners/vbap/vbap.cc +++ b/libs/panners/vbap/vbap.cc @@ -313,3 +313,21 @@ VBAPanner::describe_parameter (Evoral::Parameter p) return _pannable->describe_parameter (p); } } + +string +VBAPanner::value_as_string (boost::shared_ptr ac) const +{ + /* DO NOT USE LocaleGuard HERE */ + double val = ac->get_value(); + + switch (ac->parameter().type()) { + case PanAzimuthAutomation: /* direction */ + return string_compose (_("%1"), val * 360.0); + + case PanWidthAutomation: /* diffusion */ + return string_compose (_("%1%%"), (int) floor (100.0 * fabs(val))); + + default: + return _pannable->value_as_string (ac); + } +} diff --git a/libs/panners/vbap/vbap.h b/libs/panners/vbap/vbap.h index 2b80b032cb..cf010cc331 100644 --- a/libs/panners/vbap/vbap.h +++ b/libs/panners/vbap/vbap.h @@ -53,6 +53,7 @@ public: void set_azimuth_elevation (double azimuth, double elevation); std::string describe_parameter (Evoral::Parameter); + std::string value_as_string (boost::shared_ptr) const; XMLNode& state (bool full_state); XMLNode& get_state (); -- cgit v1.2.3