Fix 'live' CC sending of bar controllers after loading session (previously only worked when immediately created by user).

git-svn-id: svn://localhost/ardour2/trunk@2116 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2007-07-06 02:37:35 +00:00
parent 19273e824d
commit b942d3613e
11 changed files with 34 additions and 18 deletions

View file

@ -26,6 +26,7 @@
#include <pbd/enumwriter.h>
#include <ardour/session.h>
#include <ardour/automatable.h>
#include <ardour/midi_track.h>
#include "i18n.h"
@ -33,7 +34,6 @@ using namespace std;
using namespace ARDOUR;
using namespace PBD;
Automatable::Automatable(Session& _session, const string& name)
: SessionObject(_session, name)
, _last_automation_snapshot(0)
@ -169,9 +169,8 @@ Automatable::control (Parameter parameter, bool create_if_missing)
} 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 {
@ -301,7 +300,7 @@ Automatable::set_automation_state (const XMLNode& node, Parameter legacy_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;
@ -452,3 +451,15 @@ Automatable::transport_stopped (nframes_t now)
}
}
/* 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));
}
}