2 Copyright (C) 2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <glibmm/fileutils.h>
26 #include <glibmm/miscutils.h>
28 #include "pbd/controllable_descriptor.h"
29 #include "pbd/error.h"
30 #include "pbd/failed_constructor.h"
31 #include "pbd/file_utils.h"
32 #include "pbd/xml++.h"
33 #include "pbd/compose.h"
35 #include "midi++/port.h"
37 #include "ardour/audioengine.h"
38 #include "ardour/filesystem_paths.h"
39 #include "ardour/session.h"
40 #include "ardour/route.h"
41 #include "ardour/midi_ui.h"
42 #include "ardour/rc_configuration.h"
43 #include "ardour/midiport_manager.h"
44 #include "ardour/debug.h"
46 #include "generic_midi_control_protocol.h"
47 #include "midicontrollable.h"
48 #include "midifunction.h"
49 #include "midiaction.h"
51 using namespace ARDOUR;
57 #define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
59 GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
60 : ControlProtocol (s, _("Generic MIDI"))
65 _input_port = s.midi_input_port ();
66 _output_port = s.midi_output_port ();
69 _feedback_interval = 10000; // microseconds
70 last_feedback_time = 0;
75 /* these signals are emitted by the MidiControlUI's event loop thread
76 * and we may as well handle them right there in the same the same
80 Controllable::StartLearning.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::start_learning, this, _1));
81 Controllable::StopLearning.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::stop_learning, this, _1));
82 Controllable::CreateBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::create_binding, this, _1, _2, _3));
83 Controllable::DeleteBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::delete_binding, this, _1));
85 /* this signal is emitted by the process() callback, and if
86 * send_feedback() is going to do anything, it should do it in the
87 * context of the process() callback itself.
90 Session::SendFeedback.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::send_feedback, this));
91 //Session::SendFeedback.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::send_feedback, this), midi_ui_context());;
93 /* this one is cross-thread */
95 Route::RemoteControlIDChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::reset_controllables, this), midi_ui_context());
100 GenericMidiControlProtocol::~GenericMidiControlProtocol ()
106 static const char * const midimap_env_variable_name = "ARDOUR_MIDIMAPS_PATH";
107 static const char* const midi_map_dir_name = "midi_maps";
108 static const char* const midi_map_suffix = ".map";
111 system_midi_map_search_path ()
113 bool midimap_path_defined = false;
114 std::string spath_env (Glib::getenv (midimap_env_variable_name, midimap_path_defined));
116 if (midimap_path_defined) {
120 Searchpath spath (ardour_data_search_path());
121 spath.add_subdirectory_to_paths(midi_map_dir_name);
126 user_midi_map_directory ()
128 return Glib::build_filename (user_config_directory(), midi_map_dir_name);
132 midi_map_filter (const string &str, void* /*arg*/)
134 return (str.length() > strlen(midi_map_suffix) &&
135 str.find (midi_map_suffix) == (str.length() - strlen (midi_map_suffix)));
139 GenericMidiControlProtocol::reload_maps ()
141 vector<string> midi_maps;
142 Searchpath spath (system_midi_map_search_path());
143 spath += user_midi_map_directory ();
145 find_files_matching_filter (midi_maps, spath, midi_map_filter, 0, false, true);
147 if (midi_maps.empty()) {
148 cerr << "No MIDI maps found using " << spath.to_string() << endl;
152 for (vector<string>::iterator i = midi_maps.begin(); i != midi_maps.end(); ++i) {
153 string fullpath = *i;
157 if (!tree.read (fullpath.c_str())) {
163 XMLProperty* prop = tree.root()->property ("name");
169 mi.name = prop->value ();
172 map_info.push_back (mi);
177 GenericMidiControlProtocol::drop_all ()
179 DEBUG_TRACE (DEBUG::GenericMidi, "Drop all bindings\n");
180 Glib::Threads::Mutex::Lock lm (pending_lock);
181 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
183 for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
186 controllables.clear ();
188 for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) {
191 pending_controllables.clear ();
193 for (MIDIFunctions::iterator i = functions.begin(); i != functions.end(); ++i) {
198 for (MIDIActions::iterator i = actions.begin(); i != actions.end(); ++i) {
205 GenericMidiControlProtocol::drop_bindings ()
207 DEBUG_TRACE (DEBUG::GenericMidi, "Drop bindings, leave learned\n");
208 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
210 for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ) {
211 if (!(*i)->learned()) {
213 i = controllables.erase (i);
219 for (MIDIFunctions::iterator i = functions.begin(); i != functions.end(); ++i) {
224 _current_binding = "";
230 GenericMidiControlProtocol::set_active (bool /*yn*/)
232 /* start/stop delivery/outbound thread */
237 GenericMidiControlProtocol::set_feedback_interval (microseconds_t ms)
239 _feedback_interval = ms;
243 GenericMidiControlProtocol::send_feedback ()
245 /* This is executed in RT "process" context", so no blocking calls
252 microseconds_t now = get_microseconds ();
254 if (last_feedback_time != 0) {
255 if ((now - last_feedback_time) < _feedback_interval) {
262 last_feedback_time = now;
266 GenericMidiControlProtocol::_send_feedback ()
268 /* This is executed in RT "process" context", so no blocking calls
271 const int32_t bufsize = 16 * 1024; /* XXX too big */
272 MIDI::byte buf[bufsize];
273 int32_t bsize = bufsize;
275 /* XXX: due to bugs in some ALSA / JACK MIDI bridges, we have to do separate
276 writes for each controllable here; if we send more than one MIDI message
277 in a single jack_midi_event_write then some bridges will only pass the
281 Glib::Threads::Mutex::Lock lm (controllables_lock, Glib::Threads::TRY_LOCK);
286 for (MIDIControllables::iterator r = controllables.begin(); r != controllables.end(); ++r) {
287 MIDI::byte* end = (*r)->write_feedback (buf, bsize);
289 _output_port->write (buf, (int32_t) (end - buf), 0);
295 GenericMidiControlProtocol::start_learning (Controllable* c)
301 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
302 DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Learn binding: Controlable number: %1\n", c));
304 MIDIControllables::iterator tmp;
305 for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ) {
308 if ((*i)->get_controllable() == c) {
310 controllables.erase (i);
316 Glib::Threads::Mutex::Lock lm (pending_lock);
318 MIDIPendingControllables::iterator ptmp;
319 for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ) {
322 if (((*i)->first)->get_controllable() == c) {
323 (*i)->second.disconnect();
326 pending_controllables.erase (i);
332 MIDIControllable* mc = 0;
334 for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
335 if ((*i)->get_controllable() && ((*i)->get_controllable()->id() == c->id())) {
342 mc = new MIDIControllable (this, *_input_port->parser(), *c, false);
346 Glib::Threads::Mutex::Lock lm (pending_lock);
348 MIDIPendingControllable* element = new MIDIPendingControllable;
350 c->LearningFinished.connect_same_thread (element->second, boost::bind (&GenericMidiControlProtocol::learning_stopped, this, mc));
352 pending_controllables.push_back (element);
354 mc->learn_about_external_control ();
359 GenericMidiControlProtocol::learning_stopped (MIDIControllable* mc)
361 Glib::Threads::Mutex::Lock lm (pending_lock);
362 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
364 MIDIPendingControllables::iterator tmp;
366 for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ) {
370 if ( (*i)->first == mc) {
371 (*i)->second.disconnect();
373 pending_controllables.erase(i);
379 controllables.push_back (mc);
383 GenericMidiControlProtocol::stop_learning (Controllable* c)
385 Glib::Threads::Mutex::Lock lm (pending_lock);
386 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
387 MIDIControllable* dptr = 0;
389 /* learning timed out, and we've been told to consider this attempt to learn to be cancelled. find the
390 relevant MIDIControllable and remove it from the pending list.
393 for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) {
394 if (((*i)->first)->get_controllable() == c) {
395 (*i)->first->stop_learning ();
397 (*i)->second.disconnect();
400 pending_controllables.erase (i);
409 GenericMidiControlProtocol::delete_binding (PBD::Controllable* control)
412 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
414 for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end();) {
415 MIDIControllable* existingBinding = (*iter);
417 if (control == (existingBinding->get_controllable())) {
418 delete existingBinding;
419 iter = controllables.erase (iter);
428 // This next function seems unused
430 GenericMidiControlProtocol::create_binding (PBD::Controllable* control, int pos, int control_number)
432 if (control != NULL) {
433 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
435 MIDI::channel_t channel = (pos & 0xf);
436 MIDI::byte value = control_number;
438 // Create a MIDIControllable
439 MIDIControllable* mc = new MIDIControllable (this, *_input_port->parser(), *control, false);
441 // Remove any old binding for this midi channel/type/value pair
442 // Note: can't use delete_binding() here because we don't know the specific controllable we want to remove, only the midi information
443 for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end();) {
444 MIDIControllable* existingBinding = (*iter);
446 if ((existingBinding->get_control_channel() & 0xf ) == channel &&
447 existingBinding->get_control_additional() == value &&
448 (existingBinding->get_control_type() & 0xf0 ) == MIDI::controller) {
450 delete existingBinding;
451 iter = controllables.erase (iter);
458 // Update the MIDI Controllable based on the the pos param
459 // Here is where a table lookup for user mappings could go; for now we'll just wing it...
460 mc->bind_midi(channel, MIDI::controller, value);
461 DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Create binding: Channel: %1 Controller: %2 Value: %3 \n", channel, MIDI::controller, value));
462 controllables.push_back (mc);
467 GenericMidiControlProtocol::check_used_event (int pos, int control_number)
469 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
471 MIDI::channel_t channel = (pos & 0xf);
472 MIDI::byte value = control_number;
474 DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("checking for used event: Channel: %1 Controller: %2 value: %3\n", (int) channel, (pos & 0xf0), (int) value));
476 // Remove any old binding for this midi channel/type/value pair
477 // Note: can't use delete_binding() here because we don't know the specific controllable we want to remove, only the midi information
478 for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end();) {
479 MIDIControllable* existingBinding = (*iter);
480 if ( (existingBinding->get_control_type() & 0xf0 ) == (pos & 0xf0) && (existingBinding->get_control_channel() & 0xf ) == channel ) {
481 if ( ((int) existingBinding->get_control_additional() == (int) value) || ((pos & 0xf0) == MIDI::pitchbend)) {
482 DEBUG_TRACE (DEBUG::GenericMidi, "checking: found match, delete old binding.\n");
483 delete existingBinding;
484 iter = controllables.erase (iter);
493 for (MIDIFunctions::iterator iter = functions.begin(); iter != functions.end();) {
494 MIDIFunction* existingBinding = (*iter);
495 if ( (existingBinding->get_control_type() & 0xf0 ) == (pos & 0xf0) && (existingBinding->get_control_channel() & 0xf ) == channel ) {
496 if ( ((int) existingBinding->get_control_additional() == (int) value) || ((pos & 0xf0) == MIDI::pitchbend)) {
497 DEBUG_TRACE (DEBUG::GenericMidi, "checking: found match, delete old binding.\n");
498 delete existingBinding;
499 iter = functions.erase (iter);
508 for (MIDIActions::iterator iter = actions.begin(); iter != actions.end();) {
509 MIDIAction* existingBinding = (*iter);
510 if ( (existingBinding->get_control_type() & 0xf0 ) == (pos & 0xf0) && (existingBinding->get_control_channel() & 0xf ) == channel ) {
511 if ( ((int) existingBinding->get_control_additional() == (int) value) || ((pos & 0xf0) == MIDI::pitchbend)) {
512 DEBUG_TRACE (DEBUG::GenericMidi, "checking: found match, delete old binding.\n");
513 delete existingBinding;
514 iter = actions.erase (iter);
526 GenericMidiControlProtocol::get_state ()
528 XMLNode& node (ControlProtocol::get_state());
531 snprintf (buf, sizeof (buf), "%" PRIu64, _feedback_interval);
532 node.add_property (X_("feedback_interval"), buf);
533 snprintf (buf, sizeof (buf), "%d", _threshold);
534 node.add_property (X_("threshold"), buf);
536 if (!_current_binding.empty()) {
537 node.add_property ("binding", _current_binding);
540 XMLNode* children = new XMLNode (X_("Controls"));
542 node.add_child_nocopy (*children);
544 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
545 for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
547 /* we don't care about bindings that come from a bindings map, because
548 they will all be reset/recreated when we load the relevant bindings
552 if ((*i)->get_controllable() && (*i)->learned()) {
553 children->add_child_nocopy ((*i)->get_state());
561 GenericMidiControlProtocol::set_state (const XMLNode& node, int version)
564 XMLNodeConstIterator niter;
565 const XMLProperty* prop;
567 if (ControlProtocol::set_state (node, version)) {
571 if ((prop = node.property ("feedback_interval")) != 0) {
572 if (sscanf (prop->value().c_str(), "%" PRIu64, &_feedback_interval) != 1) {
573 _feedback_interval = 10000;
576 _feedback_interval = 10000;
579 if ((prop = node.property ("threshold")) != 0) {
580 if (sscanf (prop->value().c_str(), "%d", &_threshold) != 1) {
587 boost::shared_ptr<Controllable> c;
590 Glib::Threads::Mutex::Lock lm (pending_lock);
591 for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) {
594 pending_controllables.clear ();
597 // midi map has to be loaded first so learned binding can go on top
598 if ((prop = node.property ("binding")) != 0) {
599 for (list<MapInfo>::iterator x = map_info.begin(); x != map_info.end(); ++x) {
600 if (prop->value() == (*x).name) {
601 load_bindings ((*x).path);
607 /* Load up specific bindings from the
608 * <Controls><MidiControllable>...</MidiControllable><Controls> section
612 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
613 nlist = node.children(); // "Controls"
615 if (!nlist.empty()) {
616 nlist = nlist.front()->children(); // "MIDIControllable" ...
618 if (!nlist.empty()) {
619 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
621 if ((prop = (*niter)->property ("id")) != 0) {
623 ID id = prop->value ();
624 DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Relearned binding for session: Control ID: %1\n", id.to_s()));
625 Controllable* c = Controllable::by_id (id);
628 MIDIControllable* mc = new MIDIControllable (this, *_input_port->parser(), *c, false);
630 if (mc->set_state (**niter, version) == 0) {
631 controllables.push_back (mc);
635 warning << string_compose (
636 _("Generic MIDI control: controllable %1 not found in session (ignored)"),
637 id.to_s()) << endmsg;
649 GenericMidiControlProtocol::set_feedback (bool yn)
652 last_feedback_time = 0;
657 GenericMidiControlProtocol::get_feedback () const
663 GenericMidiControlProtocol::load_bindings (const string& xmlpath)
665 DEBUG_TRACE (DEBUG::GenericMidi, "Load bindings: Reading midi map\n");
668 if (!state_tree.read (xmlpath.c_str())) {
669 error << string_compose(_("Could not understand MIDI bindings file %1"), xmlpath) << endmsg;
673 XMLNode* root = state_tree.root();
675 if (root->name() != X_("ArdourMIDIBindings")) {
676 error << string_compose (_("MIDI Bindings file %1 is not really a MIDI bindings file"), xmlpath) << endmsg;
680 const XMLProperty* prop;
682 if ((prop = root->property ("version")) == 0) {
689 sscanf (prop->value().c_str(), "%d.%d.%d", &major, &minor, µ);
690 Stateful::loading_state_version = (major * 1000) + minor;
693 const XMLNodeList& children (root->children());
694 XMLNodeConstIterator citer;
695 XMLNodeConstIterator gciter;
697 MIDIControllable* mc;
701 DEBUG_TRACE (DEBUG::GenericMidi, "Loading bindings\n");
702 for (citer = children.begin(); citer != children.end(); ++citer) {
704 if ((*citer)->name() == "DeviceInfo") {
705 const XMLProperty* prop;
707 if ((prop = (*citer)->property ("bank-size")) != 0) {
708 _bank_size = atoi (prop->value());
712 if ((prop = (*citer)->property ("motorised")) != 0 || ((prop = (*citer)->property ("motorized")) != 0)) {
713 _motorised = string_is_affirmative (prop->value ());
718 if ((prop = (*citer)->property ("threshold")) != 0) {
719 _threshold = atoi (prop->value ());
726 if ((*citer)->name() == "Binding") {
727 const XMLNode* child = *citer;
729 if (child->property ("uri")) {
732 if ((mc = create_binding (*child)) != 0) {
733 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
734 controllables.push_back (mc);
737 } else if (child->property ("function")) {
742 if ((mf = create_function (*child)) != 0) {
743 functions.push_back (mf);
746 } else if (child->property ("action")) {
749 if ((ma = create_action (*child)) != 0) {
750 actions.push_back (ma);
756 if ((prop = root->property ("name")) != 0) {
757 _current_binding = prop->value ();
760 reset_controllables ();
766 GenericMidiControlProtocol::create_binding (const XMLNode& node)
768 const XMLProperty* prop;
770 MIDI::channel_t channel;
776 if ((prop = node.property (X_("ctl"))) != 0) {
777 ev = MIDI::controller;
778 } else if ((prop = node.property (X_("note"))) != 0) {
780 } else if ((prop = node.property (X_("pgm"))) != 0) {
782 } else if ((prop = node.property (X_("pb"))) != 0) {
783 ev = MIDI::pitchbend;
788 if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
792 detail = (MIDI::byte) intval;
794 if ((prop = node.property (X_("channel"))) == 0) {
798 if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
801 channel = (MIDI::channel_t) intval;
802 /* adjust channel to zero-based counting */
807 if ((prop = node.property (X_("momentary"))) != 0) {
808 momentary = string_is_affirmative (prop->value());
813 prop = node.property (X_("uri"));
816 MIDIControllable* mc = new MIDIControllable (this, *_input_port->parser(), momentary);
818 if (mc->init (uri)) {
823 mc->bind_midi (channel, ev, detail);
829 GenericMidiControlProtocol::reset_controllables ()
831 Glib::Threads::Mutex::Lock lm2 (controllables_lock);
833 for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end(); ) {
834 MIDIControllable* existingBinding = (*iter);
835 MIDIControllables::iterator next = iter;
838 if (!existingBinding->learned()) {
839 ControllableDescriptor& desc (existingBinding->descriptor());
842 desc.set_bank_offset (_current_bank * _bank_size);
845 /* its entirely possible that the session doesn't have
846 * the specified controllable (e.g. it has too few
847 * tracks). if we find this to be the case, we just leave
848 * the binding around, unbound, and it will do "late
849 * binding" (or "lazy binding") if/when any data arrives.
852 existingBinding->lookup_controllable ();
859 boost::shared_ptr<Controllable>
860 GenericMidiControlProtocol::lookup_controllable (const ControllableDescriptor& desc) const
862 return session->controllable_by_descriptor (desc);
866 GenericMidiControlProtocol::create_function (const XMLNode& node)
868 const XMLProperty* prop;
870 MIDI::byte detail = 0;
871 MIDI::channel_t channel = 0;
874 MIDI::byte* data = 0;
875 uint32_t data_size = 0;
878 if ((prop = node.property (X_("ctl"))) != 0) {
879 ev = MIDI::controller;
880 } else if ((prop = node.property (X_("note"))) != 0) {
882 } else if ((prop = node.property (X_("pgm"))) != 0) {
884 } else if ((prop = node.property (X_("sysex"))) != 0 || (prop = node.property (X_("msg"))) != 0) {
886 if (prop->name() == X_("sysex")) {
897 stringstream ss (prop->value());
909 data = new MIDI::byte[cnt];
913 stringstream ss (prop->value());
918 data[cnt++] = (MIDI::byte) val;
923 warning << "Binding ignored - unknown type" << endmsg;
927 if (data_size == 0) {
928 if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
932 detail = (MIDI::byte) intval;
934 if ((prop = node.property (X_("channel"))) == 0) {
938 if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
941 channel = (MIDI::channel_t) intval;
942 /* adjust channel to zero-based counting */
948 if ((prop = node.property (X_("arg"))) != 0 || (prop = node.property (X_("argument"))) != 0 || (prop = node.property (X_("arguments"))) != 0) {
949 argument = prop->value ();
952 prop = node.property (X_("function"));
954 MIDIFunction* mf = new MIDIFunction (*_input_port->parser());
956 if (mf->setup (*this, prop->value(), argument, data, data_size)) {
961 mf->bind_midi (channel, ev, detail);
967 GenericMidiControlProtocol::create_action (const XMLNode& node)
969 const XMLProperty* prop;
971 MIDI::byte detail = 0;
972 MIDI::channel_t channel = 0;
975 MIDI::byte* data = 0;
976 uint32_t data_size = 0;
978 if ((prop = node.property (X_("ctl"))) != 0) {
979 ev = MIDI::controller;
980 } else if ((prop = node.property (X_("note"))) != 0) {
982 } else if ((prop = node.property (X_("pgm"))) != 0) {
984 } else if ((prop = node.property (X_("sysex"))) != 0 || (prop = node.property (X_("msg"))) != 0) {
986 if (prop->name() == X_("sysex")) {
997 stringstream ss (prop->value());
1009 data = new MIDI::byte[cnt];
1013 stringstream ss (prop->value());
1018 data[cnt++] = (MIDI::byte) val;
1023 warning << "Binding ignored - unknown type" << endmsg;
1027 if (data_size == 0) {
1028 if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
1032 detail = (MIDI::byte) intval;
1034 if ((prop = node.property (X_("channel"))) == 0) {
1038 if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
1041 channel = (MIDI::channel_t) intval;
1042 /* adjust channel to zero-based counting */
1048 prop = node.property (X_("action"));
1050 MIDIAction* ma = new MIDIAction (*_input_port->parser());
1052 if (ma->init (*this, prop->value(), data, data_size)) {
1057 ma->bind_midi (channel, ev, detail);
1063 GenericMidiControlProtocol::set_current_bank (uint32_t b)
1066 reset_controllables ();
1070 GenericMidiControlProtocol::next_bank ()
1073 reset_controllables ();
1077 GenericMidiControlProtocol::prev_bank()
1079 if (_current_bank) {
1081 reset_controllables ();
1086 GenericMidiControlProtocol::set_motorised (bool m)
1092 GenericMidiControlProtocol::set_threshold (int t)