Patch from royvegard to add a set-bank midi function
[ardour.git] / libs / surfaces / generic_midi / midifunction.cc
index 3d407b4c76c4345bf8680c172cea428b64ebd95f..70e9337861e5d4b0601cbd1a14794e920eeeb570 100644 (file)
@@ -35,10 +35,12 @@ MIDIFunction::~MIDIFunction ()
 }
 
 int
-MIDIFunction::init (GenericMidiControlProtocol& ui, const std::string& invokable_name, MIDI::byte* msg_data, size_t data_sz)
+MIDIFunction::setup (GenericMidiControlProtocol& ui, const std::string& invokable_name, const std::string& arg, MIDI::byte* msg_data, size_t data_sz)
 {
         MIDIInvokable::init (ui, invokable_name, msg_data, data_sz);
 
+       _argument = arg;
+
        if (strcasecmp (_invokable_name.c_str(), "transport-stop") == 0) {
                _function = TransportStop;
        } else if (strcasecmp (_invokable_name.c_str(), "transport-roll") == 0) {
@@ -59,6 +61,26 @@ MIDIFunction::init (GenericMidiControlProtocol& ui, const std::string& invokable
                _function = NextBank;
        } else if (strcasecmp (_invokable_name.c_str(), "prev-bank") == 0) {
                _function = PrevBank;
+       } else if (strcasecmp (_invokable_name.c_str(), "set-bank") == 0) {
+               if (_argument.empty()) {
+                       return -1;
+               }
+               _function = SetBank;
+       } else if (strcasecmp (_invokable_name.c_str(), "select") == 0) {
+               if (_argument.empty()) {
+                       return -1;
+               }
+               _function = Select;
+       } 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;
        } else {
                return -1;
        }
@@ -78,6 +100,14 @@ MIDIFunction::execute ()
                _ui->prev_bank();
                break;
 
+       case SetBank:
+               if (!_argument.empty()) {
+                       uint32_t bank;
+                       sscanf (_argument.c_str(), "%d", &bank);
+                       _ui->set_current_bank (bank);
+               }
+               break;
+
        case TransportStop:
                _ui->transport_stop ();
                break;
@@ -109,6 +139,26 @@ MIDIFunction::execute ()
        case TransportRecordDisable:
                _ui->set_record_enable (false);
                break;
+
+       case Select:
+               if (!_argument.empty()) {
+                       uint32_t rid;
+                       sscanf (_argument.c_str(), "%d", &rid);
+                       _ui->SetRouteSelection (rid);
+               }
+               break;
+       case TrackSetMute:
+               break;
+       case TrackSetSolo:
+               break;
+       case TrackSetSoloIsolate:
+               break;
+       case TrackSetGain:
+               break;
+       case TrackSetRecordEnable:
+               break;
+       default:
+               break;
        }
 }
 
@@ -120,7 +170,7 @@ MIDIFunction::get_state ()
 }
 
 int
-MIDIFunction::set_state (const XMLNode& node, int version)
+MIDIFunction::set_state (const XMLNode& /*node*/, int /*version*/)
 {
        return 0;
 }