Skip to content

Commit

Permalink
Fix error adding too many chains. Hide audio chains from menu if no a…
Browse files Browse the repository at this point in the history
…udio mixer channels available.
  • Loading branch information
riban committed Nov 7, 2024
1 parent b992ad4 commit c26cff2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 20 deletions.
13 changes: 11 additions & 2 deletions zyngine/zynthian_chain_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ def add_chain(self, chain_id, midi_chan=None, midi_thru=False, audio_thru=False,
chain.set_mixer_chan(mixer_chan)
# else, if audio_thru enabled, setup a mixer_chan
elif audio_thru:
chain.set_mixer_chan(self.get_next_free_mixer_chan())
try:
chain.set_mixer_chan(self.get_next_free_mixer_chan())
except Exception as e:
logging.warning(e)
self.state_manager.end_busy("add_chain")
return None

# Setup MIDI routing
if isinstance(midi_chan, int):
Expand Down Expand Up @@ -828,7 +833,11 @@ def add_processor(self, chain_id, eng_code, parallel=False, slot=None, proc_id=N
chain.fader_pos += 1
# TODO: Fails to detect MIDI only chains in snapshots
if chain.mixer_chan is None and processor.type != "MIDI Tool":
chain.mixer_chan = self.get_next_free_mixer_chan()
try:
chain.mixer_chan = self.get_next_free_mixer_chan()
except Exception as e:
logging.warning(e)
return None
engine = self.start_engine(processor, eng_code, eng_config)
if engine:
chain.rebuild_graph()
Expand Down
4 changes: 4 additions & 0 deletions zyngui/zynthian_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,10 @@ def modify_chain(self, status=None):
self.modify_chain_status["audio_thru"],
zmop_index=zmop_index
)
if chain_id is None:
self.show_screen_reset("audio_mixer")
self.show_info("Failed to create chain", 1500)
return
processor = self.chain_manager.add_processor(
chain_id,
self.modify_chain_status["engine"]
Expand Down
23 changes: 15 additions & 8 deletions zyngui/zynthian_gui_chain_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,23 @@ def __init__(self):
def fill_list(self):
self.list_data = []

try:
self.zyngui.chain_manager.get_next_free_mixer_chan()
mixer_avail = True
except:
mixer_avail = False
self.list_data.append((None, 0, "> ADD CHAIN"))
self.list_data.append(
(self.add_synth_chain, 0, "Add Instrument Chain"))
self.list_data.append((self.add_audiofx_chain, 0, "Add Audio Chain"))
if mixer_avail:
self.list_data.append(
(self.add_synth_chain, 0, "Add Instrument Chain"))
self.list_data.append((self.add_audiofx_chain, 0, "Add Audio Chain"))
self.list_data.append((self.add_midifx_chain, 0, "Add MIDI Chain"))
self.list_data.append(
(self.add_midiaudiofx_chain, 0, "Add MIDI+Audio Chain"))
self.list_data.append(
(self.add_generator_chain, 0, "Add Audio Generator Chain"))
self.list_data.append((self.add_special_chain, 0, "Add Special Chain"))
if mixer_avail:
self.list_data.append(
(self.add_midiaudiofx_chain, 0, "Add MIDI+Audio Chain"))
self.list_data.append(
(self.add_generator_chain, 0, "Add Audio Generator Chain"))
self.list_data.append((self.add_special_chain, 0, "Add Special Chain"))

self.list_data.append((None, 0, "> REMOVE"))
self.list_data.append((self.remove_sequences, 0, "Remove Sequences"))
Expand Down
23 changes: 15 additions & 8 deletions zyngui/zynthian_gui_main_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,23 @@ def fill_list(self):
self.list_data = []

# Chain & Sequence Management
try:
self.zyngui.chain_manager.get_next_free_mixer_chan()
mixer_avail = True
except:
mixer_avail = False
self.list_data.append((None, 0, "> ADD CHAIN"))
self.list_data.append(
(self.add_synth_chain, 0, "Add Instrument Chain"))
self.list_data.append((self.add_audiofx_chain, 0, "Add Audio Chain"))
if mixer_avail:
self.list_data.append(
(self.add_synth_chain, 0, "Add Instrument Chain"))
self.list_data.append((self.add_audiofx_chain, 0, "Add Audio Chain"))
self.list_data.append((self.add_midifx_chain, 0, "Add MIDI Chain"))
self.list_data.append(
(self.add_midiaudiofx_chain, 0, "Add MIDI+Audio Chain"))
self.list_data.append(
(self.add_generator_chain, 0, "Add Audio Generator Chain"))
self.list_data.append((self.add_special_chain, 0, "Add Special Chain"))
if mixer_avail:
self.list_data.append(
(self.add_midiaudiofx_chain, 0, "Add MIDI+Audio Chain"))
self.list_data.append(
(self.add_generator_chain, 0, "Add Audio Generator Chain"))
self.list_data.append((self.add_special_chain, 0, "Add Special Chain"))

self.list_data.append((None, 0, "> REMOVE"))
self.list_data.append((self.remove_sequences, 0, "Remove Sequences"))
Expand Down
5 changes: 3 additions & 2 deletions zyngui/zynthian_gui_midi_chan.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ def set_mode(self, mode, chan=None, chan_all=False):
try:
self.midi_chan = self.zyngui.chain_manager.get_next_free_midi_chan(
self.midi_chan)
except:
pass
except Exception as e:
logging.warning(e)
return
self.index = self.get_midi_chan_index(self.midi_chan)

def fill_list(self):
Expand Down

0 comments on commit c26cff2

Please sign in to comment.