+float
+MIDIControllable::control_to_midi(float val)
+{
+ float control_min = 0.0f;
+ float control_max = 1.0f;
+ ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(&controllable);
+ if (ac) {
+ control_min = ac->parameter().min();
+ control_max = ac->parameter().max();
+ }
+
+ const float control_range = control_max - control_min;
+ const float midi_range = 127.0f; // TODO: NRPN etc.
+
+ return (val - control_min) / control_range * midi_range;
+}
+
+float
+MIDIControllable::midi_to_control(float val)
+{
+ float control_min = 0.0f;
+ float control_max = 1.0f;
+ ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(&controllable);
+ if (ac) {
+ control_min = ac->parameter().min();
+ control_max = ac->parameter().max();
+ }
+
+ const float control_range = control_max - control_min;
+ const float midi_range = 127.0f; // TODO: NRPN etc.
+
+ return val / midi_range * control_range + control_min;
+}
+
+void
+MIDIControllable::midi_sense_note_on (Parser &p, EventTwoBytes *tb)