#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"
, _threshold (10)
, gui (0)
{
- _input_port = MIDI::Manager::instance()->midi_input_port ();
- _output_port = MIDI::Manager::instance()->midi_output_port ();
+ _input_port = s.midi_input_port ();
+ _output_port = s.midi_output_port ();
do_feedback = false;
_feedback_interval = 10000; // microseconds
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;
return spath_env;
}
- SearchPath spath (ardour_data_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
}
static bool
-midi_map_filter (const string &str, void */*arg*/)
+midi_map_filter (const string &str, void* /*arg*/)
{
return (str.length() > strlen(midi_map_suffix) &&
str.find (midi_map_suffix) == (str.length() - strlen (midi_map_suffix)));
{
vector<string *> *midi_maps;
PathScanner scanner;
- SearchPath spath (system_midi_map_search_path());
+ Searchpath spath (system_midi_map_search_path());
spath += user_midi_map_directory ();
midi_maps = scanner (spath.to_string(), midi_map_filter, 0, false, true);
}
if (!mc) {
- mc = new MIDIControllable (this, *_input_port, *c, false);
+ mc = new MIDIControllable (this, *_input_port->parser(), *c, false);
}
{
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
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);
file.
*/
- if ((*i)->learned()) {
+ if ((*i)->get_controllable() && (*i)->learned()) {
children->add_child_nocopy ((*i)->get_state());
}
}
_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<Controllable> c;
{
pending_controllables.clear ();
}
+ /* Load up specific bindings from the
+ * <Controls><MidiControllable>...</MidiControllable><Controls> section
+ */
+
{
Glib::Threads::Mutex::Lock lm2 (controllables_lock);
controllables.clear ();
nlist = node.children(); // "Controls"
-
- if (nlist.empty()) {
- return 0;
- }
-
- nlist = nlist.front()->children ();
-
- 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 (!nlist.empty()) {
+ nlist = nlist.front()->children(); // "MIDIControllable" ...
- 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;
+ }
+ }
}
}
}
-
}
if ((prop = node.property ("binding")) != 0) {
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;
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;
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;