3.0 version of rev 5564 from 2.x - basic boolean plugin parameter automation (no...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 23 Aug 2010 16:31:34 +0000 (16:31 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 23 Aug 2010 16:31:34 +0000 (16:31 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7670 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_line.cc
gtk2_ardour/automation_line.h
gtk2_ardour/generic_pluginui.cc
libs/ardour/automation_control.cc
libs/ardour/event_type_map.cc
libs/ardour/plugin_insert.cc
libs/evoral/evoral/Parameter.hpp

index 052691cb605a2371d9797d7d346a2f84ddd1c761..1b20d4c2871657e4d0e73b56e10076c0fe0db3b2 100644 (file)
@@ -72,6 +72,7 @@ AutomationLine::AutomationLine (const string& name, TimeAxisView& tv, ArdourCanv
        _uses_gain_mapping = false;
        no_draw = false;
        _visible = true;
+        _is_boolean = false;
        terminal_points_can_slide = true;
        _height = 0;
 
@@ -1129,6 +1130,11 @@ AutomationLine::set_list (boost::shared_ptr<ARDOUR::AutomationList> list)
 void
 AutomationLine::show_all_control_points ()
 {
+        if (_is_boolean) {
+                // show the line but don't allow any control points
+                return;
+        }
+
        points_visible = true;
 
        for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
index 3e23729e678f1094fa4b129c15996927e2ba6fbf..ec6034ccf2e7b9fa902bc8c8a9a4ca723a2cd6c5 100644 (file)
@@ -156,6 +156,7 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible
        bool    terminal_points_can_slide : 1;
        bool    update_pending            : 1;
        bool    no_draw                   : 1;
+       bool    _is_boolean               : 1;
        bool    points_visible            : 1;
        bool    did_push;
 
index bef4227e274f2b00ed5dbdd1b53a2b5a668d9b54..30a12aeb0e64923114f5db0034151f0dde92c052 100644 (file)
@@ -465,47 +465,51 @@ GenericPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automat
 
                        control_ui->pack_start (control_ui->label, true, true);
                        control_ui->pack_start (*control_ui->button, false, true);
-                       // control_ui->pack_start (control_ui->automate_button, false, false);
+                       control_ui->pack_start (control_ui->automate_button, false, false);
 
                        control_ui->button->signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::control_port_toggled), control_ui));
-                       mcontrol->Changed.connect (control_connections, invalidator (*this), boost::bind (&GenericPluginUI::toggle_parameter_changed, this, control_ui), gui_context());
+                       control_ui->automate_button.signal_clicked().connect (bind (mem_fun(*this, &GenericPluginUI::astate_clicked), control_ui, (uint32_t) port_index));
 
+                       mcontrol->Changed.connect (control_connections, invalidator (*this), boost::bind (&GenericPluginUI::toggle_parameter_changed, this, control_ui), gui_context());
+                        mcontrol->alist()->automation_state_changed.connect (control_connections, invalidator (*this), boost::bind (&GenericPluginUI::automation_state_changed, this, control_ui), gui_context());
+       
                        if (plugin->get_parameter (port_index) > 0.5){
                                control_ui->button->set_active(true);
                        }
 
+                        automation_state_changed (control_ui);
+
                        return control_ui;
                }
 
                /* create the controller */
 
                control_ui->controller = AutomationController::create(insert, mcontrol->parameter(), mcontrol);
+
                /* XXX this code is not right yet, because it doesn't handle
                   the absence of bounds in any sensible fashion.
                */
 
-//#if 0
-               control_ui->controller->adjustment()->set_lower (desc.lower);
-               control_ui->controller->adjustment()->set_upper (desc.upper);
+                Adjustment* adj = control_ui->controller->adjustment();
+
+               adj->set_lower (desc.lower);
+               adj->set_upper (desc.upper);
 
-               control_ui->logarithmic = false; // just disable it for now
-               /*
                control_ui->logarithmic = desc.logarithmic;
+
                if (control_ui->logarithmic) {
-                       if (control_ui->controller->adjustment()->get_lower() == 0.0) {
-                               control_ui->controller->adjustment()->set_lower (control_ui->controller->adjustment()->get_upper()/10000);
+                       if (adj->get_lower() == 0.0) {
+                               adj->set_lower (adj->get_upper()/10000);
                        }
-                       control_ui->controller->adjustment()->set_upper (log(control_ui->controller->adjustment()->get_upper()));
-                       control_ui->controller->adjustment()->set_lower (log(control_ui->controller->adjustment()->get_lower()));
-               }*/
-
+                       adj->set_upper (log(adj->get_upper()));
+                       adj->set_lower (log(adj->get_lower()));
+               }
 
-               control_ui->controller->adjustment()->set_step_increment (desc.step);
-               control_ui->controller->adjustment()->set_page_increment (desc.largestep);
-//#endif
+               adj->set_step_increment (desc.step);
+               adj->set_page_increment (desc.largestep);
 
                if (desc.integer_step) {
-                       control_ui->clickbox = new ClickBox (control_ui->controller->adjustment(), "PluginUIClickBox");
+                       control_ui->clickbox = new ClickBox (adj, "PluginUIClickBox");
                        Gtkmm2ext::set_size_request_to_display_given_text (*control_ui->clickbox, "g9999999", 2, 2);
                        control_ui->clickbox->set_print_func (integer_printer, 0);
                } else {
@@ -523,9 +527,9 @@ GenericPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automat
                }
 
                if (control_ui->logarithmic) {
-                       control_ui->controller->adjustment()->set_value(log(plugin->get_parameter(port_index)));
+                       adj->set_value(log(plugin->get_parameter(port_index)));
                } else{
-                       control_ui->controller->adjustment()->set_value(plugin->get_parameter(port_index));
+                       adj->set_value(plugin->get_parameter(port_index));
                }
 
                /* XXX memory leak: SliderController not destroyed by ControlUI
index a4e0a7bbc088e700b08a5365f535eeb3d6606095..2989d82818ecc23bb8dde1eda6dc1bdc0a7e11ff 100644 (file)
@@ -52,8 +52,16 @@ AutomationControl::set_value(double value)
 {
        bool to_list = _list && _session.transport_stopped()
                && ((AutomationList*)_list.get())->automation_write();
+        if (to_list && parameter().toggled()) {
 
-       Control::set_double(value, to_list, _session.transport_frame());
+                //store the previous value just before this so any 
+                // interpolation works right
+                
+                _list->add (get_double(), _session.transport_frame()-1);
+        }
+
+       Control::set_double (value, to_list, _session.transport_frame());
 
        Changed(); /* EMIT SIGNAL */
 }
index a2db60f4ba110292676cfe9d98fe4d630f9c8587..d88e5afd265a8c1693140dfbbd838e187207e92e 100644 (file)
@@ -168,7 +168,7 @@ EventTypeMap::new_parameter(uint32_t type, uint8_t channel, uint32_t id) const
                return p;
        }
 
-       p.set_range(type, min, max, normal);
+       p.set_range(type, min, max, normal, false);
        return p;
 }
 
index d6dfc014cfc713ead82575ad1c6b12db0c41c3ce..a0deec6807e5f7541d70375949c2c569352f3984 100644 (file)
@@ -195,7 +195,7 @@ PluginInsert::set_automatable ()
                           but we want the Controllable related to this Parameter to have those limits.
                        */
 
-                       param.set_range (desc.lower, desc.upper, _plugins.front()->default_value(i->id()));
+                       param.set_range (desc.lower, desc.upper, _plugins.front()->default_value(i->id()), desc.toggled);
                        can_automate (param);
                        boost::shared_ptr<AutomationList> list(new AutomationList(param));
                        add_control (boost::shared_ptr<AutomationControl>(new PluginControl(this, param, list)));
@@ -402,8 +402,9 @@ PluginInsert::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end
 void
 PluginInsert::set_parameter (Evoral::Parameter param, float val)
 {
-       if (param.type() != PluginAutomation)
+       if (param.type() != PluginAutomation) {
                return;
+        }
 
        /* the others will be set from the event triggered by this */
 
index 95ee5daa8e344242b32c773c53fe1207f6d87c90..f5dd3e95e4dbc4c4a4b3083b0e7497fdfd0da880 100644 (file)
@@ -79,22 +79,23 @@ public:
 
        /** Not used in indentity/comparison */
        struct Metadata {
-               Metadata(double low=0.0, double high=1.0, double mid=0.0)
-                       : min(low), max(high), normal(mid)
+                Metadata(double low=0.0, double high=1.0, double mid=0.0, bool tog=false)
+                        : min(low), max(high), normal(mid), toggled(tog)
                {}
                double min;
                double max;
                double normal;
+                bool   toggled;
        };
 
-       inline static void set_range(uint32_t type, double min, double max, double normal) {
-               _type_metadata[type] = Metadata(min, max, normal);
+        inline static void set_range(uint32_t type, double min, double max, double normal, bool toggled) {
+               _type_metadata[type] = Metadata(min, max, normal, toggled);
        }
 
-       inline void set_range(double min, double max, double normal) {
-               _metadata = boost::shared_ptr<Metadata>(new Metadata(min, max, normal));
+        inline void set_range(double min, double max, double normal, bool toggled) {
+                _metadata = boost::shared_ptr<Metadata>(new Metadata(min, max, normal, toggled));
        }
-
+    
        inline Metadata& metadata() const {
                if (_metadata)
                        return *_metadata.get();
@@ -102,9 +103,10 @@ public:
                        return _type_metadata[_type];
        }
 
-       inline double min()    const { return metadata().min; }
-       inline double max()    const { return metadata().max; }
-       inline double normal() const { return metadata().normal; }
+       inline double min()     const { return metadata().min; }
+       inline double max()     const { return metadata().max; }
+       inline double normal()  const { return metadata().normal; }
+       inline double toggled() const { return metadata().toggled; }
 
 protected:
        // Default copy constructor is ok