Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • master
1 result

Target

Select target project
  • rorist/endless-sequencer
  • moon2/endless-sequencer
2 results
Select Git revision
  • master
1 result
Show changes
Commits on Source (1)
  • moon2's avatar
    captouch edge detection and background playback · 8c652add
    moon2 authored
    We assume that recording is supposed to happen on the edges of presses
    since otherwise it is very hard to input a sequence without a lot of repeats.
    
    Also we added the feature to continue playing in the background as a drum
    computer (with limited accuracy for now as we're using micropython callbacks).
    
    Other things:
    - updated bl00mbox use to new API
    - added a get_help() method for the onboard help viewer
    - reset LEDs when petals are released
    
    This bumps the version to 14.
    8c652add
......@@ -15,11 +15,8 @@ class EndlessSequencer(Application):
self.DEBUG = False
self.is_loading = True
self.loading_text = 'Loading'
self.blm = bl00mbox.Channel("Endless Sequencer")
self.blm.volume = 8000
self.kick = None
self.notes = []
self.samples = []
self.leds_ids = list(range(40))
self.sample_names = [
'kick.wav',
......@@ -42,6 +39,35 @@ class EndlessSequencer(Application):
self.time_signature_txt = ['1/16', '1/8', '1/4']
self.current_time_signature = 1 # 1/8
def get_help(self):
ret = ( "Hold petal 0 and press petals 2-8 to record a sequence in order.\n\n"
"Press petal 1 to add silence, press petal 9 to reset the sequence.\n\n"
"Use the app button l/r to adjust bpm.\n\n"
"Plays in background unless the sequence is empty when exiting.\n\n"
)
return ret
def on_enter(self, vm):
super().on_enter(vm)
try:
self.blm.foreground = True
except:
self.blm = bl00mbox.Channel("Endless Sequencer")
self.mixer = self.blm.new(bl00mbox.plugins.mixer, len(self.sample_names))
self.mixer.signals.output >> self.blm.signals.line_out
self.mixer.signals.gain.mult = 1
self.samples = []
self.is_loading = True
def on_exit(self):
super().on_exit()
if len(self.notes) > 0:
self.blm.callback = self.play_seq
self.blm.background_mute_override = True
else:
self.blm.delete()
def draw(self, ctx: Context) -> None:
ctx.rgb(*colours.BLACK)
ctx.rectangle(
......@@ -146,15 +172,16 @@ class EndlessSequencer(Application):
if self.DEBUG:
print("Loading {}".format(spl))
sample = self.blm.new(bl00mbox.patches.sampler, self.app_path + spl)
sample.signals.output = self.blm.mixer
sample = self.blm.new(bl00mbox.plugins.sampler, self.app_path + spl)
sample.signals.playback_output >> self.mixer.signals.input[next]
self.samples.append(sample)
else:
#if self.DEBUG:
# print("Loading finished.")
self.is_loading = False
ct = captouch.read()
edge = self.input.captouch.petals
hold = ins.captouch.petals
# Input command
btn = self.input.buttons.app
......@@ -163,14 +190,14 @@ class EndlessSequencer(Application):
if btn.right.repeated or btn.right.pressed:
self.bpm += 1
if ct.petals[9].pressed: #reset
if edge[9].whole.pressed: #reset
if self.DEBUG:
print("CLEAR SEQ")
self.notes = []
self.current_note = 0
self.current_sample = 0
if ct.petals[0].pressed: #record
if hold[0].pressed: #record
if self.DEBUG:
print("REC SEQ")
......@@ -179,24 +206,23 @@ class EndlessSequencer(Application):
# Get sequence
for i in range(2, 9):
sample_id = i-2
if ct.petals[i].pressed and sample_id < len(self.sample_names):
if edge[i].whole.pressed and sample_id < len(self.sample_names):
if self.DEBUG:
print(' seq {}'.format(self.sample_names[sample_id]))
self.notes.append(sample_id)
self.play_sample(sample_id)
time.sleep(0.15)
if ct.petals[1].pressed:
if edge[1].whole.pressed:
self.notes.append(self.SILENCE)
time.sleep(0.15)
# Light petal
leds.set_all_rgb(0, 0, 0)
for i in range(10):
if ct.petals[i].pressed or \
if hold[i].pressed or \
(self.current_sample == i-2
and not ct.petals[0].pressed
and not hold[0].pressed
and len(self.notes) > 0):
leds.set_all_rgb(0, 0, 0)
# Select led range
led_id = i*4
......@@ -225,8 +251,10 @@ class EndlessSequencer(Application):
leds.update()
# Play sequence if nothing is pressed
if len(self.notes) > 0 and not ct.petals[0].pressed:
self.play_seq()
if len(self.notes) > 0 and not hold[0].pressed:
self.blm.callback = self.play_seq
else:
self.blm.callback = None
def next_bpm(self):
# taken from binarybrain code
......@@ -239,9 +267,9 @@ class EndlessSequencer(Application):
if i < len(self.samples):
if self.DEBUG and i in self.sample_names:
print (self.sample_names[i])
self.samples[i].signals.trigger.start()
self.samples[i].signals.playback_trigger.start()
def play_seq(self):
def play_seq(self, ins, delta_ms):
if self.DEBUG:
print("PLAY SEQ")
......@@ -262,5 +290,4 @@ class EndlessSequencer(Application):
if __name__ == "__main__":
import st3m.run
st3m.run.run_view(EndlessSequencer(ApplicationContext()))
st3m.run.run_app(EndlessSequencer, "/sd/apps/rorist-endless-sequencer")
......@@ -10,4 +10,4 @@ author = "Rorist"
license = "MIT"
url = "https://git.flow3r.garden/rorist/endless-sequencer"
description = "Sequencer mimicic the OP-1, hold REC to add a step to the sequence, press NXT to add a silence and press RST to reset the sequence."
version = 13
version = 14