stereo bug: more testing
[calf.git] / bigbull / test.py
blobdfb3d4ce5b809727eb224c95297a81303c273b4f
1 #!/usr/bin/env python
2 import calfpytools
3 import time
5 #print calfpytools.scan_ttl_file("/usr/local/lib/lv2/allpass-swh.lv2/plugin.ttl")
7 client = calfpytools.JackClient()
8 client.open("calf")
9 print client.get_cobj()
10 port = client.register_port("port", calfpytools.JACK_DEFAULT_AUDIO_TYPE, calfpytools.JackPortIsOutput)
11 print port
12 print port.get_cobj()
13 assert port.get_name() == "port"
14 assert port.get_full_name() == "calf:port"
15 assert port.set_name("port2") == "port2"
16 assert port.get_name() == "port2"
17 assert port.get_full_name() == "calf:port2"
18 assert port.get_flags() == calfpytools.JackPortIsOutput
19 assert port.is_valid()
21 # This doesn't work: assert client.get_port("calf:port2") == port (because JACK C API doesn't reuse the jack_port_t structs)
23 print client.get_ports()
24 print "Audio capture ports: %s" % (", ".join(client.get_ports("system:.*", calfpytools.JACK_DEFAULT_AUDIO_TYPE, calfpytools.JackPortIsOutput)))
25 print "Audio playback ports: %s" % (", ".join(client.get_ports("system:.*", calfpytools.JACK_DEFAULT_AUDIO_TYPE, calfpytools.JackPortIsInput)))
26 print "MIDI capture ports: %s" % (", ".join(client.get_ports("system:.*", calfpytools.JACK_DEFAULT_MIDI_TYPE, calfpytools.JackPortIsOutput)))
27 print "MIDI playback ports: %s" % (", ".join(client.get_ports("system:.*", calfpytools.JACK_DEFAULT_MIDI_TYPE, calfpytools.JackPortIsInput)))
29 assert client.get_ports("calf:.*", calfpytools.JACK_DEFAULT_AUDIO_TYPE) == ['calf:port2']
30 assert client.get_ports("calf:.*", calfpytools.JACK_DEFAULT_MIDI_TYPE) == []
32 port2 = client.get_port("system:playback_1")
33 assert port2.get_name() == "playback_1"
34 print port2.get_full_name()
35 print port2.get_aliases()
36 # prevent Patchage from crashing
37 time.sleep(1)
38 port.unregister()
39 assert port2 == client.get_port("system:playback_1")
40 client.connect("system:capture_1", "system:playback_1")
41 assert port2.get_connections() == ['system:capture_1']
42 assert not port.is_valid()
43 print port2.get_connections()
44 assert port2.get_connections() == ['system:capture_1']
45 client.disconnect("system:capture_1", "system:playback_1")
46 assert port2.get_connections() == []
48 while True:
49 msg = client.get_message()
50 if msg != None:
51 print "Msg = %s" % str(msg)
52 else:
53 #time.sleep(0.1)
54 break
55 client.close()