#include "midicontrollable.h"
using namespace sigc;
+using namespace std;
using namespace MIDI;
using namespace PBD;
using namespace ARDOUR;
MIDIControllable::MIDIControllable (Port& p, const string& c, bool is_bistate)
- : controllable (0), _port (p), bistate (is_bistate)
+ : controllable (0), _current_uri (c), _port (p), bistate (is_bistate)
{
init ();
}
void
MIDIControllable::reacquire_controllable ()
{
- _controllable = Controllable::controllable_by_uri (current_uri);
+ if (!_current_uri.empty()) {
+ controllable = Controllable::by_uri (_current_uri);
+ } else {
+ controllable = 0;
+ }
}
void
{
float control_min = 0.0f;
float control_max = 1.0f;
- ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(&controllable);
+ ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(controllable);
if (ac) {
control_min = ac->parameter().min();
control_max = ac->parameter().max();
{
float control_min = 0.0f;
float control_max = 1.0f;
- ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(&controllable);
+ ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(controllable);
if (ac) {
control_min = ac->parameter().min();
control_max = ac->parameter().max();
*/
if (msg->note_number == control_additional) {
- controllable.set_value (is_on ? 1 : 0);
+ controllable->set_value (is_on ? 1 : 0);
}
}
XMLNode&
MIDIControllable::get_state ()
{
- if (!controllable) {
- return XXX !what!;
- }
-
char buf[32];
- XMLNode& node (controllable->get_state ());
- snprintf (buf, sizeof(buf), "0x%x", (int) control_type);
- node.add_property ("event", buf);
- snprintf (buf, sizeof(buf), "%d", (int) control_channel);
- node.add_property ("channel", buf);
- snprintf (buf, sizeof(buf), "0x%x", (int) control_additional);
- node.add_property ("additional", buf);
- node.add_property ("feedback", (feedback ? "yes" : "no"));
+ XMLNode* node = new XMLNode ("MIDIControllable");
+
+ if (controllable) {
+ node->add_property ("uri", controllable->uri());
+ snprintf (buf, sizeof(buf), "0x%x", (int) control_type);
+ node->add_property ("event", buf);
+ snprintf (buf, sizeof(buf), "%d", (int) control_channel);
+ node->add_property ("channel", buf);
+ snprintf (buf, sizeof(buf), "0x%x", (int) control_additional);
+ node->add_property ("additional", buf);
+ node->add_property ("feedback", (feedback ? "yes" : "no"));
+ }
- return node;
+ return *node;
}