when calculating average slave/master delta, use absolute value.
[ardour.git] / libs / ardour / plugin_insert.cc
index 6dbfcc6a2b36b9706e969a4524ea6fdbefc8d86f..ce05d6c298fc536b5da25eb9d86ab9c0f198c0b5 100644 (file)
@@ -492,7 +492,11 @@ PluginInsert::create_automatable_parameters ()
                        if (Variant::type_is_numeric(desc.datatype)) {
                                list = boost::shared_ptr<AutomationList>(new AutomationList(param, desc));
                        }
-                       add_control (boost::shared_ptr<AutomationControl> (new PluginPropertyControl(this, param, desc, list)));
+                       boost::shared_ptr<AutomationControl> c (new PluginPropertyControl(this, param, desc, list));
+                       if (!Variant::type_is_numeric(desc.datatype)) {
+                               c->set_flags (Controllable::Flag ((int)c->flags() | Controllable::NotAutomatable));
+                       }
+                       add_control (c);
                }
        }
 
@@ -701,6 +705,18 @@ PluginInsert::bypassable_changed ()
        BypassableChanged ();
 }
 
+bool
+PluginInsert::write_immediate_event (size_t size, const uint8_t* buf)
+{
+       bool rv = true;
+       for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
+               if (!(*i)->write_immediate_event (size, buf)) {
+                       rv = false;
+               }
+       }
+       return rv;
+}
+
 void
 PluginInsert::preset_load_set_value (uint32_t p, float v)
 {
@@ -1128,7 +1144,10 @@ PluginInsert::bypass (BufferSet& bufs, pframes_t nframes)
 void
 PluginInsert::silence (framecnt_t nframes, framepos_t start_frame)
 {
+       automation_run (start_frame, nframes); // evaluate automation only
+
        if (!active ()) {
+               // XXX delaybuffers need to be offset by nframes
                return;
        }
 
@@ -1162,14 +1181,17 @@ PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
                /* run as normal if we are active or moving from inactive to active */
 
                if (_session.transport_rolling() || _session.bounce_processing()) {
-                       automation_run (bufs, start_frame, end_frame, speed, nframes);
+                       automate_and_run (bufs, start_frame, end_frame, speed, nframes);
                } else {
                        Glib::Threads::Mutex::Lock lm (control_lock(), Glib::Threads::TRY_LOCK);
                        connect_and_run (bufs, start_frame, end_frame, speed, nframes, 0, lm.locked());
                }
 
        } else {
+               // XXX should call ::silence() to run plugin(s) for consistent load.
+               // We'll need to change this anyway when bypass can be automated
                bypass (bufs, nframes);
+               automation_run (start_frame, nframes); // evaluate automation only
                _delaybuffers.flush ();
        }
 
@@ -1181,7 +1203,7 @@ PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
 }
 
 void
-PluginInsert::automation_run (BufferSet& bufs, framepos_t start, framepos_t end, double speed, pframes_t nframes)
+PluginInsert::automate_and_run (BufferSet& bufs, framepos_t start, framepos_t end, double speed, pframes_t nframes)
 {
        Evoral::ControlEvent next_event (0, 0.0f);
        framecnt_t offset = 0;
@@ -3072,7 +3094,7 @@ PluginInsert::end_touch (uint32_t param_id)
        boost::shared_ptr<AutomationControl> ac = automation_control (Evoral::Parameter (PluginAutomation, 0, param_id));
        if (ac) {
                // ToDo subtract _plugin_signal_latency  from audible_frame() when rolling, assert > 0
-               ac->stop_touch (true, session().audible_frame());
+               ac->stop_touch (session().audible_frame());
        }
 }