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
|
/* 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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*
|
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,12 +184,32 @@ 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) {
|
||||||
|
if (lookup_controllable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!controllable->is_toggle()) {
|
if (!controllable->is_toggle()) {
|
||||||
controllable->set_value (midi_to_control (msg->note_number));
|
controllable->set_value (midi_to_control (msg->note_number));
|
||||||
@ -206,8 +226,10 @@ void
|
|||||||
MIDIControllable::midi_sense_controller (Parser &, EventTwoBytes *msg)
|
MIDIControllable::midi_sense_controller (Parser &, EventTwoBytes *msg)
|
||||||
{
|
{
|
||||||
if (!controllable) {
|
if (!controllable) {
|
||||||
|
if (lookup_controllable ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (controllable->touching()) {
|
if (controllable->touching()) {
|
||||||
return; // to prevent feedback fights when e.g. dragging a UI slider
|
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)
|
MIDIControllable::midi_sense_program_change (Parser &, byte msg)
|
||||||
{
|
{
|
||||||
if (!controllable) {
|
if (!controllable) {
|
||||||
|
if (lookup_controllable ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!controllable->is_toggle()) {
|
if (!controllable->is_toggle()) {
|
||||||
controllable->set_value (midi_to_control (msg));
|
controllable->set_value (midi_to_control (msg));
|
||||||
@ -270,8 +294,10 @@ void
|
|||||||
MIDIControllable::midi_sense_pitchbend (Parser &, pitchbend_t pb)
|
MIDIControllable::midi_sense_pitchbend (Parser &, pitchbend_t pb)
|
||||||
{
|
{
|
||||||
if (!controllable) {
|
if (!controllable) {
|
||||||
|
if (lookup_controllable ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!controllable->is_toggle()) {
|
if (!controllable->is_toggle()) {
|
||||||
controllable->set_value (midi_to_control (pb));
|
controllable->set_value (midi_to_control (pb));
|
||||||
@ -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]);
|
||||||
|
|
||||||
|
if (controllable) {
|
||||||
controllable->LearningFinished ();
|
controllable->LearningFinished ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -117,6 +117,8 @@ class MIDIControllable : public PBD::Stateful
|
|||||||
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);
|
||||||
void midi_sense_note_on (MIDI::Parser &p, MIDI::EventTwoBytes *tb);
|
void midi_sense_note_on (MIDI::Parser &p, MIDI::EventTwoBytes *tb);
|
||||||
|
Loading…
Reference in New Issue
Block a user