- 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 {
- return boost::shared_ptr<AutomationControl>(new AutomationControl(_session, list));
+ boost::shared_ptr<AutomationList> list(new AutomationList(param));
+ Evoral::Control* control = NULL;
+ if (param.type() >= MidiCCAutomation && param.type() <= MidiChannelPressureAutomation) {
+ MidiTrack* mt = dynamic_cast<MidiTrack*>(this);
+ if (mt) {
+ control = new MidiTrack::MidiControl(mt, param);
+ } else {
+ warning << "MidiCCAutomation for non-MidiTrack" << endl;
+ }
+ } else if (param.type() == PluginAutomation) {
+ PluginInsert* pi = dynamic_cast<PluginInsert*>(this);
+ if (pi) {
+ control = new PluginInsert::PluginControl(pi, param);
+ } else {
+ warning << "PluginAutomation for non-Plugin" << endl;
+ }
+ } else if (param.type() == GainAutomation) {
+ Amp* amp = dynamic_cast<Amp*>(this);
+ if (amp) {
+ control = new Amp::GainControl(X_("gaincontrol"), _a_session, amp, param);
+ } else {
+ warning << "GainAutomation for non-Amp" << endl;
+ }
+ } else if (param.type() == PanAutomation) {
+ Panner* me = dynamic_cast<Panner*>(this);
+ if (me) {
+ control = new Panner::PanControllable(me->session(), X_("panner"), *me, param);
+ } else {
+ warning << "PanAutomation for non-Panner" << endl;
+ }
+ }
+
+ if (!control) {
+ control = new AutomationControl(_a_session, param);