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

Add time signature

parent c26d27ac
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,9 @@ class EndlessSequencer(Application): ...@@ -36,7 +36,9 @@ class EndlessSequencer(Application):
self.current_note = 0 self.current_note = 0
self.startTime = time.ticks_ms() self.startTime = time.ticks_ms()
self.SILENCE = 99 self.SILENCE = 99
self.bpm = 240 self.bpm = 120
self.time_signature = [0.5, 1, 2] # 1/16, 1/8, 1/4
self.current_time_signature = 2 # 1/8
def draw(self, ctx: Context) -> None: def draw(self, ctx: Context) -> None:
ctx.rgb(*colours.BLACK) ctx.rgb(*colours.BLACK)
...@@ -216,7 +218,7 @@ class EndlessSequencer(Application): ...@@ -216,7 +218,7 @@ class EndlessSequencer(Application):
def next_bpm(self): def next_bpm(self):
# taken from binarybrain code # taken from binarybrain code
beatTime = 60.0 * 1000.0 / self.bpm beatTime = 60.0 * 1000.0 / self.bpm / self.current_time_signature
curRelTime = time.ticks_diff(time.ticks_ms(), self.startTime) curRelTime = time.ticks_diff(time.ticks_ms(), self.startTime)
return curRelTime / beatTime > 1 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