Skip to content

Commit

Permalink
fixing up synth releasing per dan
Browse files Browse the repository at this point in the history
  • Loading branch information
bwhitman committed Jan 6, 2025
1 parent 2eb7426 commit ffbe487
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tulip/shared/py/midi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit ffbe487

Please sign in to comment.