Skip to content

Commit e79bb3e

Browse files
committed
feat: tweak LinkHut.py to more closely mimic official example
https://github.com/Ableton/link/blob/Link-3.1.2/examples/linkhut/main.cpp
1 parent 07ef5f5 commit e79bb3e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

example/LinkHut.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,28 @@ def main() -> None:
99
l.enabled = True
1010
l.startStopSyncEnabled = True
1111

12+
print("enabled | num peers | quantum | start stop sync | tempo | beats | metro")
13+
1214
while True:
1315
s = l.captureSessionState()
1416

1517
link_time = l.clock().micros()
18+
enabled = "yes" if l.enabled else "no"
19+
peers = l.numPeers()
20+
start_stop_sync = "yes" if l.startStopSyncEnabled else "no"
21+
playing = "[playing]" if s.isPlaying() else "[stopped]"
1622
beats = s.beatAtTime(link_time, 0)
17-
phase = int(s.phaseAtTime(link_time, QUANTUM))
18-
phase = "X" * phase + "0" * (QUANTUM - phase)
23+
phase = int(s.phaseAtTime(link_time, QUANTUM)) + 1
24+
metro = "X" * phase + "0" * (QUANTUM - phase)
1925

2026
print(
21-
f"tempo {s.tempo():.2f} | "
22-
f"playing: {s.isPlaying()} | "
23-
f"beats {beats:.2f} | {phase}",
27+
f"{enabled:<7s} | "
28+
f"{peers:<9d} | "
29+
f"{QUANTUM:<7d} | "
30+
f"{start_stop_sync:<3s} {playing:<11s} | "
31+
f"{s.tempo():<7.2f} | "
32+
f"{beats:<7.2f} | "
33+
f"{metro}",
2434
end="\r",
2535
flush=True,
2636
)

0 commit comments

Comments
 (0)