From 7f70c63e99b5d6bd4303295ed189ee1746e9de6c Mon Sep 17 00:00:00 2001 From: Tristan Tarrant Date: Sun, 14 May 2023 17:43:10 +0200 Subject: [PATCH] Re-enable MIDI program change switching after last web session is closed --- mod/host.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mod/host.py b/mod/host.py index ced4be68..d8ed03fc 100644 --- a/mod/host.py +++ b/mod/host.py @@ -1503,7 +1503,7 @@ def initialize_hmi(self, uiConnected, callback): for i in range(startIndex, endIndex): initial_state_data += ' %s %d' % (normalize_for_hw(pedalboards[i]['title']), i + self.pedalboard_index_offset) - def cb_migi_pb_prgch(_): + def cb_midi_pb_prgch(_): midi_pb_prgch = self.profile.get_midi_prgch_channel("pedalboard") if midi_pb_prgch >= 1 and midi_pb_prgch <= 16: self.send_notmodified("monitor_midi_program %d 1" % (midi_pb_prgch-1), @@ -1512,19 +1512,19 @@ def cb_migi_pb_prgch(_): callback(True) def cb_footswitches(_): - self.setNavigateWithFootswitches(True, cb_migi_pb_prgch) + self.setNavigateWithFootswitches(True, cb_midi_pb_prgch) def cb_set_initial_state(_): - cb = cb_footswitches if self.isBankFootswitchNavigationOn() else cb_migi_pb_prgch + cb = cb_footswitches if self.isBankFootswitchNavigationOn() else cb_midi_pb_prgch self.hmi.initial_state(initial_state_data, cb) if self.hmi.initialized: if self.descriptor.get("hmi_bank_navigation", False): self.setNavigateWithFootswitches(False, cb_set_initial_state) else: - self.hmi.initial_state(initial_state_data, cb_migi_pb_prgch) + self.hmi.initial_state(initial_state_data, cb_midi_pb_prgch) else: - cb_migi_pb_prgch(True) + cb_midi_pb_prgch(True) def start_session(self, callback): midi_pb_prgch, midi_ss_prgch = self.profile.get_midi_prgch_channels() @@ -1572,7 +1572,12 @@ def end_session(self, callback): self.send_output_data_ready(None, None) if not self.hmi.initialized: - callback(True) + # typically initialize_hmi takes care of this but without HMI we need to do it manually + midi_pb_prgch, midi_ss_prgch = self.profile.get_midi_prgch_channels() + if midi_pb_prgch >= 1 and midi_pb_prgch <= 16: + self.send_notmodified("monitor_midi_program %d 1" % (midi_pb_prgch-1), callback) + else + callback(True) return if not self.hmi.connected: callback(True)