avoid compiler warnings about un-implemented MIDI functions (for now)
[ardour2.git] / libs / surfaces / generic_midi / midifunction.cc
blob926ee95a89637b6591ca6394be1e5af27cccbf9f
1 /*
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.
19 #include <cstring>
21 #include "midi++/port.h"
23 #include "midifunction.h"
24 #include "generic_midi_control_protocol.h"
26 using namespace MIDI;
28 MIDIFunction::MIDIFunction (MIDI::Port& p)
29 : MIDIInvokable (p)
33 MIDIFunction::~MIDIFunction ()
37 int
38 MIDIFunction::setup (GenericMidiControlProtocol& ui, const std::string& invokable_name, const std::string& arg, MIDI::byte* msg_data, size_t data_sz)
40 MIDIInvokable::init (ui, invokable_name, msg_data, data_sz);
42 _argument = arg;
44 if (strcasecmp (_invokable_name.c_str(), "transport-stop") == 0) {
45 _function = TransportStop;
46 } else if (strcasecmp (_invokable_name.c_str(), "transport-roll") == 0) {
47 _function = TransportRoll;
48 } else if (strcasecmp (_invokable_name.c_str(), "transport-zero") == 0) {
49 _function = TransportZero;
50 } else if (strcasecmp (_invokable_name.c_str(), "transport-start") == 0) {
51 _function = TransportStart;
52 } else if (strcasecmp (_invokable_name.c_str(), "transport-end") == 0) {
53 _function = TransportEnd;
54 } else if (strcasecmp (_invokable_name.c_str(), "loop-toggle") == 0) {
55 _function = TransportLoopToggle;
56 } else if (strcasecmp (_invokable_name.c_str(), "rec-enable") == 0) {
57 _function = TransportRecordEnable;
58 } else if (strcasecmp (_invokable_name.c_str(), "rec-disable") == 0) {
59 _function = TransportRecordDisable;
60 } else if (strcasecmp (_invokable_name.c_str(), "next-bank") == 0) {
61 _function = NextBank;
62 } else if (strcasecmp (_invokable_name.c_str(), "prev-bank") == 0) {
63 _function = PrevBank;
64 } else if (strcasecmp (_invokable_name.c_str(), "select") == 0) {
65 if (_argument.empty()) {
66 return -1;
68 _function = Select;
69 } else if (strcasecmp (_invokable_name.c_str(), "track-set-solo") == 0) {
70 if (_argument.empty()) {
71 return -1;
73 _function = TrackSetSolo;
74 } else if (strcasecmp (_invokable_name.c_str(), "track-set-mute") == 0) {
75 if (_argument.empty()) {
76 return -1;
78 _function = TrackSetMute;
79 } else {
80 return -1;
83 return 0;
86 void
87 MIDIFunction::execute ()
89 switch (_function) {
90 case NextBank:
91 _ui->next_bank();
92 break;
94 case PrevBank:
95 _ui->prev_bank();
96 break;
98 case TransportStop:
99 _ui->transport_stop ();
100 break;
102 case TransportRoll:
103 _ui->transport_play ();
104 break;
106 case TransportStart:
107 _ui->goto_start ();
108 break;
110 case TransportZero:
111 // need this in BasicUI
112 break;
114 case TransportEnd:
115 _ui->goto_end ();
116 break;
118 case TransportLoopToggle:
119 _ui->loop_toggle ();
120 break;
122 case TransportRecordEnable:
123 _ui->set_record_enable (true);
124 break;
126 case TransportRecordDisable:
127 _ui->set_record_enable (false);
128 break;
130 case Select:
131 if (!_argument.empty()) {
132 uint32_t rid;
133 sscanf (_argument.c_str(), "%d", &rid);
134 _ui->SelectByRID (rid);
136 case TrackSetMute:
137 break;
138 case TrackSetSolo:
139 break;
140 case TrackSetSoloIsolate:
141 break;
142 case TrackSetGain:
143 break;
144 case TrackSetRecordEnable:
145 break;
146 default:
147 break;
151 XMLNode&
152 MIDIFunction::get_state ()
154 XMLNode* node = new XMLNode ("MIDIFunction");
155 return *node;
159 MIDIFunction::set_state (const XMLNode& /*node*/, int /*version*/)
161 return 0;