2009-12-28 15:52:13 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009 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 <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
|
|
|
|
|
|
|
using namespace MIDI;
|
|
|
|
|
|
|
|
MIDIFunction::MIDIFunction (MIDI::Port& p)
|
2010-04-08 17:05:55 -04:00
|
|
|
: MIDIInvokable (p)
|
2009-12-28 15:52:13 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MIDIFunction::~MIDIFunction ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-04-08 17:05:55 -04:00
|
|
|
MIDIFunction::init (GenericMidiControlProtocol& ui, const std::string& invokable_name, 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);
|
|
|
|
|
|
|
|
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;
|
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;
|
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();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PrevBank:
|
|
|
|
_ui->prev_bank();
|
|
|
|
break;
|
|
|
|
|
2009-12-28 15:52:13 -05:00
|
|
|
case TransportStop:
|
|
|
|
_ui->transport_stop ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportRoll:
|
|
|
|
_ui->transport_play ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportStart:
|
|
|
|
_ui->goto_start ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportZero:
|
|
|
|
// need this in BasicUI
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportEnd:
|
|
|
|
_ui->goto_end ();
|
|
|
|
break;
|
2009-12-28 18:55:33 -05:00
|
|
|
|
|
|
|
case TransportLoopToggle:
|
|
|
|
_ui->loop_toggle ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportRecordEnable:
|
|
|
|
_ui->set_record_enable (true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TransportRecordDisable:
|
|
|
|
_ui->set_record_enable (false);
|
|
|
|
break;
|
2009-12-28 15:52:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLNode&
|
|
|
|
MIDIFunction::get_state ()
|
|
|
|
{
|
|
|
|
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
|
|
|
|