X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fautomatable.cc;h=84f8cd56cca540948a29b93998d29a72e5d3fb29;hb=79db9422ac70605cb3b706c3a19cf1c4e00af2f1;hp=d0a605bcd9edbf80be131854d23ed37240a64eed;hpb=6fa6514cfdb0ce38d93b51197f599dfd091bad1d;p=ardour.git diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index d0a605bcd9..84f8cd56cc 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -25,8 +25,6 @@ #include "pbd/error.h" -#include "midi++/names.h" - #include "ardour/amp.h" #include "ardour/automatable.h" #include "ardour/event_type_map.h" @@ -42,27 +40,36 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -framecnt_t Automatable::_automation_interval = 0; const string Automatable::xml_node_name = X_("Automation"); Automatable::Automatable(Session& session) : _a_session(session) - , _last_automation_snapshot(0) { } Automatable::Automatable (const Automatable& other) : ControlSet (other) , _a_session (other._a_session) - , _last_automation_snapshot (0) { - Glib::Mutex::Lock lm (other._control_lock); + Glib::Threads::Mutex::Lock lm (other._control_lock); for (Controls::const_iterator i = other._controls.begin(); i != other._controls.end(); ++i) { boost::shared_ptr ac (control_factory (i->first)); add_control (ac); } } + +Automatable::~Automatable () +{ + { + Glib::Threads::Mutex::Lock lm (_control_lock); + + for (Controls::const_iterator li = _controls.begin(); li != _controls.end(); ++li) { + boost::dynamic_pointer_cast(li->second)->drop_references (); + } + } +} + int Automatable::old_set_automation_state (const XMLNode& node) { @@ -74,8 +81,6 @@ Automatable::old_set_automation_state (const XMLNode& node) warning << _("Automation node has no path property") << endmsg; } - _last_automation_snapshot = 0; - return 0; } @@ -98,12 +103,10 @@ Automatable::load_automation (const string& path) return 1; } - Glib::Mutex::Lock lm (control_lock()); + Glib::Threads::Mutex::Lock lm (control_lock()); set tosave; controls().clear (); - _last_automation_snapshot = 0; - while (in) { double when; double value; @@ -154,8 +157,7 @@ Automatable::describe_parameter (Evoral::Parameter param) if (param == Evoral::Parameter(GainAutomation)) { return _("Fader"); } else if (param.type() == MidiCCAutomation) { - return string_compose("%1: %2 [%3]", - param.id(), midi_name(param.id()), int(param.channel()) + 1); + return string_compose("Controller %1 [%2]", param.id(), int(param.channel()) + 1); } else if (param.type() == MidiPgmChangeAutomation) { return string_compose("Program [%1]", int(param.channel()) + 1); } else if (param.type() == MidiPitchBenderAutomation) { @@ -180,7 +182,7 @@ Automatable::can_automate (Evoral::Parameter what) int Automatable::set_automation_xml_state (const XMLNode& node, Evoral::Parameter legacy_param) { - Glib::Mutex::Lock lm (control_lock()); + Glib::Threads::Mutex::Lock lm (control_lock()); /* Don't clear controls, since some may be special derived Controllable classes */ @@ -228,15 +230,13 @@ Automatable::set_automation_xml_state (const XMLNode& node, Evoral::Parameter le } } - _last_automation_snapshot = 0; - return 0; } XMLNode& Automatable::get_automation_xml_state () { - Glib::Mutex::Lock lm (control_lock()); + Glib::Threads::Mutex::Lock lm (control_lock()); XMLNode* node = new XMLNode (Automatable::xml_node_name); if (controls().empty()) { @@ -256,13 +256,12 @@ Automatable::get_automation_xml_state () void Automatable::set_parameter_automation_state (Evoral::Parameter param, AutoState s) { - Glib::Mutex::Lock lm (control_lock()); + Glib::Threads::Mutex::Lock lm (control_lock()); - boost::shared_ptr c = control (param, true); - boost::shared_ptr l = boost::dynamic_pointer_cast(c->list()); + boost::shared_ptr c = automation_control (param, true); - if (s != l->automation_state()) { - l->set_automation_state (s); + if (c && (s != c->automation_state())) { + c->set_automation_state (s); _a_session.set_dirty (); } } @@ -272,11 +271,10 @@ Automatable::get_parameter_automation_state (Evoral::Parameter param) { AutoState result = Off; - boost::shared_ptr c = control(param); - boost::shared_ptr l = boost::dynamic_pointer_cast(c->list()); - + boost::shared_ptr c = automation_control(param); + if (c) { - result = l->automation_state(); + result = c->automation_state(); } return result; @@ -285,13 +283,12 @@ Automatable::get_parameter_automation_state (Evoral::Parameter param) void Automatable::set_parameter_automation_style (Evoral::Parameter param, AutoStyle s) { - Glib::Mutex::Lock lm (control_lock()); + Glib::Threads::Mutex::Lock lm (control_lock()); - boost::shared_ptr c = control(param, true); - boost::shared_ptr l = boost::dynamic_pointer_cast(c->list()); + boost::shared_ptr c = automation_control(param, true); - if (s != l->automation_style()) { - l->set_automation_style (s); + if (c && (s != c->automation_style())) { + c->set_automation_style (s); _a_session.set_dirty (); } } @@ -299,7 +296,7 @@ Automatable::set_parameter_automation_style (Evoral::Parameter param, AutoStyle AutoStyle Automatable::get_parameter_automation_style (Evoral::Parameter param) { - Glib::Mutex::Lock lm (control_lock()); + Glib::Threads::Mutex::Lock lm (control_lock()); boost::shared_ptr c = control(param); boost::shared_ptr l = boost::dynamic_pointer_cast(c->list()); @@ -336,19 +333,20 @@ Automatable::protect_automation () } void -Automatable::automation_snapshot (framepos_t now, bool force) +Automatable::transport_located (framepos_t now) { - if (force || _last_automation_snapshot > now || (now - _last_automation_snapshot) > _automation_interval) { + for (Controls::iterator li = controls().begin(); li != controls().end(); ++li) { - for (Controls::iterator i = controls().begin(); i != controls().end(); ++i) { - boost::shared_ptr c - = boost::dynamic_pointer_cast(i->second); - if (_a_session.transport_rolling() && c->automation_write()) { - c->list()->rt_add (now, i->second->user_double()); + boost::shared_ptr c + = boost::dynamic_pointer_cast(li->second); + if (c) { + boost::shared_ptr l + = boost::dynamic_pointer_cast(c->list()); + + if (l) { + l->start_write_pass (now); } } - - _last_automation_snapshot = now; } }