}
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));
}
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);
_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")),
} 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);
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);
}
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; }
class AutomationList;
class Session;
+class Automatable;
/** A PBD:Controllable with associated automation data (AutomationList)
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);
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);
#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 (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));
+ }
+}
#include <ardour/automation_control.h>
#include <ardour/session.h>
#include <ardour/automatable.h>
+#include <ardour/midi_track.h>
using namespace std;
using namespace ARDOUR;
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);