forked from gonzaloflirt/link-python
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLinkHut.py
More file actions
executable file
·36 lines (31 loc) · 864 Bytes
/
LinkHut.py
File metadata and controls
executable file
·36 lines (31 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
from os import path
import sys
import time
lib_dir = path.normpath(path.dirname(path.realpath(__file__)) + '/..')
sys.path.insert(0, lib_dir)
import link
l = link.Link(120)
l.enabled = True
l.startStopSyncEnabled = True
try:
while True:
s = l.captureSessionState()
link_time = l.clock().micros();
tempo_str = '{0:.2f}'.format(s.tempo())
beats_str = '{0:.2f}'.format(s.beatAtTime(link_time, 0))
playing_str = str(s.isPlaying())
phase = s.phaseAtTime(link_time, 4)
phase_str = ''
for x in range(0, 4):
if x < phase:
phase_str += 'X'
else:
phase_str += '0'
sys.stdout.write(
'tempo ' + tempo_str + ' | playing: ' + playing_str + ' | beats ' + beats_str
+ ' | ' + phase_str + ' \r')
sys.stdout.flush()
time.sleep(0.02)
except KeyboardInterrupt:
pass