From 75fe2ce095c4ec10473b309eb91bc2593aee71f7 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 5 Jun 2022 15:37:04 -0600 Subject: [PATCH] generic MIDI: extend select function API and make argument be bank-relative, always --- .../generic_midi_control_protocol.cc | 29 +++++++++++ .../generic_midi_control_protocol.h | 5 ++ libs/surfaces/generic_midi/midifunction.cc | 48 +++++++++++++++++-- libs/surfaces/generic_midi/midifunction.h | 7 ++- 4 files changed, 83 insertions(+), 6 deletions(-) diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index 1f09ec5253..b7a6522013 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -1663,3 +1663,32 @@ GenericMidiControlProtocol::midi_input_handler (Glib::IOCondition ioc, boost::we return true; } + +void +GenericMidiControlProtocol::add_rid_to_selection (int rid) +{ + int id = rid + (_current_bank * _bank_size); + ControlProtocol::add_rid_to_selection (id); +} + +void +GenericMidiControlProtocol::set_rid_selection (int rid) +{ + int id = rid + (_current_bank * _bank_size); + ControlProtocol::set_rid_selection (id); +} + +void +GenericMidiControlProtocol::toggle_rid_selection (int rid) +{ + int id = rid + (_current_bank * _bank_size); + ControlProtocol::toggle_rid_selection (id); +} + +void +GenericMidiControlProtocol::remove_rid_from_selection (int rid) +{ + int id = rid + (_current_bank * _bank_size); + ControlProtocol::remove_rid_from_selection (id); +} + diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.h b/libs/surfaces/generic_midi/generic_midi_control_protocol.h index 405f346352..2b624f4c34 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.h +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.h @@ -126,6 +126,11 @@ public: return _threshold; } + void add_rid_to_selection (int rid); + void set_rid_selection (int rid); + void toggle_rid_selection (int rid); + void remove_rid_from_selection (int rid); + PBD::Signal0 ConnectionChange; CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL(); diff --git a/libs/surfaces/generic_midi/midifunction.cc b/libs/surfaces/generic_midi/midifunction.cc index 4948efb4d2..b3d5c2656d 100644 --- a/libs/surfaces/generic_midi/midifunction.cc +++ b/libs/surfaces/generic_midi/midifunction.cc @@ -75,11 +75,26 @@ MIDIFunction::setup (GenericMidiControlProtocol& ui, const std::string& invokabl return -1; } _function = SetBank; - } else if (strcasecmp (_invokable_name.c_str(), "select") == 0) { + } else if (strcasecmp (_invokable_name.c_str(), "select") == 0 || strcasecmp (_invokable_name.c_str(), "select-set") == 0) { if (_argument.empty()) { return -1; } - _function = Select; + _function = SelectSet; + } else if (strcasecmp (_invokable_name.c_str(), "select-remove") == 0) { + if (_argument.empty()) { + return -1; + } + _function = SelectRemove; + } else if (strcasecmp (_invokable_name.c_str(), "select-add") == 0) { + if (_argument.empty()) { + return -1; + } + _function = SelectAdd; + } else if (strcasecmp (_invokable_name.c_str(), "select-toggle") == 0) { + if (_argument.empty()) { + return -1; + } + _function = SelectToggle; } else if (strcasecmp (_invokable_name.c_str(), "track-set-solo") == 0) { if (_argument.empty()) { return -1; @@ -165,14 +180,39 @@ MIDIFunction::execute () DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = false\n"); break; - case Select: + case SelectSet: if (!_argument.empty()) { uint32_t rid; sscanf (_argument.c_str(), "%d", &rid); _ui->set_rid_selection (rid); - DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SetRouteSelection = %1\n", rid)); + DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SelectSet = %1\n", rid)); } break; + case SelectAdd: + if (!_argument.empty()) { + uint32_t rid; + sscanf (_argument.c_str(), "%d", &rid); + _ui->add_rid_to_selection (rid); + DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SelectAdd = %1\n", rid)); + } + break; + case SelectRemove: + if (!_argument.empty()) { + uint32_t rid; + sscanf (_argument.c_str(), "%d", &rid); + _ui->remove_rid_from_selection (rid); + DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SelectRemove = %1\n", rid)); + } + break; + case SelectToggle: + if (!_argument.empty()) { + uint32_t rid; + sscanf (_argument.c_str(), "%d", &rid); + _ui->toggle_rid_selection (rid); + DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SelectToggle = %1\n", rid)); + } + break; + case TrackSetMute: break; case TrackSetSolo: diff --git a/libs/surfaces/generic_midi/midifunction.h b/libs/surfaces/generic_midi/midifunction.h index 878806e425..1ea127fefc 100644 --- a/libs/surfaces/generic_midi/midifunction.h +++ b/libs/surfaces/generic_midi/midifunction.h @@ -52,8 +52,11 @@ class MIDIFunction : public MIDIInvokable TransportRecordToggle, TransportRecordEnable, TransportRecordDisable, - /* 1 argument functions: RID */ - Select, + /* 1 argument functions: RID, bank relative */ + SelectAdd, + SelectRemove, + SelectToggle, + SelectSet, SetBank, /* 2 argument functions: RID, value */ TrackSetSolo,