-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathshowtime.py
More file actions
executable file
·59 lines (47 loc) · 1.64 KB
/
showtime.py
File metadata and controls
executable file
·59 lines (47 loc) · 1.64 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""Display information about time, transport state et cetera.
This is somewhat modeled after the "showtime.c" example of JACK.
https://github.com/jackaudio/example-clients/blob/master/showtime.c
https://github.com/jackaudio/jack2/blob/master/example-clients/showtime.c
"""
from contextlib import suppress
import time
import sys
import jack
try:
client = jack.Client('showtime')
except jack.JackError:
sys.exit('JACK server not running?')
def showtime():
state, pos = client.transport_query()
items = []
items.append('frame = {} frame_time = {} usecs = {} '.format(
pos['frame'], client.frame_time, pos['usecs']))
items.append(f'state: {state}')
with suppress(KeyError):
items.append('BBT: {bar:3}|{beat}|{tick:04}'.format(**pos))
with suppress(KeyError):
items.append('TC: ({frame_time:.6f}, {next_time:.6f})'.format(**pos))
with suppress(KeyError):
items.append('BBT offset: ({bbt_offset})'.format(**pos))
with suppress(KeyError):
items.append(
'audio/video: ({audio_frames_per_video_frame})'.format(**pos))
with suppress(KeyError):
video_offset = pos['video_offset']
if video_offset:
items.append(f' video@: ({video_offset})')
else:
items.append(' no video');
print(*items, sep='\t')
@client.set_shutdown_callback
def shutdown(status, reason):
sys.exit('JACK shut down, exiting ...')
with client:
try:
while True:
time.sleep(0.00002)
showtime()
except KeyboardInterrupt:
print('signal received, exiting ...', file=sys.stderr)
sys.exit(0)