2008-06-02 17:41:35 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2006 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2009-12-28 18:55:33 -05:00
|
|
|
#include <sstream>
|
2008-06-02 17:41:35 -04:00
|
|
|
#include <algorithm>
|
|
|
|
|
2011-03-25 17:21:05 -04:00
|
|
|
#include <glibmm/miscutils.h>
|
|
|
|
|
2009-12-31 18:43:47 -05:00
|
|
|
#include "pbd/controllable_descriptor.h"
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "pbd/error.h"
|
|
|
|
#include "pbd/failed_constructor.h"
|
2009-12-29 16:31:14 -05:00
|
|
|
#include "pbd/pathscanner.h"
|
|
|
|
#include "pbd/xml++.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "midi++/port.h"
|
2010-07-08 18:55:20 -04:00
|
|
|
#include "midi++/manager.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
#include "ardour/filesystem_paths.h"
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "ardour/session.h"
|
2009-10-30 11:30:22 -04:00
|
|
|
#include "ardour/route.h"
|
2009-12-21 13:23:07 -05:00
|
|
|
#include "ardour/midi_ui.h"
|
2010-03-25 12:03:31 -04:00
|
|
|
#include "ardour/rc_configuration.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
#include "generic_midi_control_protocol.h"
|
|
|
|
#include "midicontrollable.h"
|
2009-12-28 11:49:44 -05:00
|
|
|
#include "midifunction.h"
|
2010-04-08 17:05:55 -04:00
|
|
|
#include "midiaction.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
2009-12-28 11:49:44 -05:00
|
|
|
using namespace std;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2009-12-21 13:23:07 -05:00
|
|
|
#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
|
|
|
|
#define ui_bind(x) boost::protect (boost::bind ((x)))
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
|
2009-12-28 11:49:44 -05:00
|
|
|
: ControlProtocol (s, _("Generic MIDI"), midi_ui_context())
|
2009-12-29 16:31:14 -05:00
|
|
|
, gui (0)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
|
2010-07-08 18:55:20 -04:00
|
|
|
_input_port = MIDI::Manager::instance()->midi_input_port ();
|
|
|
|
_output_port = MIDI::Manager::instance()->midi_output_port ();
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
do_feedback = false;
|
|
|
|
_feedback_interval = 10000; // microseconds
|
|
|
|
last_feedback_time = 0;
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
_current_bank = 0;
|
|
|
|
_bank_size = 0;
|
|
|
|
|
2009-12-21 13:23:07 -05:00
|
|
|
/* XXX is it right to do all these in the same thread as whatever emits the signal? */
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-21 13:23:07 -05:00
|
|
|
Controllable::StartLearning.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::start_learning, this, _1));
|
|
|
|
Controllable::StopLearning.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::stop_learning, this, _1));
|
|
|
|
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));
|
2009-12-19 15:26:31 -05:00
|
|
|
|
2010-03-30 11:18:43 -04:00
|
|
|
Session::SendFeedback.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::send_feedback, this), midi_ui_context());;
|
|
|
|
Route::RemoteControlIDChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::reset_controllables, this), midi_ui_context());
|
2009-12-28 11:49:44 -05:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
reload_maps ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GenericMidiControlProtocol::~GenericMidiControlProtocol ()
|
2009-12-29 16:31:14 -05:00
|
|
|
{
|
|
|
|
drop_all ();
|
|
|
|
tear_down_gui ();
|
|
|
|
}
|
|
|
|
|
2011-03-25 17:21:05 -04:00
|
|
|
static const char * const midimap_env_variable_name = "ARDOUR_MIDIMAPS_PATH";
|
2009-12-29 16:31:14 -05:00
|
|
|
static const char* const midi_map_dir_name = "midi_maps";
|
|
|
|
static const char* const midi_map_suffix = ".map";
|
|
|
|
|
|
|
|
static sys::path
|
|
|
|
system_midi_map_search_path ()
|
|
|
|
{
|
2011-03-25 17:21:05 -04:00
|
|
|
bool midimap_path_defined = false;
|
|
|
|
sys::path spath_env (Glib::getenv (midimap_env_variable_name, midimap_path_defined));
|
|
|
|
|
|
|
|
if (midimap_path_defined) {
|
|
|
|
return spath_env;
|
|
|
|
}
|
|
|
|
|
|
|
|
SearchPath spath (system_data_search_path());
|
2009-12-29 16:31:14 -05:00
|
|
|
spath.add_subdirectory_to_paths(midi_map_dir_name);
|
|
|
|
|
|
|
|
// just return the first directory in the search path that exists
|
|
|
|
SearchPath::const_iterator i = std::find_if(spath.begin(), spath.end(), sys::exists);
|
|
|
|
|
|
|
|
if (i == spath.end()) return sys::path();
|
|
|
|
|
|
|
|
return *i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static sys::path
|
|
|
|
user_midi_map_directory ()
|
|
|
|
{
|
|
|
|
sys::path p(user_config_directory());
|
|
|
|
p /= midi_map_dir_name;
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
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;
|
|
|
|
PathScanner scanner;
|
|
|
|
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) {
|
|
|
|
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);
|
|
|
|
|
|
|
|
XMLTree tree;
|
|
|
|
|
|
|
|
if (!tree.read (fullpath.c_str())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
MapInfo mi;
|
|
|
|
|
|
|
|
XMLProperty* prop = tree.root()->property ("name");
|
|
|
|
|
|
|
|
if (!prop) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
mi.name = prop->value ();
|
|
|
|
mi.path = fullpath;
|
|
|
|
|
|
|
|
map_info.push_back (mi);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete midi_maps;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::drop_all ()
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2009-12-28 11:49:44 -05:00
|
|
|
Glib::Mutex::Lock lm (pending_lock);
|
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
|
|
|
|
for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
controllables.clear ();
|
|
|
|
|
|
|
|
for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
pending_controllables.clear ();
|
|
|
|
|
|
|
|
for (MIDIFunctions::iterator i = functions.begin(); i != functions.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
functions.clear ();
|
2010-04-08 17:05:55 -04:00
|
|
|
|
|
|
|
for (MIDIActions::iterator i = actions.begin(); i != actions.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
actions.clear ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::drop_bindings ()
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
|
|
|
|
for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ) {
|
|
|
|
if (!(*i)->learned()) {
|
|
|
|
delete *i;
|
|
|
|
i = controllables.erase (i);
|
|
|
|
} else {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (MIDIFunctions::iterator i = functions.begin(); i != functions.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
functions.clear ();
|
|
|
|
|
|
|
|
_current_binding = "";
|
|
|
|
_bank_size = 0;
|
|
|
|
_current_bank = 0;
|
|
|
|
}
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
int
|
2009-07-21 11:55:17 -04:00
|
|
|
GenericMidiControlProtocol::set_active (bool /*yn*/)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
/* start/stop delivery/outbound thread */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::set_feedback_interval (microseconds_t ms)
|
|
|
|
{
|
|
|
|
_feedback_interval = ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::send_feedback ()
|
|
|
|
{
|
|
|
|
if (!do_feedback) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
microseconds_t now = get_microseconds ();
|
|
|
|
|
|
|
|
if (last_feedback_time != 0) {
|
|
|
|
if ((now - last_feedback_time) < _feedback_interval) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_send_feedback ();
|
|
|
|
|
|
|
|
last_feedback_time = now;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::_send_feedback ()
|
|
|
|
{
|
|
|
|
const int32_t bufsize = 16 * 1024; /* XXX too big */
|
|
|
|
MIDI::byte buf[bufsize];
|
|
|
|
int32_t bsize = bufsize;
|
|
|
|
MIDI::byte* end = buf;
|
|
|
|
|
|
|
|
for (MIDIControllables::iterator r = controllables.begin(); r != controllables.end(); ++r) {
|
|
|
|
end = (*r)->write_feedback (end, bsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end == buf) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-07-06 20:40:58 -04:00
|
|
|
_output_port->write (buf, (int32_t) (end - buf), 0);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GenericMidiControlProtocol::start_learning (Controllable* c)
|
|
|
|
{
|
|
|
|
if (c == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
MIDIControllables::iterator tmp;
|
|
|
|
for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ) {
|
|
|
|
tmp = i;
|
|
|
|
++tmp;
|
2009-12-10 22:18:17 -05:00
|
|
|
if ((*i)->get_controllable() == c) {
|
2008-06-02 17:41:35 -04:00
|
|
|
delete (*i);
|
|
|
|
controllables.erase (i);
|
|
|
|
}
|
|
|
|
i = tmp;
|
|
|
|
}
|
|
|
|
|
2009-12-30 11:48:58 -05:00
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lm (pending_lock);
|
|
|
|
|
|
|
|
MIDIPendingControllables::iterator ptmp;
|
|
|
|
for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ) {
|
|
|
|
ptmp = i;
|
|
|
|
++ptmp;
|
|
|
|
if (((*i)->first)->get_controllable() == c) {
|
|
|
|
(*i)->second.disconnect();
|
|
|
|
delete (*i)->first;
|
|
|
|
delete *i;
|
|
|
|
pending_controllables.erase (i);
|
|
|
|
}
|
|
|
|
i = ptmp;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MIDIControllable* mc = 0;
|
|
|
|
|
|
|
|
for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
|
2010-01-03 21:04:05 -05:00
|
|
|
if ((*i)->get_controllable() && ((*i)->get_controllable()->id() == c->id())) {
|
2008-06-02 17:41:35 -04:00
|
|
|
mc = *i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mc) {
|
2010-07-06 20:40:58 -04:00
|
|
|
mc = new MIDIControllable (*_input_port, *c, false);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lm (pending_lock);
|
|
|
|
|
2009-12-20 11:50:41 -05:00
|
|
|
MIDIPendingControllable* element = new MIDIPendingControllable;
|
|
|
|
element->first = mc;
|
2009-12-21 13:23:07 -05:00
|
|
|
c->LearningFinished.connect_same_thread (element->second, boost::bind (&GenericMidiControlProtocol::learning_stopped, this, mc));
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
pending_controllables.push_back (element);
|
|
|
|
}
|
|
|
|
|
|
|
|
mc->learn_about_external_control ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::learning_stopped (MIDIControllable* mc)
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lm (pending_lock);
|
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
|
|
|
|
MIDIPendingControllables::iterator tmp;
|
|
|
|
|
|
|
|
for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ) {
|
|
|
|
tmp = i;
|
|
|
|
++tmp;
|
|
|
|
|
2009-12-20 11:50:41 -05:00
|
|
|
if ( (*i)->first == mc) {
|
|
|
|
(*i)->second.disconnect();
|
|
|
|
delete *i;
|
2008-06-02 17:41:35 -04:00
|
|
|
pending_controllables.erase(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = tmp;
|
|
|
|
}
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
controllables.push_back (mc);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::stop_learning (Controllable* c)
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lm (pending_lock);
|
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
MIDIControllable* dptr = 0;
|
|
|
|
|
|
|
|
/* learning timed out, and we've been told to consider this attempt to learn to be cancelled. find the
|
|
|
|
relevant MIDIControllable and remove it from the pending list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) {
|
2009-12-20 11:50:41 -05:00
|
|
|
if (((*i)->first)->get_controllable() == c) {
|
|
|
|
(*i)->first->stop_learning ();
|
|
|
|
dptr = (*i)->first;
|
|
|
|
(*i)->second.disconnect();
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-20 11:50:41 -05:00
|
|
|
delete *i;
|
2008-06-02 17:41:35 -04:00
|
|
|
pending_controllables.erase (i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-18 14:31:00 -05:00
|
|
|
delete dptr;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-18 15:57:58 -05:00
|
|
|
GenericMidiControlProtocol::delete_binding (PBD::Controllable* control)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2009-02-18 15:57:58 -05:00
|
|
|
if (control != 0) {
|
2008-06-02 17:41:35 -04:00
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
|
2010-02-01 15:03:25 -05:00
|
|
|
for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end();) {
|
2008-06-02 17:41:35 -04:00
|
|
|
MIDIControllable* existingBinding = (*iter);
|
|
|
|
|
2009-12-10 22:18:17 -05:00
|
|
|
if (control == (existingBinding->get_controllable())) {
|
2008-06-02 17:41:35 -04:00
|
|
|
delete existingBinding;
|
2010-02-01 15:03:25 -05:00
|
|
|
iter = controllables.erase (iter);
|
|
|
|
} else {
|
|
|
|
++iter;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2009-02-18 15:57:58 -05:00
|
|
|
}
|
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
2009-02-18 15:57:58 -05:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::create_binding (PBD::Controllable* control, int pos, int control_number)
|
|
|
|
{
|
2009-02-18 15:57:58 -05:00
|
|
|
if (control != NULL) {
|
2008-06-02 17:41:35 -04:00
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
|
|
|
|
MIDI::channel_t channel = (pos & 0xf);
|
|
|
|
MIDI::byte value = control_number;
|
|
|
|
|
2009-02-18 15:57:58 -05:00
|
|
|
// Create a MIDIControllable
|
2010-07-06 20:40:58 -04:00
|
|
|
MIDIControllable* mc = new MIDIControllable (*_input_port, *control, false);
|
2009-12-30 07:41:10 -05:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
// 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
|
2010-02-01 15:03:25 -05:00
|
|
|
for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end();) {
|
2008-06-02 17:41:35 -04:00
|
|
|
MIDIControllable* existingBinding = (*iter);
|
|
|
|
|
2009-02-18 15:57:58 -05:00
|
|
|
if ((existingBinding->get_control_channel() & 0xf ) == channel &&
|
2008-06-02 17:41:35 -04:00
|
|
|
existingBinding->get_control_additional() == value &&
|
2009-02-18 15:57:58 -05:00
|
|
|
(existingBinding->get_control_type() & 0xf0 ) == MIDI::controller) {
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
delete existingBinding;
|
2010-02-01 15:03:25 -05:00
|
|
|
iter = controllables.erase (iter);
|
|
|
|
} else {
|
|
|
|
++iter;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2009-02-18 15:57:58 -05:00
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
// Update the MIDI Controllable based on the the pos param
|
|
|
|
// Here is where a table lookup for user mappings could go; for now we'll just wing it...
|
2009-02-18 15:57:58 -05:00
|
|
|
mc->bind_midi(channel, MIDI::controller, value);
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
controllables.push_back (mc);
|
2009-02-18 15:57:58 -05:00
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
XMLNode&
|
|
|
|
GenericMidiControlProtocol::get_state ()
|
|
|
|
{
|
|
|
|
XMLNode* node = new XMLNode ("Protocol");
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
node->add_property (X_("name"), _name);
|
|
|
|
node->add_property (X_("feedback"), do_feedback ? "1" : "0");
|
|
|
|
snprintf (buf, sizeof (buf), "%" PRIu64, _feedback_interval);
|
|
|
|
node->add_property (X_("feedback_interval"), buf);
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
if (!_current_binding.empty()) {
|
|
|
|
node->add_property ("binding", _current_binding);
|
|
|
|
}
|
|
|
|
|
2010-11-27 12:43:32 -05:00
|
|
|
XMLNode* children = new XMLNode (X_("Controls"));
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
node->add_child_nocopy (*children);
|
|
|
|
|
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
/* we don't care about bindings that come from a bindings map, because
|
|
|
|
they will all be reset/recreated when we load the relevant bindings
|
|
|
|
file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((*i)->learned()) {
|
|
|
|
children->add_child_nocopy ((*i)->get_state());
|
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return *node;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2009-10-14 20:57:55 -04:00
|
|
|
GenericMidiControlProtocol::set_state (const XMLNode& node, int version)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
XMLNodeList nlist;
|
|
|
|
XMLNodeConstIterator niter;
|
|
|
|
const XMLProperty* prop;
|
|
|
|
|
|
|
|
if ((prop = node.property ("feedback")) != 0) {
|
|
|
|
do_feedback = (bool) atoi (prop->value().c_str());
|
|
|
|
} else {
|
|
|
|
do_feedback = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((prop = node.property ("feedback_interval")) != 0) {
|
|
|
|
if (sscanf (prop->value().c_str(), "%" PRIu64, &_feedback_interval) != 1) {
|
|
|
|
_feedback_interval = 10000;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_feedback_interval = 10000;
|
|
|
|
}
|
|
|
|
|
2009-12-21 13:23:07 -05:00
|
|
|
boost::shared_ptr<Controllable> c;
|
|
|
|
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lm (pending_lock);
|
|
|
|
for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) {
|
|
|
|
delete *i;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
2009-12-21 13:23:07 -05:00
|
|
|
pending_controllables.clear ();
|
|
|
|
}
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
controllables.clear ();
|
2010-11-27 12:43:32 -05:00
|
|
|
nlist = node.children(); // "Controls"
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
if (nlist.empty()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
nlist = nlist.front()->children ();
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
|
2009-12-21 13:23:07 -05:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
if ((prop = (*niter)->property ("id")) != 0) {
|
2010-11-27 12:43:32 -05:00
|
|
|
|
|
|
|
cerr << "Looking for MIDI Controllable with ID " << prop->value() << endl;
|
2009-12-21 13:23:07 -05:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
ID id = prop->value ();
|
2010-11-27 12:43:32 -05:00
|
|
|
Controllable* c = Controllable::by_id (id);
|
|
|
|
|
|
|
|
cerr << "\tresult = " << c << endl;
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
if (c) {
|
2010-07-06 20:40:58 -04:00
|
|
|
MIDIControllable* mc = new MIDIControllable (*_input_port, *c, false);
|
2010-11-27 12:43:32 -05:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
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;
|
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
2009-12-29 16:31:14 -05:00
|
|
|
|
2009-02-18 15:57:58 -05:00
|
|
|
}
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
if ((prop = node.property ("binding")) != 0) {
|
|
|
|
for (list<MapInfo>::iterator x = map_info.begin(); x != map_info.end(); ++x) {
|
|
|
|
if (prop->value() == (*x).name) {
|
|
|
|
load_bindings ((*x).path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
GenericMidiControlProtocol::set_feedback (bool yn)
|
|
|
|
{
|
|
|
|
do_feedback = yn;
|
|
|
|
last_feedback_time = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GenericMidiControlProtocol::get_feedback () const
|
|
|
|
{
|
|
|
|
return do_feedback;
|
|
|
|
}
|
2009-02-18 15:57:58 -05:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
int
|
|
|
|
GenericMidiControlProtocol::load_bindings (const string& xmlpath)
|
|
|
|
{
|
|
|
|
XMLTree state_tree;
|
|
|
|
|
|
|
|
if (!state_tree.read (xmlpath.c_str())) {
|
|
|
|
error << string_compose(_("Could not understand MIDI bindings file %1"), xmlpath) << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLNode* root = state_tree.root();
|
|
|
|
|
|
|
|
if (root->name() != X_("ArdourMIDIBindings")) {
|
|
|
|
error << string_compose (_("MIDI Bindings file %1 is not really a MIDI bindings file"), xmlpath) << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const XMLProperty* prop;
|
|
|
|
|
|
|
|
if ((prop = root->property ("version")) == 0) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
int micro;
|
|
|
|
|
|
|
|
sscanf (prop->value().c_str(), "%d.%d.%d", &major, &minor, µ);
|
|
|
|
Stateful::loading_state_version = (major * 1000) + minor;
|
|
|
|
}
|
|
|
|
|
|
|
|
const XMLNodeList& children (root->children());
|
|
|
|
XMLNodeConstIterator citer;
|
|
|
|
XMLNodeConstIterator gciter;
|
|
|
|
|
|
|
|
MIDIControllable* mc;
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
drop_all ();
|
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
for (citer = children.begin(); citer != children.end(); ++citer) {
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
if ((*citer)->name() == "DeviceInfo") {
|
|
|
|
const XMLProperty* prop;
|
|
|
|
|
|
|
|
if ((prop = (*citer)->property ("bank-size")) != 0) {
|
|
|
|
_bank_size = atoi (prop->value());
|
|
|
|
_current_bank = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
if ((*citer)->name() == "Binding") {
|
|
|
|
const XMLNode* child = *citer;
|
|
|
|
|
|
|
|
if (child->property ("uri")) {
|
|
|
|
/* controllable */
|
|
|
|
|
|
|
|
if ((mc = create_binding (*child)) != 0) {
|
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
2009-12-29 16:31:14 -05:00
|
|
|
controllables.push_back (mc);
|
2009-12-28 11:49:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (child->property ("function")) {
|
|
|
|
|
|
|
|
/* function */
|
|
|
|
MIDIFunction* mf;
|
|
|
|
|
|
|
|
if ((mf = create_function (*child)) != 0) {
|
|
|
|
functions.push_back (mf);
|
|
|
|
}
|
2010-04-08 17:05:55 -04:00
|
|
|
|
|
|
|
} else if (child->property ("action")) {
|
|
|
|
MIDIAction* ma;
|
|
|
|
|
|
|
|
if ((ma = create_action (*child)) != 0) {
|
|
|
|
actions.push_back (ma);
|
|
|
|
}
|
|
|
|
}
|
2009-12-28 11:49:44 -05:00
|
|
|
}
|
|
|
|
}
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
if ((prop = root->property ("name")) != 0) {
|
|
|
|
_current_binding = prop->value ();
|
|
|
|
}
|
|
|
|
|
|
|
|
reset_controllables ();
|
2009-12-28 11:49:44 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MIDIControllable*
|
|
|
|
GenericMidiControlProtocol::create_binding (const XMLNode& node)
|
|
|
|
{
|
|
|
|
const XMLProperty* prop;
|
2009-12-29 16:31:14 -05:00
|
|
|
MIDI::byte detail;
|
|
|
|
MIDI::channel_t channel;
|
2009-12-28 11:49:44 -05:00
|
|
|
string uri;
|
|
|
|
MIDI::eventType ev;
|
2009-12-29 16:31:14 -05:00
|
|
|
int intval;
|
2010-01-01 13:14:32 -05:00
|
|
|
bool momentary;
|
2009-12-28 11:49:44 -05:00
|
|
|
|
|
|
|
if ((prop = node.property (X_("ctl"))) != 0) {
|
|
|
|
ev = MIDI::controller;
|
|
|
|
} else if ((prop = node.property (X_("note"))) != 0) {
|
|
|
|
ev = MIDI::on;
|
|
|
|
} else if ((prop = node.property (X_("pgm"))) != 0) {
|
|
|
|
ev = MIDI::program;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
|
2009-12-28 11:49:44 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
detail = (MIDI::byte) intval;
|
2009-12-28 11:49:44 -05:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
if ((prop = node.property (X_("channel"))) == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
channel = (MIDI::channel_t) intval;
|
|
|
|
/* adjust channel to zero-based counting */
|
|
|
|
if (channel > 0) {
|
|
|
|
channel -= 1;
|
|
|
|
}
|
2010-01-01 13:14:32 -05:00
|
|
|
|
|
|
|
if ((prop = node.property (X_("momentary"))) != 0) {
|
|
|
|
momentary = string_is_affirmative (prop->value());
|
|
|
|
} else {
|
|
|
|
momentary = false;
|
|
|
|
}
|
2009-12-29 16:31:14 -05:00
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
prop = node.property (X_("uri"));
|
|
|
|
uri = prop->value();
|
|
|
|
|
2010-07-06 20:40:58 -04:00
|
|
|
MIDIControllable* mc = new MIDIControllable (*_input_port, momentary);
|
2009-12-30 07:41:10 -05:00
|
|
|
|
|
|
|
if (mc->init (uri)) {
|
|
|
|
delete mc;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
mc->bind_midi (channel, ev, detail);
|
|
|
|
|
|
|
|
return mc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::reset_controllables ()
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lm2 (controllables_lock);
|
|
|
|
|
|
|
|
for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end(); ++iter) {
|
|
|
|
MIDIControllable* existingBinding = (*iter);
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
if (!existingBinding->learned()) {
|
2009-12-31 18:43:47 -05:00
|
|
|
ControllableDescriptor& desc (existingBinding->descriptor());
|
|
|
|
|
|
|
|
if (desc.banked()) {
|
|
|
|
desc.set_bank_offset (_current_bank * _bank_size);
|
2009-12-29 16:31:14 -05:00
|
|
|
}
|
2009-12-31 18:43:47 -05:00
|
|
|
|
|
|
|
boost::shared_ptr<Controllable> c = session->controllable_by_descriptor (desc);
|
2009-12-29 16:31:14 -05:00
|
|
|
existingBinding->set_controllable (c.get());
|
|
|
|
}
|
2009-12-28 11:49:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MIDIFunction*
|
|
|
|
GenericMidiControlProtocol::create_function (const XMLNode& node)
|
|
|
|
{
|
|
|
|
const XMLProperty* prop;
|
2009-12-28 18:55:33 -05:00
|
|
|
int intval;
|
|
|
|
MIDI::byte detail = 0;
|
|
|
|
MIDI::channel_t channel = 0;
|
2009-12-28 11:49:44 -05:00
|
|
|
string uri;
|
|
|
|
MIDI::eventType ev;
|
2010-04-08 17:05:55 -04:00
|
|
|
MIDI::byte* data = 0;
|
|
|
|
uint32_t data_size = 0;
|
2009-12-28 11:49:44 -05:00
|
|
|
|
|
|
|
if ((prop = node.property (X_("ctl"))) != 0) {
|
|
|
|
ev = MIDI::controller;
|
|
|
|
} else if ((prop = node.property (X_("note"))) != 0) {
|
|
|
|
ev = MIDI::on;
|
|
|
|
} else if ((prop = node.property (X_("pgm"))) != 0) {
|
|
|
|
ev = MIDI::program;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if ((prop = node.property (X_("sysex"))) != 0 || (prop = node.property (X_("msg"))) != 0) {
|
|
|
|
|
|
|
|
if (prop->name() == X_("sysex")) {
|
|
|
|
ev = MIDI::sysex;
|
|
|
|
} else {
|
|
|
|
ev = MIDI::any;
|
|
|
|
}
|
2009-12-28 18:55:33 -05:00
|
|
|
|
|
|
|
int val;
|
|
|
|
uint32_t cnt;
|
|
|
|
|
|
|
|
{
|
|
|
|
cnt = 0;
|
|
|
|
stringstream ss (prop->value());
|
|
|
|
ss << hex;
|
|
|
|
|
|
|
|
while (ss >> val) {
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cnt == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-08 17:05:55 -04:00
|
|
|
data = new MIDI::byte[cnt];
|
|
|
|
data_size = cnt;
|
2009-12-28 18:55:33 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
stringstream ss (prop->value());
|
|
|
|
ss << hex;
|
|
|
|
cnt = 0;
|
|
|
|
|
|
|
|
while (ss >> val) {
|
2010-04-08 17:05:55 -04:00
|
|
|
data[cnt++] = (MIDI::byte) val;
|
2009-12-28 18:55:33 -05:00
|
|
|
}
|
|
|
|
}
|
2010-04-08 17:05:55 -04:00
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
} else {
|
2009-12-28 18:55:33 -05:00
|
|
|
warning << "Binding ignored - unknown type" << endmsg;
|
2009-12-28 11:49:44 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-08 17:05:55 -04:00
|
|
|
if (data_size == 0) {
|
2009-12-29 16:31:14 -05:00
|
|
|
if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
detail = (MIDI::byte) intval;
|
|
|
|
|
2009-12-28 18:55:33 -05:00
|
|
|
if ((prop = node.property (X_("channel"))) == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
channel = (MIDI::channel_t) intval;
|
|
|
|
/* adjust channel to zero-based counting */
|
|
|
|
if (channel > 0) {
|
|
|
|
channel -= 1;
|
|
|
|
}
|
2009-12-28 11:49:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
prop = node.property (X_("function"));
|
|
|
|
|
2010-07-06 20:40:58 -04:00
|
|
|
MIDIFunction* mf = new MIDIFunction (*_input_port);
|
2009-12-28 11:49:44 -05:00
|
|
|
|
2010-04-08 17:05:55 -04:00
|
|
|
if (mf->init (*this, prop->value(), data, data_size)) {
|
2009-12-28 11:49:44 -05:00
|
|
|
delete mf;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mf->bind_midi (channel, ev, detail);
|
2009-12-28 18:55:33 -05:00
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
return mf;
|
|
|
|
}
|
2009-12-29 16:31:14 -05:00
|
|
|
|
2010-04-08 17:05:55 -04:00
|
|
|
MIDIAction*
|
|
|
|
GenericMidiControlProtocol::create_action (const XMLNode& node)
|
|
|
|
{
|
|
|
|
const XMLProperty* prop;
|
|
|
|
int intval;
|
|
|
|
MIDI::byte detail = 0;
|
|
|
|
MIDI::channel_t channel = 0;
|
|
|
|
string uri;
|
|
|
|
MIDI::eventType ev;
|
|
|
|
MIDI::byte* data = 0;
|
|
|
|
uint32_t data_size = 0;
|
|
|
|
|
|
|
|
if ((prop = node.property (X_("ctl"))) != 0) {
|
|
|
|
ev = MIDI::controller;
|
|
|
|
} else if ((prop = node.property (X_("note"))) != 0) {
|
|
|
|
ev = MIDI::on;
|
|
|
|
} else if ((prop = node.property (X_("pgm"))) != 0) {
|
|
|
|
ev = MIDI::program;
|
|
|
|
} else if ((prop = node.property (X_("sysex"))) != 0 || (prop = node.property (X_("msg"))) != 0) {
|
|
|
|
|
|
|
|
if (prop->name() == X_("sysex")) {
|
|
|
|
ev = MIDI::sysex;
|
|
|
|
} else {
|
|
|
|
ev = MIDI::any;
|
|
|
|
}
|
|
|
|
|
|
|
|
int val;
|
|
|
|
uint32_t cnt;
|
|
|
|
|
|
|
|
{
|
|
|
|
cnt = 0;
|
|
|
|
stringstream ss (prop->value());
|
|
|
|
ss << hex;
|
|
|
|
|
|
|
|
while (ss >> val) {
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cnt == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = new MIDI::byte[cnt];
|
|
|
|
data_size = cnt;
|
|
|
|
|
|
|
|
{
|
|
|
|
stringstream ss (prop->value());
|
|
|
|
ss << hex;
|
|
|
|
cnt = 0;
|
|
|
|
|
|
|
|
while (ss >> val) {
|
|
|
|
data[cnt++] = (MIDI::byte) val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
warning << "Binding ignored - unknown type" << endmsg;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data_size == 0) {
|
|
|
|
if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
detail = (MIDI::byte) intval;
|
|
|
|
|
|
|
|
if ((prop = node.property (X_("channel"))) == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sscanf (prop->value().c_str(), "%d", &intval) != 1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
channel = (MIDI::channel_t) intval;
|
|
|
|
/* adjust channel to zero-based counting */
|
|
|
|
if (channel > 0) {
|
|
|
|
channel -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = node.property (X_("action"));
|
|
|
|
|
2010-07-06 20:40:58 -04:00
|
|
|
MIDIAction* ma = new MIDIAction (*_input_port);
|
2010-04-08 17:05:55 -04:00
|
|
|
|
|
|
|
if (ma->init (*this, prop->value(), data, data_size)) {
|
|
|
|
delete ma;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ma->bind_midi (channel, ev, detail);
|
|
|
|
|
|
|
|
return ma;
|
|
|
|
}
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::set_current_bank (uint32_t b)
|
|
|
|
{
|
|
|
|
_current_bank = b;
|
|
|
|
reset_controllables ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::next_bank ()
|
|
|
|
{
|
|
|
|
_current_bank++;
|
|
|
|
reset_controllables ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::prev_bank()
|
|
|
|
{
|
|
|
|
if (_current_bank) {
|
|
|
|
_current_bank--;
|
|
|
|
reset_controllables ();
|
|
|
|
}
|
|
|
|
}
|