#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
Controllable::CreateBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::create_binding, this, _1, _2, _3));
Controllable::DeleteBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::delete_binding, this, _1));
- Session::SendFeedback.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::send_feedback, this), midi_ui_context());;
-#if 0
- /* XXXX SOMETHING GOES WRONG HERE (april 2012) - STILL DEBUGGING */
/* this signal is emitted by the process() callback, and if
* send_feedback() is going to do anything, it should do it in the
* context of the process() callback itself.
*/
Session::SendFeedback.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::send_feedback, this));
-#endif
+ //Session::SendFeedback.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::send_feedback, this), midi_ui_context());;
+
/* this one is cross-thread */
Route::RemoteControlIDChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::reset_controllables, this), midi_ui_context());
static const char* const midi_map_dir_name = "midi_maps";
static const char* const midi_map_suffix = ".map";
-SearchPath
+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);
return spath;
}
}
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)));
void
GenericMidiControlProtocol::reload_maps ()
{
- vector<string *> *midi_maps;
+ 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 (!midi_maps) {
+ if (midi_maps.empty()) {
cerr << "No MIDI maps found using " << spath.to_string() << endl;
return;
}
- for (vector<string*>::iterator i = midi_maps->begin(); i != midi_maps->end(); ++i) {
- string fullpath = *(*i);
+ for (vector<string>::iterator i = midi_maps.begin(); i != midi_maps.end(); ++i) {
+ string fullpath = *i;
XMLTree tree;
map_info.push_back (mi);
}
-
- delete midi_maps;
}
void
}
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
XMLNode&
GenericMidiControlProtocol::get_state ()
{
- XMLNode* node = new XMLNode ("Protocol");
+ XMLNode& node (ControlProtocol::get_state());
char buf[32];
- node->add_property (X_("name"), _name);
- node->add_property (X_("feedback"), do_feedback ? "1" : "0");
+ node.add_property (X_("feedback"), do_feedback ? "1" : "0");
snprintf (buf, sizeof (buf), "%" PRIu64, _feedback_interval);
- node->add_property (X_("feedback_interval"), buf);
+ node.add_property (X_("feedback_interval"), buf);
snprintf (buf, sizeof (buf), "%d", _threshold);
- node->add_property (X_("threshold"), buf);
+ node.add_property (X_("threshold"), buf);
if (!_current_binding.empty()) {
- node->add_property ("binding", _current_binding);
+ node.add_property ("binding", _current_binding);
}
XMLNode* children = new XMLNode (X_("Controls"));
- node->add_child_nocopy (*children);
+ node.add_child_nocopy (*children);
Glib::Threads::Mutex::Lock lm2 (controllables_lock);
for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
}
}
- return *node;
+ return node;
}
int
Controllable* c = Controllable::by_id (id);
if (c) {
- MIDIControllable* mc = new MIDIControllable (this, *_input_port, *c, false);
+ MIDIControllable* mc = new MIDIControllable (this, *_input_port->parser(), *c, false);
if (mc->set_state (**niter, version) == 0) {
controllables.push_back (mc);
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;