only subdivide plugin-cycle when automation is playing
authorRobin Gareus <robin@gareus.org>
Wed, 7 Oct 2015 08:42:28 +0000 (10:42 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 7 Oct 2015 12:21:29 +0000 (14:21 +0200)
PluginInsert::automation_run() subdivides plugin-run on every
control-port automation event (without splitting the process cycle).

libevoral has no automation-control context, hence this function
must be implemented by Automatable.

libs/ardour/ardour/automatable.h
libs/ardour/automatable.cc
libs/evoral/evoral/ControlSet.hpp
libs/evoral/src/ControlSet.cpp
libs/evoral/test/SequenceTest.hpp

index ddf9eee8bb38bfc1b7d9112362daeccba2b4e67a..c9e14cfae5170f00ad660d3a1240987bc106c99c 100644 (file)
@@ -57,6 +57,7 @@ public:
        automation_control (const Evoral::Parameter& id) const;
 
        virtual void add_control(boost::shared_ptr<Evoral::Control>);
+       virtual bool find_next_event(double start, double end, Evoral::ControlEvent& ev, bool only_active = true) const;
        void clear_controls ();
 
         virtual void transport_located (framepos_t now);
index e0c21a6f6f110a69fc93380803dfcd230bfa2ed2..0b316890bc354eedd8163de49fac0dc0a788f071 100644 (file)
@@ -501,3 +501,42 @@ Automatable::value_as_string (boost::shared_ptr<AutomationControl> ac) const
 {
        return ARDOUR::value_as_string(ac->desc(), ac->get_value());
 }
+
+bool
+Automatable::find_next_event (double now, double end, Evoral::ControlEvent& next_event, bool only_active) const
+{
+       Controls::const_iterator li;
+
+       next_event.when = std::numeric_limits<double>::max();
+
+       for (li = _controls.begin(); li != _controls.end(); ++li) {
+               boost::shared_ptr<AutomationControl> c
+                       = boost::dynamic_pointer_cast<AutomationControl>(li->second);
+
+               if (only_active && (!c || !c->automation_playback())) {
+                       continue;
+               }
+
+               Evoral::ControlList::const_iterator i;
+               boost::shared_ptr<const Evoral::ControlList> alist (li->second->list());
+               Evoral::ControlEvent cp (now, 0.0f);
+               if (!alist) {
+                       continue;
+               }
+
+               for (i = lower_bound (alist->begin(), alist->end(), &cp, Evoral::ControlList::time_comparator);
+                    i != alist->end() && (*i)->when < end; ++i) {
+                       if ((*i)->when > now) {
+                               break;
+                       }
+               }
+
+               if (i != alist->end() && (*i)->when < end) {
+                       if ((*i)->when < next_event.when) {
+                               next_event.when = (*i)->when;
+                       }
+               }
+       }
+
+       return next_event.when != std::numeric_limits<double>::max();
+}
index b7d50d7d2ef3d05dc97cb82628aaf98e718c3df2..f1c2d96f49e4156742016bce3d024cf80aeb409c 100644 (file)
@@ -60,7 +60,7 @@ public:
 
        virtual void add_control(boost::shared_ptr<Control>);
 
-       bool find_next_event(double start, double end, ControlEvent& ev) const;
+       virtual bool find_next_event(double start, double end, ControlEvent& ev, bool only_active = true) const = 0;
 
        virtual bool controls_empty() const { return _controls.size() == 0; }
        virtual void clear_controls();
index f24c410d730038dad1f9fe4b3aa56529ca6d9a8f..cc8d7c60a77dacb4c12f4e2489cfaa1f84833119 100644 (file)
@@ -87,38 +87,6 @@ ControlSet::control (const Parameter& parameter, bool create_if_missing)
        }
 }
 
-bool
-ControlSet::find_next_event (double now, double end, ControlEvent& next_event) const
-{
-       Controls::const_iterator li;
-
-       next_event.when = std::numeric_limits<double>::max();
-
-       for (li = _controls.begin(); li != _controls.end(); ++li) {
-               ControlList::const_iterator i;
-               boost::shared_ptr<const ControlList> alist (li->second->list());
-               ControlEvent cp (now, 0.0f);
-               if (!alist) {
-                       continue;
-               }
-
-               for (i = lower_bound (alist->begin(), alist->end(), &cp, ControlList::time_comparator);
-                    i != alist->end() && (*i)->when < end; ++i) {
-                       if ((*i)->when > now) {
-                               break;
-                       }
-               }
-
-               if (i != alist->end() && (*i)->when < end) {
-                       if ((*i)->when < next_event.when) {
-                               next_event.when = (*i)->when;
-                       }
-               }
-       }
-
-       return next_event.when != std::numeric_limits<double>::max();
-}
-
 void
 ControlSet::clear_controls ()
 {
index da1991efc8e2c95c4d289886b1e67df096db4458..3207541571309d583fd0cad2125778fa9440eaee 100644 (file)
@@ -51,6 +51,8 @@ class MySequence : public Sequence<Time> {
 public:
        MySequence(DummyTypeMap&map) : Sequence<Time>(map) {}
 
+       virtual bool find_next_event(double start, double end, ControlEvent& ev, bool only_active) const { return false; }
+
        boost::shared_ptr<Control> control_factory(const Parameter& param) {
                const Evoral::ParameterDescriptor desc;
                boost::shared_ptr<ControlList>    list(new ControlList(param, desc));