add late/lazy binding between generic MIDI bindings and controllable elements in the session. this allows you to load a binding map that refers to elements that have not yet been created in the session, and when they are created, the binding will work
git-svn-id: svn://localhost/ardour2/branches/3.0@12921 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
ed51eb8801
commit
92469df6ab
@ -773,15 +773,14 @@ GenericMidiControlProtocol::reset_controllables ()
|
||||
|
||||
/* its entirely possible that the session doesn't have
|
||||
* the specified controllable (e.g. it has too few
|
||||
* tracks). if we find this to be the case, drop any
|
||||
* bindings that would be left without controllables.
|
||||
* tracks). if we find this to be the case, we just leave
|
||||
* the binding around, unbound, and it will do "late
|
||||
* binding" (or "lazy binding") if/when any data arrives.
|
||||
*/
|
||||
|
||||
boost::shared_ptr<Controllable> c = session->controllable_by_descriptor (desc);
|
||||
if (c) {
|
||||
existingBinding->set_controllable (c.get());
|
||||
} else {
|
||||
controllables.erase (iter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -789,6 +788,12 @@ GenericMidiControlProtocol::reset_controllables ()
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<Controllable>
|
||||
GenericMidiControlProtocol::lookup_controllable (const ControllableDescriptor& desc) const
|
||||
{
|
||||
return session->controllable_by_descriptor (desc);
|
||||
}
|
||||
|
||||
MIDIFunction*
|
||||
GenericMidiControlProtocol::create_function (const XMLNode& node)
|
||||
{
|
||||
|
@ -32,6 +32,7 @@ namespace MIDI {
|
||||
|
||||
namespace PBD {
|
||||
class Controllable;
|
||||
class ControllableDescriptor;
|
||||
}
|
||||
|
||||
namespace ARDOUR {
|
||||
@ -57,6 +58,8 @@ class GenericMidiControlProtocol : public ARDOUR::ControlProtocol {
|
||||
int set_feedback (bool yn);
|
||||
bool get_feedback () const;
|
||||
|
||||
boost::shared_ptr<PBD::Controllable> lookup_controllable (const PBD::ControllableDescriptor&) const;
|
||||
|
||||
XMLNode& get_state ();
|
||||
int set_state (const XMLNode&, int version);
|
||||
|
||||
|
@ -184,12 +184,32 @@ MIDIControllable::midi_sense_note_off (Parser &p, EventTwoBytes *tb)
|
||||
midi_sense_note (p, tb, false);
|
||||
}
|
||||
|
||||
int
|
||||
MIDIControllable::lookup_controllable()
|
||||
{
|
||||
if (!_descriptor) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
boost::shared_ptr<Controllable> c = _surface->lookup_controllable (*_descriptor);
|
||||
|
||||
if (!c) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
controllable = c.get();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool /*is_on*/)
|
||||
{
|
||||
if (!controllable) {
|
||||
if (lookup_controllable()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!controllable->is_toggle()) {
|
||||
controllable->set_value (midi_to_control (msg->note_number));
|
||||
@ -206,8 +226,10 @@ void
|
||||
MIDIControllable::midi_sense_controller (Parser &, EventTwoBytes *msg)
|
||||
{
|
||||
if (!controllable) {
|
||||
if (lookup_controllable ()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (controllable->touching()) {
|
||||
return; // to prevent feedback fights when e.g. dragging a UI slider
|
||||
@ -254,8 +276,10 @@ void
|
||||
MIDIControllable::midi_sense_program_change (Parser &, byte msg)
|
||||
{
|
||||
if (!controllable) {
|
||||
if (lookup_controllable ()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!controllable->is_toggle()) {
|
||||
controllable->set_value (midi_to_control (msg));
|
||||
@ -270,8 +294,10 @@ void
|
||||
MIDIControllable::midi_sense_pitchbend (Parser &, pitchbend_t pb)
|
||||
{
|
||||
if (!controllable) {
|
||||
if (lookup_controllable ()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!controllable->is_toggle()) {
|
||||
controllable->set_value (midi_to_control (pb));
|
||||
@ -299,8 +325,10 @@ MIDIControllable::midi_receiver (Parser &, byte *msg, size_t /*len*/)
|
||||
|
||||
bind_midi ((channel_t) (msg[0] & 0xf), eventType (msg[0] & 0xF0), msg[1]);
|
||||
|
||||
if (controllable) {
|
||||
controllable->LearningFinished ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MIDIControllable::bind_midi (channel_t chn, eventType ev, MIDI::byte additional)
|
||||
|
@ -117,6 +117,8 @@ class MIDIControllable : public PBD::Stateful
|
||||
std::string _what;
|
||||
bool _bank_relative;
|
||||
|
||||
int lookup_controllable();
|
||||
|
||||
void midi_receiver (MIDI::Parser &p, MIDI::byte *, size_t);
|
||||
void midi_sense_note (MIDI::Parser &, MIDI::EventTwoBytes *, bool is_on);
|
||||
void midi_sense_note_on (MIDI::Parser &p, MIDI::EventTwoBytes *tb);
|
||||
|
Loading…
Reference in New Issue
Block a user