summaryrefslogtreecommitdiff
path: root/libs/ardour/automatable.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2018-12-16 04:01:42 +0100
committerRobin Gareus <robin@gareus.org>2018-12-16 04:25:20 +0100
commite4d3ebfb666e2c4e9cf134d8f3ed42152da343bf (patch)
treed0855bac03500a9dfca33b38949faf8da3ed5002 /libs/ardour/automatable.cc
parent17a8a50e5816b48469907fa4aa00b50103f0f02d (diff)
Optimize plugin-processing for non-automated params
Keep a dedicated list of automated parameters to evaluate in realtime. This fixes a performance issue with plugins that have many controls with only few of them being automated.
Diffstat (limited to 'libs/ardour/automatable.cc')
-rw-r--r--libs/ardour/automatable.cc54
1 files changed, 50 insertions, 4 deletions
diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc
index fd7c0a9b01..51a58ce942 100644
--- a/libs/ardour/automatable.cc
+++ b/libs/ardour/automatable.cc
@@ -55,13 +55,15 @@ const string Automatable::xml_node_name = X_("Automation");
Automatable::Automatable(Session& session)
: _a_session(session)
+ , _automated_controls (new ControlList)
{
}
Automatable::Automatable (const Automatable& other)
- : ControlSet (other)
- , Slavable ()
- , _a_session (other._a_session)
+ : ControlSet (other)
+ , Slavable ()
+ , _a_session (other._a_session)
+ , _automated_controls (new ControlList)
{
Glib::Threads::Mutex::Lock lm (other._control_lock);
@@ -73,6 +75,13 @@ Automatable::Automatable (const Automatable& other)
Automatable::~Automatable ()
{
+ {
+ RCUWriter<ControlList> writer (_automated_controls);
+ boost::shared_ptr<ControlList> cl = writer.get_copy ();
+ cl->clear ();
+ }
+ _automated_controls.flush ();
+
Glib::Threads::Mutex::Lock lm (_control_lock);
for (Controls::const_iterator li = _controls.begin(); li != _controls.end(); ++li) {
boost::dynamic_pointer_cast<AutomationControl>(li->second)->drop_references ();
@@ -439,8 +448,16 @@ Automatable::non_realtime_transport_stop (samplepos_t now, bool /*flush_processo
}
void
-Automatable::automation_run (samplepos_t start, pframes_t nframes)
+Automatable::automation_run (samplepos_t start, pframes_t nframes, bool only_active)
{
+ if (only_active) {
+ boost::shared_ptr<ControlList> cl = _automated_controls.reader ();
+ for (ControlList::const_iterator ci = cl->begin(); ci != cl->end(); ++ci) {
+ (*ci)->automation_run (start, nframes);
+ }
+ return;
+ }
+
for (Controls::iterator li = controls().begin(); li != controls().end(); ++li) {
boost::shared_ptr<AutomationControl> c =
boost::dynamic_pointer_cast<AutomationControl>(li->second);
@@ -451,6 +468,35 @@ Automatable::automation_run (samplepos_t start, pframes_t nframes)
}
}
+void
+Automatable::automation_list_automation_state_changed (Evoral::Parameter param, AutoState as)
+{
+ {
+ boost::shared_ptr<AutomationControl> c (automation_control(param));
+ assert (c && c->list());
+
+ RCUWriter<ControlList> writer (_automated_controls);
+ boost::shared_ptr<ControlList> cl = writer.get_copy ();
+
+ ControlList::const_iterator fi = std::find (cl->begin(), cl->end(), c);
+ if (fi != cl->end()) {
+ cl->erase (fi);
+ }
+ switch (as) {
+ /* all potential automation_playback() states */
+ case Play:
+ case Touch:
+ case Latch:
+ cl->push_back (c);
+ break;
+ case Off:
+ case Write:
+ break;
+ }
+ }
+ _automated_controls.flush();
+}
+
boost::shared_ptr<Evoral::Control>
Automatable::control_factory(const Evoral::Parameter& param)
{