diff options
author | David Robillard <d@drobilla.net> | 2007-07-06 02:37:35 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-07-06 02:37:35 +0000 |
commit | b942d3613e9679a1ffc5ad5ff0a6491cac1fa853 (patch) | |
tree | c6df327c7e2a34425c54e16ae02032affceeaae0 | |
parent | 19273e824d40534a4e31259fb8b83122b24aa4e9 (diff) |
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
-rw-r--r-- | gtk2_ardour/automation_controller.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/automation_controller.h | 3 | ||||
-rw-r--r-- | gtk2_ardour/automation_time_axis.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/ladspa_pluginui.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/automatable.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/automation_control.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_track.h | 7 | ||||
-rw-r--r-- | libs/ardour/automatable.cc | 19 | ||||
-rw-r--r-- | libs/ardour/automation_control.cc | 1 | ||||
-rw-r--r-- | libs/ardour/midi_track.cc | 6 |
11 files changed, 34 insertions, 18 deletions
diff --git a/gtk2_ardour/automation_controller.cc b/gtk2_ardour/automation_controller.cc index 09d1f1e744..8483bab393 100644 --- a/gtk2_ardour/automation_controller.cc +++ b/gtk2_ardour/automation_controller.cc @@ -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)); } diff --git a/gtk2_ardour/automation_controller.h b/gtk2_ardour/automation_controller.h index 0f98e5f083..8a244113c4 100644 --- a/gtk2_ardour/automation_controller.h +++ b/gtk2_ardour/automation_controller.h @@ -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); diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 28d8ba326f..5c5cd53dec 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -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")), diff --git a/gtk2_ardour/ladspa_pluginui.cc b/gtk2_ardour/ladspa_pluginui.cc index ffab3c18f9..7abee4fe23 100644 --- a/gtk2_ardour/ladspa_pluginui.cc +++ b/gtk2_ardour/ladspa_pluginui.cc @@ -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); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 7f43d3b638..a843659cbc 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -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); } diff --git a/libs/ardour/ardour/automatable.h b/libs/ardour/ardour/automatable.h index 6100f60b80..a48029734a 100644 --- a/libs/ardour/ardour/automatable.h +++ b/libs/ardour/ardour/automatable.h @@ -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; } diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h index cc0aee5326..68ac5797dc 100644 --- a/libs/ardour/ardour/automation_control.h +++ b/libs/ardour/ardour/automation_control.h @@ -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); diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index a6e28405f8..aea032f725 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -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); diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index 5b30877edc..885034056d 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -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)); + } +} diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc index bbeec65669..73d5819bc4 100644 --- a/libs/ardour/automation_control.cc +++ b/libs/ardour/automation_control.cc @@ -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; diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index aa23e3d92b..6e52bb19c0 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -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); |