Repository navigation
Expand file tree
/
Copy pathchatty_client.py
More file actions
executable file
·114 lines (68 loc) · 2.51 KB
/
Copy pathchatty_client.py
File metadata and controls
executable file
·114 lines (68 loc) · 2.51 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python3
"""Create a JACK client that prints a lot of information.
This client registers all possible callbacks (except the process
callback, which would be just too much noise) and prints some
information whenever they are called.
"""
from __future__ import print_function # only needed for Python 2.x
import jack
def error(msg):
print("Error:", msg)
def info(msg):
print("Info:", msg)
print("setting error/info functions")
jack.set_error_function(error)
jack.set_info_function(info)
print("starting chatty client")
client = jack.Client("Chatty-Client")
if client.status.server_started:
print("JACK server was started")
else:
print("JACK server was already running")
if client.status.name_not_unique:
print("unique client name generated:", client.name)
print("registering callbacks")
def shutdown(status, reason, userdata):
print("JACK shutdown!")
print("status:", status)
print("reason:", reason)
client.set_shutdown_callback(shutdown)
def freewheel(starting, userdata):
print(["stopping", "starting"][starting], "freewheel mode")
client.set_freewheel_callback(freewheel)
def blocksize(blocksize, userdata):
print("setting blocksize to", blocksize)
return jack.SUCCESS
client.set_blocksize_callback(blocksize)
def samplerate(samplerate, userdata):
print("setting samplerate to", samplerate)
return jack.SUCCESS
client.set_samplerate_callback(samplerate)
def client_registration(name, register, userdata):
print("client", repr(name), ["unregistered", "registered"][register])
client.set_client_registration_callback(client_registration)
def port_registration(port, register, userdata):
print(repr(port), ["unregistered", "registered"][register])
client.set_port_registration_callback(port_registration)
def port_connect(a, b, connect, userdata):
print(["disconnected", "connected"][connect], a, "and", b)
client.set_port_connect_callback(port_connect)
def port_rename(port, old, new, userdata):
print("renamed", port, "from", repr(old), "to", repr(new))
return jack.SUCCESS
client.set_port_rename_callback(port_rename)
def graph_order(userdata):
print("graph order changed")
return jack.SUCCESS
client.set_graph_order_callback(graph_order)
def xrun(userdata):
print("xrun; delay", client.xrun_delayed_usecs, "microseconds")
return jack.SUCCESS
client.set_xrun_callback(xrun)
print("activating JACK")
with client:
print("#" * 80)
print("press Return to quit")
print("#" * 80)
input()
print("closing JACK")