Skip to content

Commit

Permalink
Re-enable MIDI program change switching after last web session is closed
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
tristantarrant authored and falkTX committed Nov 28, 2023
1 parent 76b86cb commit a94e47c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions mod/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a94e47c

Please sign in to comment.