X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fgeneric_midi%2Fgeneric_midi_control_protocol.cc;h=2820b069dc7af246917dd417ce851e3478e262c1;hb=1ab61b8564f9934c533d1c1a229888bc7e2fd557;hp=a8ca0c7221d84c0b75e51fac6876151514ca5313;hpb=397729eb182ba3d5e311f0ac80959cf72f5cba24;p=ardour.git diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index a8ca0c7221..2820b069dc 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -32,13 +32,14 @@ #include "pbd/xml++.h" #include "midi++/port.h" -#include "midi++/manager.h" +#include "ardour/audioengine.h" #include "ardour/filesystem_paths.h" #include "ardour/session.h" #include "ardour/route.h" #include "ardour/midi_ui.h" #include "ardour/rc_configuration.h" +#include "ardour/midiport_manager.h" #include "generic_midi_control_protocol.h" #include "midicontrollable.h" @@ -59,8 +60,8 @@ GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s) , _threshold (10) , gui (0) { - _input_port = MIDI::Manager::instance()->midi_input_port (); - _output_port = MIDI::Manager::instance()->midi_output_port (); + _input_port = AudioEngine::instance()->midi_input_port (); + _output_port = AudioEngine::instance()->midi_output_port (); do_feedback = false; _feedback_interval = 10000; // microseconds @@ -106,7 +107,7 @@ static const char * const midimap_env_variable_name = "ARDOUR_MIDIMAPS_PATH"; static const char* const midi_map_dir_name = "midi_maps"; static const char* const midi_map_suffix = ".map"; -static std::string +SearchPath system_midi_map_search_path () { bool midimap_path_defined = false; @@ -118,14 +119,7 @@ system_midi_map_search_path () SearchPath spath (ardour_data_search_path()); spath.add_subdirectory_to_paths(midi_map_dir_name); - - // just return the first directory in the search path that exists - for (SearchPath::const_iterator i = spath.begin(); i != spath.end(); ++i) { - if (Glib::file_test (*i, Glib::FILE_TEST_EXISTS)) { - return *i; - } - } - return std::string(); + return spath; } static std::string @@ -345,7 +339,7 @@ GenericMidiControlProtocol::start_learning (Controllable* c) } if (!mc) { - mc = new MIDIControllable (this, *_input_port, *c, false); + mc = new MIDIControllable (this, *_input_port->parser(), *c, false); } { @@ -442,7 +436,7 @@ GenericMidiControlProtocol::create_binding (PBD::Controllable* control, int pos, MIDI::byte value = control_number; // Create a MIDIControllable - MIDIControllable* mc = new MIDIControllable (this, *_input_port, *control, false); + MIDIControllable* mc = new MIDIControllable (this, *_input_port->parser(), *control, false); // Remove any old binding for this midi channel/type/value pair // Note: can't use delete_binding() here because we don't know the specific controllable we want to remove, only the midi information @@ -479,6 +473,8 @@ GenericMidiControlProtocol::get_state () node->add_property (X_("feedback"), do_feedback ? "1" : "0"); snprintf (buf, sizeof (buf), "%" PRIu64, _feedback_interval); node->add_property (X_("feedback_interval"), buf); + snprintf (buf, sizeof (buf), "%d", _threshold); + node->add_property (X_("threshold"), buf); if (!_current_binding.empty()) { node->add_property ("binding", _current_binding); @@ -525,6 +521,14 @@ GenericMidiControlProtocol::set_state (const XMLNode& node, int version) _feedback_interval = 10000; } + if ((prop = node.property ("threshold")) != 0) { + if (sscanf (prop->value().c_str(), "%d", &_threshold) != 1) { + _threshold = 10; + } + } else { + _threshold = 10; + } + boost::shared_ptr c; { @@ -535,41 +539,39 @@ GenericMidiControlProtocol::set_state (const XMLNode& node, int version) pending_controllables.clear (); } + /* Load up specific bindings from the + * ... section + */ + { Glib::Threads::Mutex::Lock lm2 (controllables_lock); controllables.clear (); nlist = node.children(); // "Controls" - if (nlist.empty()) { - return 0; - } + if (!nlist.empty()) { + nlist = nlist.front()->children(); // "MIDIControllable" ... - nlist = nlist.front()->children(); // "MIDIControllable" ... - - if (nlist.empty()) { - return 0; - } - - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - - - - if ((prop = (*niter)->property ("id")) != 0) { - - ID id = prop->value (); - Controllable* c = Controllable::by_id (id); - - if (c) { - MIDIControllable* mc = new MIDIControllable (this, *_input_port, *c, false); - - if (mc->set_state (**niter, version) == 0) { - controllables.push_back (mc); - } + if (!nlist.empty()) { + for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - } else { - warning << string_compose ( - _("Generic MIDI control: controllable %1 not found in session (ignored)"), - id) << endmsg; + if ((prop = (*niter)->property ("id")) != 0) { + + ID id = prop->value (); + Controllable* c = Controllable::by_id (id); + + if (c) { + MIDIControllable* mc = new MIDIControllable (this, *_input_port->parser(), *c, false); + + if (mc->set_state (**niter, version) == 0) { + controllables.push_back (mc); + } + + } else { + warning << string_compose ( + _("Generic MIDI control: controllable %1 not found in session (ignored)"), + id) << endmsg; + } + } } } } @@ -753,7 +755,7 @@ GenericMidiControlProtocol::create_binding (const XMLNode& node) prop = node.property (X_("uri")); uri = prop->value(); - MIDIControllable* mc = new MIDIControllable (this, *_input_port, momentary); + MIDIControllable* mc = new MIDIControllable (this, *_input_port->parser(), momentary); if (mc->init (uri)) { delete mc; @@ -891,7 +893,7 @@ GenericMidiControlProtocol::create_function (const XMLNode& node) prop = node.property (X_("function")); - MIDIFunction* mf = new MIDIFunction (*_input_port); + MIDIFunction* mf = new MIDIFunction (*_input_port->parser()); if (mf->setup (*this, prop->value(), argument, data, data_size)) { delete mf; @@ -987,7 +989,7 @@ GenericMidiControlProtocol::create_action (const XMLNode& node) prop = node.property (X_("action")); - MIDIAction* ma = new MIDIAction (*_input_port); + MIDIAction* ma = new MIDIAction (*_input_port->parser()); if (ma->init (*this, prop->value(), data, data_size)) { delete ma;