Fix last commit
[carla.git] / source / tests.old / carla-plugin-jack.py
blobe1a08fe64b4641337d5e9d18a262f44528786f8e
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
4 # --------------------------------------------------------------------------------------------------------
6 from carla_backend import *
7 from signal import signal, SIGINT, SIGTERM
8 from time import sleep
9 from sys import exit
11 # --------------------------------------------------------------------------------------------------------
13 class CarlaObject(object):
14 __slots__ = [
15 'term'
18 gCarla = CarlaObject()
19 gCarla.term = False
21 def signalHandler(sig, frame):
22 if sig in (SIGINT, SIGTERM):
23 gCarla.term = True
25 # --------------------------------------------------------------------------------------------------------
27 binaryDir = "/home/falktx/Personal/GIT-mine/falkTX/Carla/bin"
28 host = CarlaHostDLL("/home/falktx/Personal/GIT-mine/falkTX/Carla/bin/libcarla_standalone2.so", True)
29 host.set_engine_option(ENGINE_OPTION_PATH_BINARIES, 0, binaryDir)
30 host.set_engine_option(ENGINE_OPTION_PROCESS_MODE, 2, "")
31 host.set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, 0, "")
33 if not host.engine_init("PulseAudio", "Carla-Plugin-JACK"):
34 print("Engine failed to initialize, possible reasons:\n%s" % host.get_last_error())
35 exit(1)
37 fname = "pulseaudio --high-priority --realtime --exit-idle-time=-1 --file=/usr/share/cadence/pulse2jack/play.pa -n"
38 label = ""
40 fname = "/usr/bin/patchage"
41 label = ""
43 fname = "/usr/bin/carla"
44 label = ""
46 if not host.add_plugin(BINARY_NATIVE, PLUGIN_JACK, fname, "", label, 0, None, 0):
47 print("Failed to load plugin, possible reasons:\n%s" % host.get_last_error())
48 host.engine_close()
49 exit(1)
51 signal(SIGINT, signalHandler)
52 signal(SIGTERM, signalHandler)
54 while host.is_engine_running() and not gCarla.term:
55 host.engine_idle()
56 sleep(0.5)
58 if not gCarla.term:
59 print("Engine closed abruptely")
61 if not host.engine_close():
62 print("Engine failed to close, possible reasons:\n%s" % host.get_last_error())
63 exit(1)
65 # --------------------------------------------------------------------------------------------------------