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 115 116 117 118 119
|
#!/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)
@client.set_samplerate_callback
def samplerate(samplerate):
print('setting samplerate to', samplerate)
@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))
except AttributeError:
print('Could not register port rename callback (not available on JACK1).')
@client.set_graph_order_callback
def graph_order():
print('graph order changed')
@client.set_xrun_callback
def xrun(delay):
print('xrun; delay', delay, 'microseconds')
try:
@client.set_property_change_callback
def property_change(subject, key, changed):
print('subject {}: '.format(subject), end='')
if not key:
assert changed == jack.PROPERTY_DELETED
print('all properties were removed')
return
print('property {!r} was {}'.format(key, {
jack.PROPERTY_CREATED: 'created',
jack.PROPERTY_CHANGED: 'changed',
jack.PROPERTY_DELETED: 'removed',
}[changed]))
except jack.JackError as e:
print(e)
print('activating JACK')
with client:
print('#' * 80)
print('press Return to quit')
print('#' * 80)
input()
print('closing JACK')
|