Skip to content

Commit

Permalink
Fix: beat count was not reset when restarting
Browse files Browse the repository at this point in the history
When Sardine received a play message from another link peer,
the beat count was not properly reset. This commit is a fix
that will make sure of that.
  • Loading branch information
Bubobubobubobubo committed Jun 23, 2024
1 parent a0b2357 commit 670bd0b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sardine_core/clock/link_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(
tempo: NUMBER = 120,
bpb: int = 4,
loop_interval: float = 0.001,
startup_delay: float = 3.0,
startup_delay: float = 0.1, # idk
):
super().__init__(loop_interval=loop_interval)

Expand Down Expand Up @@ -183,6 +183,7 @@ def _capture_link_info(self, *, update_transport: bool):

if update_transport:
if playing and not last_playing:
self.beat = 0
self.env.resume()
elif not playing and last_playing:
self.env.pause()
Expand Down Expand Up @@ -257,7 +258,7 @@ def hook(self, event: str, *args):
self._time_shift += delta * self.beat_duration

if self._last_capture is not None:
# Allow boradcasting start/stop from sardine transport methods.
# Allow broadcasting start/stop from sardine transport methods.
# This will cause a second pause/resume call from _capture_link_info(),
# but Sardine's transport methods are idempotent so it should be fine.
if event == "pause" and self._playing:
Expand Down

0 comments on commit 670bd0b

Please sign in to comment.