Skip to content
Snippets Groups Projects
Commit c384b9b7 authored by rorist's avatar rorist
Browse files

Add time signature to UI

parent 2b3499b3
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ class EndlessSequencer(Application):
self.SILENCE = 99
self.bpm = 120
self.time_signature = [0.5, 1, 2] # 1/16, 1/8, 1/4
self.time_signature_txt = ['1/16', '1/4', '1/8']
self.current_time_signature = 2 # 1/8
def draw(self, ctx: Context) -> None:
......@@ -98,23 +99,27 @@ class EndlessSequencer(Application):
# CURRENT SAMPLE
if self.current_sample != None and self.current_sample < len(self.sample_names):
ctx.move_to(0, 18)
ctx.move_to(0, 10)
ctx.rgb(*colours.RED)
ctx.font_size = 20
ctx.text(self.sample_names[self.current_sample])
# BPM
ctx.text_align = ctx.LEFT
ctx.move_to(-90, 50)
ctx.move_to(-90, 35)
ctx.rgb(*colours.WHITE)
ctx.font_size = 18
ctx.text("BPM: {}".format(self.bpm))
ctx.move_to(-80, 70)
ctx.font_size = 12
ctx.text("left btn")
# Time signature
ctx.text_align = ctx.LEFT
ctx.move_to(-90, 50)
ctx.rgb(*colours.WHITE)
ctx.font_size = 18
ctx.text("TIME: {}".format(self.time_signature_txt[self.current_time_signature]))
# Length
ctx.move_to(30, 60)
ctx.move_to(30, 45)
ctx.rgb(*colours.BLUE)
ctx.font_size = 48
if self.current_note > 0:
......@@ -122,6 +127,12 @@ class EndlessSequencer(Application):
else:
ctx.text("{}".format(len(self.notes)))
# Hint
ctx.move_to(-80, 70)
ctx.rgb(*colours.GREY)
ctx.font_size = 12
ctx.text("btn to change\nbpm and time")
ctx.restore()
def think(self, ins: InputState, delta_ms: int) -> None:
......@@ -218,7 +229,7 @@ class EndlessSequencer(Application):
def next_bpm(self):
# taken from binarybrain code
beatTime = 60.0 * 1000.0 / self.bpm / self.current_time_signature
beatTime = 60.0 * 1000.0 / self.bpm / self.time_signature[self.current_time_signature]
curRelTime = time.ticks_diff(time.ticks_ms(), self.startTime)
return curRelTime / beatTime > 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment