Skip to content

Commit

Permalink
voices.py: Arpeggiator state set from midi.arpeggiator. Crashes if yo…
Browse files Browse the repository at this point in the history
…u quit and relaunch voices while arpegg is playing in hold mode.
  • Loading branch information
dpwe committed May 26, 2024
1 parent 0ea5711 commit 94400a1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tulip/shared/py/voices.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,33 @@ def __init__(self, width=350, height=300):
self.range.group.set_style_bg_color(tulip.pal_to_lv(9),0)
self.range.group.align_to(self.mode.group, lv.ALIGN.OUT_RIGHT_TOP, 10, 0)

def update_from_arp(self, arp):
"""Configure arpegg UI to match current arpeggiator."""
arpegg_state = self.arpegg.get_state() & lv.STATE.CHECKED
if arp.active and not arpegg_state:
self.arpegg.add_state(lv.STATE.CHECKED)
elif not arp.active and arpegg_state:
self.arpegg.remove_state(lv.STATE_CHECKED)
hold_state = self.hold.get_state() & lv.STATE.CHECKED
if arp.hold and not hold_state:
self.hold.add_state(lv.STATE.CHECKED)
elif not arp.hold and hold_state:
self.hold.remove_state(lv.STATE.CHECKED)
self.mode.select(['up', 'down', 'updown', 'rand'].index(arp.direction))
self.range.select(arp.octaves - 1)

def tempo_cb(self,e):
new_bpm = self.tempo.get_value()*2.4
if(new_bpm < 1.0): new_bpm = 1
tulip.seq_bpm(new_bpm)
self.tempo_label.set_text("%d BPM" % (tulip.seq_bpm()))

def hold_cb(self,e):
if(self.hold.get_state()==3):
midi.arpeggiator.set('hold', True)
else:
midi.arpeggiator.set('hold', False)

def arpegg_cb(self,e):
if(self.arpegg.get_state()==3):
midi.arpeggiator.set('on', True)
Expand Down Expand Up @@ -293,6 +310,7 @@ def run(screen):
app.polyphony = ListColumn('polyphony', [str(x+1) for x in range(8)], width=100)
app.add(app.polyphony)
app.settings = Settings()
app.settings.update_from_arp(midi.arpeggiator)
app.add(app.settings)

current_patch(1)
Expand Down

0 comments on commit 94400a1

Please sign in to comment.