13
0

generic MIDI: extend select function API and make argument be bank-relative, always

This commit is contained in:
Paul Davis 2022-06-05 15:37:04 -06:00
parent eb4ac77a7b
commit 75fe2ce095
4 changed files with 83 additions and 6 deletions

View File

@ -1663,3 +1663,32 @@ GenericMidiControlProtocol::midi_input_handler (Glib::IOCondition ioc, boost::we
return true; 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);
}

View File

@ -126,6 +126,11 @@ public:
return _threshold; 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<void> ConnectionChange; PBD::Signal0<void> ConnectionChange;
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL(); CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();

View File

@ -75,11 +75,26 @@ MIDIFunction::setup (GenericMidiControlProtocol& ui, const std::string& invokabl
return -1; return -1;
} }
_function = SetBank; _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()) { if (_argument.empty()) {
return -1; 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) { } else if (strcasecmp (_invokable_name.c_str(), "track-set-solo") == 0) {
if (_argument.empty()) { if (_argument.empty()) {
return -1; return -1;
@ -165,14 +180,39 @@ MIDIFunction::execute ()
DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = false\n"); DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = false\n");
break; break;
case Select: case SelectSet:
if (!_argument.empty()) { if (!_argument.empty()) {
uint32_t rid; uint32_t rid;
sscanf (_argument.c_str(), "%d", &rid); sscanf (_argument.c_str(), "%d", &rid);
_ui->set_rid_selection (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; 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: case TrackSetMute:
break; break;
case TrackSetSolo: case TrackSetSolo:

View File

@ -52,8 +52,11 @@ class MIDIFunction : public MIDIInvokable
TransportRecordToggle, TransportRecordToggle,
TransportRecordEnable, TransportRecordEnable,
TransportRecordDisable, TransportRecordDisable,
/* 1 argument functions: RID */ /* 1 argument functions: RID, bank relative */
Select, SelectAdd,
SelectRemove,
SelectToggle,
SelectSet,
SetBank, SetBank,
/* 2 argument functions: RID, value */ /* 2 argument functions: RID, value */
TrackSetSolo, TrackSetSolo,