#include <pbd/enumwriter.h>
#include <ardour/session.h>
#include <ardour/automatable.h>
+#include <ardour/midi_track.h>
#include "i18n.h"
using namespace ARDOUR;
using namespace PBD;
-
Automatable::Automatable(Session& _session, const string& name)
: SessionObject(_session, name)
, _last_automation_snapshot(0)
} else if (create_if_missing) {
boost::shared_ptr<AutomationList> al (new AutomationList (
parameter, FLT_MIN, FLT_MAX, default_parameter_value (parameter)));
- boost::shared_ptr<AutomationControl> ac (new AutomationControl(_session, al));
+ boost::shared_ptr<AutomationControl> ac(control_factory(al));
add_control(ac);
- cerr << "WARNING: Default AutomationControl created for " << parameter.to_string() << endl;
return ac;
} else {
if (!id_prop) {
warning << "AutomationList node without automation-id property, "
<< "using default: " << legacy_param.to_string() << endmsg;
- al->set_param_id(legacy_param);
+ al->set_parameter(legacy_param);
}
boost::shared_ptr<AutomationControl> existing = control(param);
if (existing)
existing->set_list(al);
else
- add_control(boost::shared_ptr<AutomationControl>(new AutomationControl(_session, al)));
+ add_control(control_factory(al));
} else {
error << "Expected AutomationList node, got '" << (*niter)->name() << endmsg;
}
}
+/* FIXME: this probably doesn't belong here */
+boost::shared_ptr<AutomationControl>
+Automatable::control_factory(boost::shared_ptr<AutomationList> list)
+{
+ if (list->parameter().type() == MidiCCAutomation) {
+ // FIXME: this will die horribly if this is not a MidiTrack
+ return boost::shared_ptr<AutomationControl>(new MidiTrack::MidiControl((MidiTrack*)this, list));
+ } else {
+ cerr << "WARNING: Default AutomationControl created for " << list->parameter().to_string() << endl;
+ return boost::shared_ptr<AutomationControl>(new AutomationControl(_session, list));
+ }
+}
+