mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 23:35:03 +01:00
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:
parent
19273e824d
commit
b942d3613e
11 changed files with 34 additions and 18 deletions
|
|
@ -61,12 +61,12 @@ AutomationController::~AutomationController()
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<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()));
|
Gtk::Adjustment* adjustment = manage(new Gtk::Adjustment(al->default_value(), al->get_min_y(), al->get_max_y()));
|
||||||
if (!ac) {
|
if (!ac) {
|
||||||
PBD::warning << "Creating AutomationController for " << al->parameter().to_string() << endmsg;
|
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));
|
return boost::shared_ptr<AutomationController>(new AutomationController(ac, adjustment));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,14 @@ namespace ARDOUR {
|
||||||
class Session;
|
class Session;
|
||||||
class AutomationList;
|
class AutomationList;
|
||||||
class AutomationControl;
|
class AutomationControl;
|
||||||
|
class Automatable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class AutomationController : public Gtkmm2ext::BarController {
|
class AutomationController : public Gtkmm2ext::BarController {
|
||||||
public:
|
public:
|
||||||
static boost::shared_ptr<AutomationController> create(
|
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::AutomationList> al,
|
||||||
boost::shared_ptr<ARDOUR::AutomationControl> ac);
|
boost::shared_ptr<ARDOUR::AutomationControl> ac);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Ro
|
||||||
_route (r),
|
_route (r),
|
||||||
_control (c),
|
_control (c),
|
||||||
_automatable (a),
|
_automatable (a),
|
||||||
_controller(AutomationController::create(s, c->list(), c)),
|
_controller(AutomationController::create(a, c->list(), c)),
|
||||||
_base_rect (0),
|
_base_rect (0),
|
||||||
_name (nom),
|
_name (nom),
|
||||||
height_button (_("h")),
|
height_button (_("h")),
|
||||||
|
|
|
||||||
|
|
@ -456,7 +456,7 @@ LadspaPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automati
|
||||||
} else {
|
} else {
|
||||||
//sigc::slot<void,char*,uint32_t> pslot = sigc::bind (mem_fun(*this, &LadspaPluginUI::print_parameter), (uint32_t) port_index);
|
//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_size_request (200, req.height);
|
||||||
control_ui->controller->set_name (X_("PluginSlider"));
|
control_ui->controller->set_name (X_("PluginSlider"));
|
||||||
control_ui->controller->set_style (BarController::LeftToRight);
|
control_ui->controller->set_style (BarController::LeftToRight);
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ MidiTimeAxisView::create_automation_child (Parameter param, bool show)
|
||||||
|
|
||||||
if (!c) {
|
if (!c) {
|
||||||
boost::shared_ptr<AutomationList> al(new ARDOUR::AutomationList(param, 0, 127, 64));
|
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);
|
_route->add_control(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ public:
|
||||||
virtual boost::shared_ptr<AutomationControl> control(Parameter id, bool create_if_missing=false);
|
virtual boost::shared_ptr<AutomationControl> control(Parameter id, bool create_if_missing=false);
|
||||||
virtual boost::shared_ptr<const AutomationControl> control(Parameter id) const;
|
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;
|
typedef std::map<Parameter,boost::shared_ptr<AutomationControl> > Controls;
|
||||||
Controls controls() { return _controls; }
|
Controls controls() { return _controls; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ namespace ARDOUR {
|
||||||
|
|
||||||
class AutomationList;
|
class AutomationList;
|
||||||
class Session;
|
class Session;
|
||||||
|
class Automatable;
|
||||||
|
|
||||||
|
|
||||||
/** A PBD:Controllable with associated automation data (AutomationList)
|
/** A PBD:Controllable with associated automation data (AutomationList)
|
||||||
|
|
@ -36,7 +37,8 @@ class Session;
|
||||||
class AutomationControl : public PBD::Controllable
|
class AutomationControl : public PBD::Controllable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AutomationControl(ARDOUR::Session&, boost::shared_ptr<ARDOUR::AutomationList>,
|
AutomationControl(ARDOUR::Session&,
|
||||||
|
boost::shared_ptr<ARDOUR::AutomationList>,
|
||||||
std::string name="unnamed controllable");
|
std::string name="unnamed controllable");
|
||||||
|
|
||||||
void set_value(float val);
|
void set_value(float val);
|
||||||
|
|
|
||||||
|
|
@ -75,17 +75,18 @@ public:
|
||||||
bool write_immediate_event(size_t size, const Byte* buf);
|
bool write_immediate_event(size_t size, const Byte* buf);
|
||||||
|
|
||||||
struct MidiControl : public AutomationControl {
|
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())
|
: AutomationControl (route->session(), al, al->parameter().to_string())
|
||||||
, _route (route)
|
, _route (route)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void set_value (float val);
|
void set_value (float val);
|
||||||
|
|
||||||
boost::weak_ptr<MidiTrack> _route;
|
MidiTrack* _route;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
XMLNode& state (bool full);
|
XMLNode& state (bool full);
|
||||||
|
|
||||||
int _set_state (const XMLNode&, bool call_base);
|
int _set_state (const XMLNode&, bool call_base);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <pbd/enumwriter.h>
|
#include <pbd/enumwriter.h>
|
||||||
#include <ardour/session.h>
|
#include <ardour/session.h>
|
||||||
#include <ardour/automatable.h>
|
#include <ardour/automatable.h>
|
||||||
|
#include <ardour/midi_track.h>
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
|
@ -33,7 +34,6 @@ using namespace std;
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
|
|
||||||
|
|
||||||
Automatable::Automatable(Session& _session, const string& name)
|
Automatable::Automatable(Session& _session, const string& name)
|
||||||
: SessionObject(_session, name)
|
: SessionObject(_session, name)
|
||||||
, _last_automation_snapshot(0)
|
, _last_automation_snapshot(0)
|
||||||
|
|
@ -169,9 +169,8 @@ Automatable::control (Parameter parameter, bool create_if_missing)
|
||||||
} else if (create_if_missing) {
|
} else if (create_if_missing) {
|
||||||
boost::shared_ptr<AutomationList> al (new AutomationList (
|
boost::shared_ptr<AutomationList> al (new AutomationList (
|
||||||
parameter, FLT_MIN, FLT_MAX, default_parameter_value (parameter)));
|
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);
|
add_control(ac);
|
||||||
cerr << "WARNING: Default AutomationControl created for " << parameter.to_string() << endl;
|
|
||||||
return ac;
|
return ac;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -301,7 +300,7 @@ Automatable::set_automation_state (const XMLNode& node, Parameter legacy_param)
|
||||||
if (existing)
|
if (existing)
|
||||||
existing->set_list(al);
|
existing->set_list(al);
|
||||||
else
|
else
|
||||||
add_control(boost::shared_ptr<AutomationControl>(new AutomationControl(_session, al)));
|
add_control(control_factory(al));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
error << "Expected AutomationList node, got '" << (*niter)->name() << endmsg;
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include <ardour/automation_control.h>
|
#include <ardour/automation_control.h>
|
||||||
#include <ardour/session.h>
|
#include <ardour/session.h>
|
||||||
#include <ardour/automatable.h>
|
#include <ardour/automatable.h>
|
||||||
|
#include <ardour/midi_track.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
|
|
||||||
|
|
@ -716,11 +716,9 @@ MidiTrack::MidiControl::set_value(float val)
|
||||||
assert(val >= 0);
|
assert(val >= 0);
|
||||||
assert(val <= 127.0);
|
assert(val <= 127.0);
|
||||||
|
|
||||||
boost::shared_ptr<MidiTrack> midi_track = _route.lock();
|
if ( ! _list->automation_playback()) {
|
||||||
|
|
||||||
if (midi_track && !_list->automation_playback()) {
|
|
||||||
Byte ev[3] = { MIDI_CMD_CONTROL, _list->parameter().id(), (int)val };
|
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);
|
AutomationControl::set_value(val);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue