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

@ -61,12 +61,12 @@ AutomationController::~AutomationController()
}
boost::shared_ptr<AutomationController>
AutomationController::create(Session& s, boost::shared_ptr<AutomationList> al, boost::shared_ptr<AutomationControl> ac)
AutomationController::create(boost::shared_ptr<Automatable> parent, boost::shared_ptr<AutomationList> al, boost::shared_ptr<AutomationControl> ac)
{
Gtk::Adjustment* adjustment = manage(new Gtk::Adjustment(al->default_value(), al->get_min_y(), al->get_max_y()));
if (!ac) {
PBD::warning << "Creating AutomationController for " << al->parameter().to_string() << endmsg;
ac = boost::shared_ptr<AutomationControl>(new AutomationControl(s, al));
ac = parent->control_factory(al);
}
return boost::shared_ptr<AutomationController>(new AutomationController(ac, adjustment));
}

View File

@ -29,13 +29,14 @@ namespace ARDOUR {
class Session;
class AutomationList;
class AutomationControl;
class Automatable;
}
class AutomationController : public Gtkmm2ext::BarController {
public:
static boost::shared_ptr<AutomationController> create(
ARDOUR::Session& s,
boost::shared_ptr<ARDOUR::Automatable> parent,
boost::shared_ptr<ARDOUR::AutomationList> al,
boost::shared_ptr<ARDOUR::AutomationControl> ac);

View File

@ -59,7 +59,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Ro
_route (r),
_control (c),
_automatable (a),
_controller(AutomationController::create(s, c->list(), c)),
_controller(AutomationController::create(a, c->list(), c)),
_base_rect (0),
_name (nom),
height_button (_("h")),

View File

@ -456,7 +456,7 @@ LadspaPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automati
} else {
//sigc::slot<void,char*,uint32_t> pslot = sigc::bind (mem_fun(*this, &LadspaPluginUI::print_parameter), (uint32_t) port_index);
control_ui->controller = AutomationController::create(insert->session(), mcontrol->list(), mcontrol);
control_ui->controller = AutomationController::create(insert, mcontrol->list(), mcontrol);
control_ui->controller->set_size_request (200, req.height);
control_ui->controller->set_name (X_("PluginSlider"));
control_ui->controller->set_style (BarController::LeftToRight);

View File

@ -199,7 +199,7 @@ MidiTimeAxisView::create_automation_child (Parameter param, bool show)
if (!c) {
boost::shared_ptr<AutomationList> al(new ARDOUR::AutomationList(param, 0, 127, 64));
c = boost::shared_ptr<AutomationControl>(new MidiTrack::MidiControl(midi_track(), al));
c = boost::shared_ptr<AutomationControl>(_route->control_factory(al));
_route->add_control(c);
}

View File

@ -49,6 +49,8 @@ public:
virtual boost::shared_ptr<AutomationControl> control(Parameter id, bool create_if_missing=false);
virtual boost::shared_ptr<const AutomationControl> control(Parameter id) const;
boost::shared_ptr<AutomationControl> control_factory(boost::shared_ptr<AutomationList> list);
typedef std::map<Parameter,boost::shared_ptr<AutomationControl> > Controls;
Controls controls() { return _controls; }

View File

@ -29,6 +29,7 @@ namespace ARDOUR {
class AutomationList;
class Session;
class Automatable;
/** A PBD:Controllable with associated automation data (AutomationList)
@ -36,7 +37,8 @@ class Session;
class AutomationControl : public PBD::Controllable
{
public:
AutomationControl(ARDOUR::Session&, boost::shared_ptr<ARDOUR::AutomationList>,
AutomationControl(ARDOUR::Session&,
boost::shared_ptr<ARDOUR::AutomationList>,
std::string name="unnamed controllable");
void set_value(float val);

View File

@ -75,17 +75,18 @@ public:
bool write_immediate_event(size_t size, const Byte* buf);
struct MidiControl : public AutomationControl {
MidiControl(boost::shared_ptr<MidiTrack> route, boost::shared_ptr<AutomationList> al)
MidiControl(MidiTrack* route, boost::shared_ptr<AutomationList> al)
: AutomationControl (route->session(), al, al->parameter().to_string())
, _route (route)
{}
void set_value (float val);
boost::weak_ptr<MidiTrack> _route;
MidiTrack* _route;
};
protected:
XMLNode& state (bool full);
int _set_state (const XMLNode&, bool call_base);

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));
}
}

View File

@ -22,6 +22,7 @@
#include <ardour/automation_control.h>
#include <ardour/session.h>
#include <ardour/automatable.h>
#include <ardour/midi_track.h>
using namespace std;
using namespace ARDOUR;

View File

@ -716,11 +716,9 @@ MidiTrack::MidiControl::set_value(float val)
assert(val >= 0);
assert(val <= 127.0);
boost::shared_ptr<MidiTrack> midi_track = _route.lock();
if (midi_track && !_list->automation_playback()) {
if ( ! _list->automation_playback()) {
Byte ev[3] = { MIDI_CMD_CONTROL, _list->parameter().id(), (int)val };
midi_track->write_immediate_event(3, ev);
_route->write_immediate_event(3, ev);
}
AutomationControl::set_value(val);