2009-12-28 15:52:13 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009 Paul Davis
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2009-12-28 15:52:13 -05:00
|
|
|
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 <cstring>
|
|
|
|
|
|
|
|
#include "midi++/port.h"
|
|
|
|
|
|
|
|
#include "midifunction.h"
|
2009-12-29 16:31:14 -05:00
|
|
|
#include "generic_midi_control_protocol.h"
|
2009-12-28 15:52:13 -05:00
|
|
|
|
2015-07-09 21:16:44 -04:00
|
|
|
#include "pbd/compose.h"
|
|
|
|
|
|
|
|
#include "ardour/debug.h"
|
|
|
|
|
2009-12-28 15:52:13 -05:00
|
|
|
using namespace MIDI;
|
2015-07-09 21:16:44 -04:00
|
|
|
using namespace PBD;
|
2009-12-28 15:52:13 -05:00
|
|
|
|
2013-08-07 22:22:11 -04:00
|
|
|
MIDIFunction::MIDIFunction (MIDI::Parser& p)
|
2010-04-08 17:05:55 -04:00
|
|
|
: MIDIInvokable (p)
|
2009-12-28 15:52:13 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MIDIFunction::~MIDIFunction ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2011-08-13 12:27:29 -04:00
|
|
|
MIDIFunction::setup (GenericMidiControlProtocol& ui, const std::string& invokable_name, const std::string& arg, MIDI::byte* msg_data, size_t data_sz)
|
2009-12-28 15:52:13 -05:00
|
|
|
{
|
2010-04-08 17:05:55 -04:00
|
|
|
MIDIInvokable::init (ui, invokable_name, msg_data, data_sz);
|
|
|
|
|
2011-08-13 12:27:29 -04:00
|
|
|
_argument = arg;
|
|
|
|
|
2010-04-08 17:05:55 -04:00
|
|
|
if (strcasecmp (_invokable_name.c_str(), "transport-stop") == 0) {
|
2009-12-28 15:52:13 -05:00
|
|
|
_function = TransportStop;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "transport-roll") == 0) {
|
2009-12-28 15:52:13 -05:00
|
|
|
_function = TransportRoll;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "transport-zero") == 0) {
|
2009-12-28 15:52:13 -05:00
|
|
|
_function = TransportZero;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "transport-start") == 0) {
|
2009-12-28 15:52:13 -05:00
|
|
|
_function = TransportStart;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "transport-end") == 0) {
|
2009-12-28 15:52:13 -05:00
|
|
|
_function = TransportEnd;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "loop-toggle") == 0) {
|
2009-12-28 18:55:33 -05:00
|
|
|
_function = TransportLoopToggle;
|
2016-01-14 17:37:47 -05:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "toggle-rec-enable") == 0) {
|
|
|
|
_function = TransportRecordToggle;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "rec-enable") == 0) {
|
2009-12-28 18:55:33 -05:00
|
|
|
_function = TransportRecordEnable;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "rec-disable") == 0) {
|
2009-12-28 18:55:33 -05:00
|
|
|
_function = TransportRecordDisable;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "next-bank") == 0) {
|
2009-12-29 16:31:14 -05:00
|
|
|
_function = NextBank;
|
2010-04-08 17:05:55 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "prev-bank") == 0) {
|
2009-12-29 16:31:14 -05:00
|
|
|
_function = PrevBank;
|
2012-06-25 15:26:00 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "set-bank") == 0) {
|
|
|
|
if (_argument.empty()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
_function = SetBank;
|
2011-08-13 12:27:29 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "select") == 0) {
|
|
|
|
if (_argument.empty()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
_function = Select;
|
2011-08-14 13:11:33 -04:00
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "track-set-solo") == 0) {
|
|
|
|
if (_argument.empty()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
_function = TrackSetSolo;
|
|
|
|
} else if (strcasecmp (_invokable_name.c_str(), "track-set-mute") == 0) {
|
|
|
|
if (_argument.empty()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
_function = TrackSetMute;
|
2009-12-28 15:52:13 -05:00
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MIDIFunction::execute ()
|
|
|
|
{
|
|
|
|
switch (_function) {
|
2009-12-29 16:31:14 -05:00
|
|
|
case NextBank:
|
|
|
|
_ui->next_bank();
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: next_bank\n");
|
2009-12-29 16:31:14 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PrevBank:
|
|
|
|
_ui->prev_bank();
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: prev_bank\n");
|
2009-12-29 16:31:14 -05:00
|
|
|
break;
|
|
|
|
|
2012-06-25 15:26:00 -04:00
|
|
|
case SetBank:
|
|
|
|
if (!_argument.empty()) {
|
|
|
|
uint32_t bank;
|
|
|
|
sscanf (_argument.c_str(), "%d", &bank);
|
|
|
|
_ui->set_current_bank (bank);
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: set_current_bank = %1\n", (int) bank));
|
2012-06-25 15:26:00 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-12-28 15:52:13 -05:00
|
|
|
case TransportStop:
|
|
|
|
_ui->transport_stop ();
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: transport_stop\n");
|
2009-12-28 15:52:13 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportRoll:
|
|
|
|
_ui->transport_play ();
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: transport_play\n");
|
2009-12-28 15:52:13 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportStart:
|
|
|
|
_ui->goto_start ();
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_start\n");
|
2009-12-28 15:52:13 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportZero:
|
|
|
|
// need this in BasicUI
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_zero-not implemented\n");
|
2009-12-28 15:52:13 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportEnd:
|
|
|
|
_ui->goto_end ();
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_end\n");
|
2009-12-28 15:52:13 -05:00
|
|
|
break;
|
2009-12-28 18:55:33 -05:00
|
|
|
|
|
|
|
case TransportLoopToggle:
|
|
|
|
_ui->loop_toggle ();
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: loop_toggle\n");
|
2009-12-28 18:55:33 -05:00
|
|
|
break;
|
|
|
|
|
2016-01-14 17:37:47 -05:00
|
|
|
case TransportRecordToggle:
|
|
|
|
_ui->rec_enable_toggle ();
|
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: toggle_record_enable\n");
|
|
|
|
break;
|
|
|
|
|
2009-12-28 18:55:33 -05:00
|
|
|
case TransportRecordEnable:
|
|
|
|
_ui->set_record_enable (true);
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = true\n");
|
2009-12-28 18:55:33 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportRecordDisable:
|
|
|
|
_ui->set_record_enable (false);
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = false\n");
|
2009-12-28 18:55:33 -05:00
|
|
|
break;
|
2011-08-13 12:27:29 -04:00
|
|
|
|
|
|
|
case Select:
|
|
|
|
if (!_argument.empty()) {
|
2016-05-17 15:45:56 -04:00
|
|
|
/* this uses only the numerical orderpart of a
|
|
|
|
PresentionInfo, because it only sets the lower 32
|
|
|
|
bits of a 64 bit value. This will be interpreted
|
|
|
|
as a request to select only Routes.
|
|
|
|
*/
|
2011-08-13 12:27:29 -04:00
|
|
|
uint32_t rid;
|
|
|
|
sscanf (_argument.c_str(), "%d", &rid);
|
2016-05-17 15:45:56 -04:00
|
|
|
_ui->SetStripableSelection (rid);
|
2015-07-09 21:16:44 -04:00
|
|
|
DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SetRouteSelection = %1\n", rid));
|
2011-08-13 12:27:29 -04:00
|
|
|
}
|
2012-04-13 12:11:55 -04:00
|
|
|
break;
|
2011-08-16 10:20:09 -04:00
|
|
|
case TrackSetMute:
|
|
|
|
break;
|
|
|
|
case TrackSetSolo:
|
|
|
|
break;
|
|
|
|
case TrackSetSoloIsolate:
|
|
|
|
break;
|
|
|
|
case TrackSetGain:
|
|
|
|
break;
|
|
|
|
case TrackSetRecordEnable:
|
|
|
|
break;
|
2011-08-14 13:11:33 -04:00
|
|
|
default:
|
|
|
|
break;
|
2009-12-28 15:52:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLNode&
|
|
|
|
MIDIFunction::get_state ()
|
|
|
|
{
|
2015-07-09 21:16:44 -04:00
|
|
|
|
2009-12-28 15:52:13 -05:00
|
|
|
XMLNode* node = new XMLNode ("MIDIFunction");
|
|
|
|
return *node;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-09-02 13:01:36 -04:00
|
|
|
MIDIFunction::set_state (const XMLNode& /*node*/, int /*version*/)
|
2009-12-28 15:52:13 -05:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2009-12-28 18:55:33 -05:00
|
|
|
|