#include "pbd/error.h"
-#include "midi++/names.h"
-
#include "ardour/amp.h"
#include "ardour/automatable.h"
#include "ardour/event_type_map.h"
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<Evoral::Control> 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<AutomationControl>(li->second)->drop_references ();
+ }
+ }
+}
+
int
Automatable::old_set_automation_state (const XMLNode& node)
{
warning << _("Automation node has no path property") << endmsg;
}
- _last_automation_snapshot = 0;
-
return 0;
}
return 1;
}
- Glib::Mutex::Lock lm (control_lock());
+ Glib::Threads::Mutex::Lock lm (control_lock());
set<Evoral::Parameter> tosave;
controls().clear ();
- _last_automation_snapshot = 0;
-
while (in) {
double when;
double value;
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) {
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 */
}
}
- _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()) {
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<Evoral::Control> c = control (param, true);
- boost::shared_ptr<AutomationList> l = boost::dynamic_pointer_cast<AutomationList>(c->list());
+ boost::shared_ptr<AutomationControl> 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 ();
}
}
{
AutoState result = Off;
- boost::shared_ptr<Evoral::Control> c = control(param);
- boost::shared_ptr<AutomationList> l = boost::dynamic_pointer_cast<AutomationList>(c->list());
-
+ boost::shared_ptr<AutomationControl> c = automation_control(param);
+
if (c) {
- result = l->automation_state();
+ result = c->automation_state();
}
return result;
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<Evoral::Control> c = control(param, true);
- boost::shared_ptr<AutomationList> l = boost::dynamic_pointer_cast<AutomationList>(c->list());
+ boost::shared_ptr<AutomationControl> 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 ();
}
}
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<Evoral::Control> c = control(param);
boost::shared_ptr<AutomationList> l = boost::dynamic_pointer_cast<AutomationList>(c->list());
}
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<AutomationControl> c
- = boost::dynamic_pointer_cast<AutomationControl>(i->second);
- if (_a_session.transport_rolling() && c->automation_write()) {
- c->list()->rt_add (now, i->second->user_double());
+ boost::shared_ptr<AutomationControl> c
+ = boost::dynamic_pointer_cast<AutomationControl>(li->second);
+ if (c) {
+ boost::shared_ptr<AutomationList> l
+ = boost::dynamic_pointer_cast<AutomationList>(c->list());
+
+ if (l) {
+ l->start_write_pass (now);
}
}
-
- _last_automation_snapshot = now;
}
}