diff --git a/pico-cp/__pycache__/code.cpython-312.pyc b/pico-cp/__pycache__/code.cpython-312.pyc index 736f663..19a9796 100644 Binary files a/pico-cp/__pycache__/code.cpython-312.pyc and b/pico-cp/__pycache__/code.cpython-312.pyc differ diff --git a/pico-cp/code.py b/pico-cp/code.py index 3b42d0f..835bc85 100644 --- a/pico-cp/code.py +++ b/pico-cp/code.py @@ -357,10 +357,16 @@ class App: self.bpm, self.lanes = parse_program(prog) self.master = self.lanes[0] self._reset_clock(); self.draw_bpm(); self.draw_status(); self.build_grid() + def _lane_dur(self, L): + beat = 60_000_000_000 / self.bpm + if L['poly']: # ~ polymeter: fit this lane's whole cycle into lane 1's bar + m = self.lanes[0]; master_bar = beat * (m['steps'] // m['sub']) + return int(master_bar / L['steps']) + return int(beat / L['sub']) # straight: a step = one beat / subdivision def _reset_clock(self): now = time.monotonic_ns() for L in self.lanes: - L['next'] = now; L['step'] = -1; L['dur'] = int(60_000_000_000 / self.bpm / L['sub']) + L['next'] = now; L['step'] = -1; L['dur'] = self._lane_dur(L) # ---------- audio + light ---------- def click(self, level): @@ -388,7 +394,7 @@ class App: v = max(30, min(300, v)) if v != self.bpm: self.bpm = v - for L in self.lanes: L['dur'] = int(60_000_000_000 / self.bpm / L['sub']) + for L in self.lanes: L['dur'] = self._lane_dur(L) self.draw_bpm() def goto(self, i): was = self.running; self.load(i); self._label("play")