Skip to content

Commit

Permalink
feat: tweak LinkHut.py to more closely mimic official example
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Aug 7, 2024
1 parent 07ef5f5 commit e79bb3e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions example/LinkHut.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@ def main() -> None:
l.enabled = True
l.startStopSyncEnabled = True

print("enabled | num peers | quantum | start stop sync | tempo | beats | metro")

while True:
s = l.captureSessionState()

link_time = l.clock().micros()
enabled = "yes" if l.enabled else "no"
peers = l.numPeers()
start_stop_sync = "yes" if l.startStopSyncEnabled else "no"
playing = "[playing]" if s.isPlaying() else "[stopped]"
beats = s.beatAtTime(link_time, 0)
phase = int(s.phaseAtTime(link_time, QUANTUM))
phase = "X" * phase + "0" * (QUANTUM - phase)
phase = int(s.phaseAtTime(link_time, QUANTUM)) + 1
metro = "X" * phase + "0" * (QUANTUM - phase)

print(
f"tempo {s.tempo():.2f} | "
f"playing: {s.isPlaying()} | "
f"beats {beats:.2f} | {phase}",
f"{enabled:<7s} | "
f"{peers:<9d} | "
f"{QUANTUM:<7d} | "
f"{start_stop_sync:<3s} {playing:<11s} | "
f"{s.tempo():<7.2f} | "
f"{beats:<7.2f} | "
f"{metro}",
end="\r",
flush=True,
)
Expand Down

0 comments on commit e79bb3e

Please sign in to comment.