diff --git a/tulip/shared/py/arpegg.py b/tulip/shared/py/arpegg.py index 8b20c5cb1..cea58315d 100644 --- a/tulip/shared/py/arpegg.py +++ b/tulip/shared/py/arpegg.py @@ -18,7 +18,6 @@ class ArpeggiatorSynth: hold = False octaves = 1 direction = "up" - period_ms = 125 # Velocity for all the notes generated by the sequencer. velocity = 0.5 # Notes at or above the split_note are always passed through live, not sequenced. @@ -74,7 +73,9 @@ def _update_full_sequence(self): # Semaphore to the run loop to start going. self.running = True - def next_note(self): + def next_note(self, step=None): + if step is None: + step = self.current_step + 1 if self.current_note: self.synth.note_off(self.current_note) self.current_note = None @@ -82,41 +83,17 @@ def next_note(self): if self.direction == "rand": self.current_step = random.randint(0, len(self.full_sequence) - 1) else: - self.current_step = (self.current_step + 1) % len(self.full_sequence) + self.current_step = step % len(self.full_sequence) self.current_note = self.full_sequence[self.current_step] self.synth.note_on(self.current_note, self.velocity) else: self.running = False - def run(self): - # Endless function that will emit sequencer notes when there are arpeggiate_base_notes. - while True: - if not self.running: - time.sleep_ms(10) # Break up the loop a little - else: - # self.running started sequence. - # Another brief pause to let all keys go down - time.sleep_ms(10) - # Cycle the notes as long as we have them. - while self.running: - self.next_note() - time.sleep_ms(self.period_ms) - def control_change(self, control, value): - #if not self.active: - # return self.synth.control_change(control, value) - if control == self.rate_control_num: - self.period_ms = 25 + 5 * value # 25 to 665 ms - elif control == self.octaves_control_num: - self.cycle_octaves() - elif control == self.direction_control_num: - self.cycle_direction() - else: - self.synth.control_change(control, value) - self._update_full_sequence() + return self.synth.control_change(control, value) def program_change(self, patch_number): - self.synth.program_change(patch_number) + return self.synth.program_change(patch_number) @property def num_voices(self): @@ -152,8 +129,6 @@ def set(self, arg, val=None): self.hold = val # Copy across the current_active_notes after a change in hold. self.arpeggiate_base_notes = set(self.current_active_notes) - elif arg == 'arp_rate': - self.period_ms = int(1000 / (2.0 ** (5 * val))) # 1 Hz to 32 Hz elif arg == 'octaves': self.octaves = val elif arg == 'direction':