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,22 +773,27 @@ GenericMidiControlProtocol::reset_controllables ()
|
||||||
|
|
||||||
/* its entirely possible that the session doesn't have
|
/* its entirely possible that the session doesn't have
|
||||||
* the specified controllable (e.g. it has too few
|
* the specified controllable (e.g. it has too few
|
||||||
* tracks). if we find this to be the case, drop any
|
* tracks). if we find this to be the case, we just leave
|
||||||
* bindings that would be left without controllables.
|
* 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);
|
boost::shared_ptr<Controllable> c = session->controllable_by_descriptor (desc);
|
||||||
if (c) {
|
if (c) {
|
||||||
existingBinding->set_controllable (c.get());
|
existingBinding->set_controllable (c.get());
|
||||||
} else {
|
}
|
||||||
controllables.erase (iter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iter = next;
|
iter = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<Controllable>
|
||||||
|
GenericMidiControlProtocol::lookup_controllable (const ControllableDescriptor& desc) const
|
||||||
|
{
|
||||||
|
return session->controllable_by_descriptor (desc);
|
||||||
|
}
|
||||||
|
|
||||||
MIDIFunction*
|
MIDIFunction*
|
||||||
GenericMidiControlProtocol::create_function (const XMLNode& node)
|
GenericMidiControlProtocol::create_function (const XMLNode& node)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace MIDI {
|
||||||
|
|
||||||
namespace PBD {
|
namespace PBD {
|
||||||
class Controllable;
|
class Controllable;
|
||||||
|
class ControllableDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ARDOUR {
|
namespace ARDOUR {
|
||||||
|
@ -57,6 +58,8 @@ class GenericMidiControlProtocol : public ARDOUR::ControlProtocol {
|
||||||
int set_feedback (bool yn);
|
int set_feedback (bool yn);
|
||||||
bool get_feedback () const;
|
bool get_feedback () const;
|
||||||
|
|
||||||
|
boost::shared_ptr<PBD::Controllable> lookup_controllable (const PBD::ControllableDescriptor&) const;
|
||||||
|
|
||||||
XMLNode& get_state ();
|
XMLNode& get_state ();
|
||||||
int set_state (const XMLNode&, int version);
|
int set_state (const XMLNode&, int version);
|
||||||
|
|
||||||
|
|
|
@ -184,11 +184,31 @@ MIDIControllable::midi_sense_note_off (Parser &p, EventTwoBytes *tb)
|
||||||
midi_sense_note (p, tb, false);
|
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
|
void
|
||||||
MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool /*is_on*/)
|
MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool /*is_on*/)
|
||||||
{
|
{
|
||||||
if (!controllable) {
|
if (!controllable) {
|
||||||
return;
|
if (lookup_controllable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!controllable->is_toggle()) {
|
if (!controllable->is_toggle()) {
|
||||||
|
@ -206,7 +226,9 @@ void
|
||||||
MIDIControllable::midi_sense_controller (Parser &, EventTwoBytes *msg)
|
MIDIControllable::midi_sense_controller (Parser &, EventTwoBytes *msg)
|
||||||
{
|
{
|
||||||
if (!controllable) {
|
if (!controllable) {
|
||||||
return;
|
if (lookup_controllable ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controllable->touching()) {
|
if (controllable->touching()) {
|
||||||
|
@ -254,7 +276,9 @@ void
|
||||||
MIDIControllable::midi_sense_program_change (Parser &, byte msg)
|
MIDIControllable::midi_sense_program_change (Parser &, byte msg)
|
||||||
{
|
{
|
||||||
if (!controllable) {
|
if (!controllable) {
|
||||||
return;
|
if (lookup_controllable ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!controllable->is_toggle()) {
|
if (!controllable->is_toggle()) {
|
||||||
|
@ -270,7 +294,9 @@ void
|
||||||
MIDIControllable::midi_sense_pitchbend (Parser &, pitchbend_t pb)
|
MIDIControllable::midi_sense_pitchbend (Parser &, pitchbend_t pb)
|
||||||
{
|
{
|
||||||
if (!controllable) {
|
if (!controllable) {
|
||||||
return;
|
if (lookup_controllable ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!controllable->is_toggle()) {
|
if (!controllable->is_toggle()) {
|
||||||
|
@ -299,7 +325,9 @@ MIDIControllable::midi_receiver (Parser &, byte *msg, size_t /*len*/)
|
||||||
|
|
||||||
bind_midi ((channel_t) (msg[0] & 0xf), eventType (msg[0] & 0xF0), msg[1]);
|
bind_midi ((channel_t) (msg[0] & 0xf), eventType (msg[0] & 0xF0), msg[1]);
|
||||||
|
|
||||||
controllable->LearningFinished ();
|
if (controllable) {
|
||||||
|
controllable->LearningFinished ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -116,6 +116,8 @@ class MIDIControllable : public PBD::Stateful
|
||||||
uint32_t _rid;
|
uint32_t _rid;
|
||||||
std::string _what;
|
std::string _what;
|
||||||
bool _bank_relative;
|
bool _bank_relative;
|
||||||
|
|
||||||
|
int lookup_controllable();
|
||||||
|
|
||||||
void midi_receiver (MIDI::Parser &p, MIDI::byte *, size_t);
|
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 (MIDI::Parser &, MIDI::EventTwoBytes *, bool is_on);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user