From ffbe487797b5b111b3b8d90ac4a90b642430266b Mon Sep 17 00:00:00 2001 From: Brian Whitman Date: Mon, 6 Jan 2025 11:29:42 -0800 Subject: [PATCH] fixing up synth releasing per dan --- tulip/shared/py/midi.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tulip/shared/py/midi.py b/tulip/shared/py/midi.py index 501f324b..44f87b31 100644 --- a/tulip/shared/py/midi.py +++ b/tulip/shared/py/midi.py @@ -21,11 +21,16 @@ def __init__(self, voices_per_channel, patch_per_channel, show_warnings=True): patch = patch_per_channel[channel] if channel in patch_per_channel else None self.add_synth(channel, patch, num_voices) - def add_synth_object(self, channel, synth_object): + def release_synth_for_channel(self, channel): if channel in self.synth_per_channel: # Old Synth allocated - Expicitly return the amy_voices to the pool. self.synth_per_channel[channel].release() del self.synth_per_channel[channel] + if channel in self.arpeggiator_per_channel: + self.arpeggiator_per_channel[channel].synth = None + + def add_synth_object(self, channel, synth_object): + self.release_synth_for_channel(channel) self.synth_per_channel[channel] = synth_object if channel in self.arpeggiator_per_channel: self.arpeggiator_per_channel[channel].synth = synth_object @@ -36,10 +41,7 @@ def add_synth(self, channel=1, patch_number=0, num_voices=6): elif channel == 16: synth_object = OscSynth(num_voices=1) # the "system bleep" synth else: - # TODO: this is a temporary hack to fix allocations that overrun available oscs - if channel in self.synth_per_channel: - self.synth_per_channel[channel].release() - del self.synth_per_channel[channel] + self.release_synth_for_channel(channel) synth_object = Synth(num_voices=num_voices, patch_number=patch_number) self.add_synth_object(channel, synth_object)