Repository navigation
Expand file tree
/
Copy pathchatty_client.py
More file actions
executable file
·107 lines (71 loc) · 2.41 KB
/
Copy pathchatty_client.py
File metadata and controls
executable file
·107 lines (71 loc) · 2.41 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
#!/usr/bin/env python3
"""Create a JACK client that prints a lot of information.
This client registers all possible callbacks (except the process
callback and the timebase 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
print("setting error/info functions")
@jack.set_error_function
def error(msg):
print("Error:", msg)
@jack.set_info_function
def info(msg):
print("Info:", msg)
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")
@client.set_shutdown_callback
def shutdown(status, reason):
print("JACK shutdown!")
print("status:", status)
print("reason:", reason)
@client.set_freewheel_callback
def freewheel(starting):
print(["stopping", "starting"][starting], "freewheel mode")
@client.set_blocksize_callback
def blocksize(blocksize):
print("setting blocksize to", blocksize)
return jack.SUCCESS
@client.set_samplerate_callback
def samplerate(samplerate):
print("setting samplerate to", samplerate)
return jack.SUCCESS
@client.set_client_registration_callback
def client_registration(name, register):
print("client", repr(name), ["unregistered", "registered"][register])
@client.set_port_registration_callback
def port_registration(port, register):
print(repr(port), ["unregistered", "registered"][register])
@client.set_port_connect_callback
def port_connect(a, b, connect):
print(["disconnected", "connected"][connect], a, "and", b)
try:
@client.set_port_rename_callback
def port_rename(port, old, new):
print("renamed", port, "from", repr(old), "to", repr(new))
return jack.SUCCESS
except:
print("Could not register port rename callback (not available on JACK1).")
@client.set_graph_order_callback
def graph_order():
print("graph order changed")
return jack.SUCCESS
@client.set_xrun_callback
def xrun():
print("xrun; delay", client.xrun_delayed_usecs, "microseconds")
return jack.SUCCESS
print("activating JACK")
with client:
print("#" * 80)
print("press Return to quit")
print("#" * 80)
input()
print("closing JACK")