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(), "toggle-rec-enable") == 0) {
62 _function = TransportRecordToggle;
63 } else if (strcasecmp (_invokable_name.c_str(), "rec-enable") == 0) {
64 _function = TransportRecordEnable;
65 } else if (strcasecmp (_invokable_name.c_str(), "rec-disable") == 0) {
66 _function = TransportRecordDisable;
67 } else if (strcasecmp (_invokable_name.c_str(), "next-bank") == 0) {
69 } else if (strcasecmp (_invokable_name.c_str(), "prev-bank") == 0) {
71 } else if (strcasecmp (_invokable_name.c_str(), "set-bank") == 0) {
72 if (_argument.empty()) {
76 } else if (strcasecmp (_invokable_name.c_str(), "select") == 0) {
77 if (_argument.empty()) {
81 } else if (strcasecmp (_invokable_name.c_str(), "track-set-solo") == 0) {
82 if (_argument.empty()) {
85 _function = TrackSetSolo;
86 } else if (strcasecmp (_invokable_name.c_str(), "track-set-mute") == 0) {
87 if (_argument.empty()) {
90 _function = TrackSetMute;
99 MIDIFunction::execute ()
104 DEBUG_TRACE (DEBUG::GenericMidi, "Function: next_bank\n");
109 DEBUG_TRACE (DEBUG::GenericMidi, "Function: prev_bank\n");
113 if (!_argument.empty()) {
115 sscanf (_argument.c_str(), "%d", &bank);
116 _ui->set_current_bank (bank);
117 DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: set_current_bank = %1\n", (int) bank));
122 _ui->transport_stop ();
123 DEBUG_TRACE (DEBUG::GenericMidi, "Function: transport_stop\n");
127 _ui->transport_play ();
128 DEBUG_TRACE (DEBUG::GenericMidi, "Function: transport_play\n");
133 DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_start\n");
137 // need this in BasicUI
138 DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_zero-not implemented\n");
143 DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_end\n");
146 case TransportLoopToggle:
148 DEBUG_TRACE (DEBUG::GenericMidi, "Function: loop_toggle\n");
151 case TransportRecordToggle:
152 _ui->rec_enable_toggle ();
153 DEBUG_TRACE (DEBUG::GenericMidi, "Function: toggle_record_enable\n");
156 case TransportRecordEnable:
157 _ui->set_record_enable (true);
158 DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = true\n");
161 case TransportRecordDisable:
162 _ui->set_record_enable (false);
163 DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = false\n");
167 if (!_argument.empty()) {
169 sscanf (_argument.c_str(), "%d", &rid);
170 // XX fix me ... need to get stripable, not RID
171 //_ui->toggle_selection (rid, ARDOUR::PresentationInfo::Flag (ARDOUR::PresentationInfo::Route|ARDOUR::PresentationInfo::VCA));
172 DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SetRouteSelection = %1\n", rid));
179 case TrackSetSoloIsolate:
183 case TrackSetRecordEnable:
191 MIDIFunction::get_state ()
194 XMLNode* node = new XMLNode ("MIDIFunction");
199 MIDIFunction::set_state (const XMLNode& /*node*/, int /*version*/)