2 Copyright (C) 2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "midi++/port.h"
23 #include "midifunction.h"
24 #include "generic_midi_control_protocol.h"
26 #include "pbd/compose.h"
28 #include "ardour/debug.h"
33 MIDIFunction::MIDIFunction (MIDI::Parser& p)
38 MIDIFunction::~MIDIFunction ()
43 MIDIFunction::setup (GenericMidiControlProtocol& ui, const std::string& invokable_name, const std::string& arg, MIDI::byte* msg_data, size_t data_sz)
45 MIDIInvokable::init (ui, invokable_name, msg_data, data_sz);
49 if (strcasecmp (_invokable_name.c_str(), "transport-stop") == 0) {
50 _function = TransportStop;
51 } else if (strcasecmp (_invokable_name.c_str(), "transport-roll") == 0) {
52 _function = TransportRoll;
53 } else if (strcasecmp (_invokable_name.c_str(), "transport-zero") == 0) {
54 _function = TransportZero;
55 } else if (strcasecmp (_invokable_name.c_str(), "transport-start") == 0) {
56 _function = TransportStart;
57 } else if (strcasecmp (_invokable_name.c_str(), "transport-end") == 0) {
58 _function = TransportEnd;
59 } else if (strcasecmp (_invokable_name.c_str(), "loop-toggle") == 0) {
60 _function = TransportLoopToggle;
61 } else if (strcasecmp (_invokable_name.c_str(), "rec-enable") == 0) {
62 _function = TransportRecordEnable;
63 } else if (strcasecmp (_invokable_name.c_str(), "rec-disable") == 0) {
64 _function = TransportRecordDisable;
65 } else if (strcasecmp (_invokable_name.c_str(), "next-bank") == 0) {
67 } else if (strcasecmp (_invokable_name.c_str(), "prev-bank") == 0) {
69 } else if (strcasecmp (_invokable_name.c_str(), "set-bank") == 0) {
70 if (_argument.empty()) {
74 } else if (strcasecmp (_invokable_name.c_str(), "select") == 0) {
75 if (_argument.empty()) {
79 } else if (strcasecmp (_invokable_name.c_str(), "track-set-solo") == 0) {
80 if (_argument.empty()) {
83 _function = TrackSetSolo;
84 } else if (strcasecmp (_invokable_name.c_str(), "track-set-mute") == 0) {
85 if (_argument.empty()) {
88 _function = TrackSetMute;
97 MIDIFunction::execute ()
102 DEBUG_TRACE (DEBUG::GenericMidi, "Function: next_bank\n");
107 DEBUG_TRACE (DEBUG::GenericMidi, "Function: prev_bank\n");
111 if (!_argument.empty()) {
113 sscanf (_argument.c_str(), "%d", &bank);
114 _ui->set_current_bank (bank);
115 DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: set_current_bank = %1\n", (int) bank));
120 _ui->transport_stop ();
121 DEBUG_TRACE (DEBUG::GenericMidi, "Function: transport_stop\n");
125 _ui->transport_play ();
126 DEBUG_TRACE (DEBUG::GenericMidi, "Function: transport_play\n");
131 DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_start\n");
135 // need this in BasicUI
136 DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_zero-not implemented\n");
141 DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_end\n");
144 case TransportLoopToggle:
146 DEBUG_TRACE (DEBUG::GenericMidi, "Function: loop_toggle\n");
149 case TransportRecordEnable:
150 _ui->set_record_enable (true);
151 DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = true\n");
154 case TransportRecordDisable:
155 _ui->set_record_enable (false);
156 DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = false\n");
160 if (!_argument.empty()) {
162 sscanf (_argument.c_str(), "%d", &rid);
163 _ui->SetRouteSelection (rid);
164 DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SetRouteSelection = %1\n", rid));
171 case TrackSetSoloIsolate:
175 case TrackSetRecordEnable:
183 MIDIFunction::get_state ()
186 XMLNode* node = new XMLNode ("MIDIFunction");
191 MIDIFunction::set_state (const XMLNode& /*node*/, int /*version*/)