1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3
4# --------------------------------------------------------------------------------------------------------
5
6from carla_backend import *
7from signal import signal, SIGINT, SIGTERM
8from time import sleep
9from sys import exit
10
11# --------------------------------------------------------------------------------------------------------
12
13class CarlaObject(object):
14    __slots__ = [
15        'term'
16    ]
17
18gCarla = CarlaObject()
19gCarla.term = False
20
21def signalHandler(sig, frame):
22    if sig in (SIGINT, SIGTERM):
23        gCarla.term = True
24
25# --------------------------------------------------------------------------------------------------------
26
27binaryDir = "/home/falktx/Personal/FOSS/GIT/falkTX/Carla/bin"
28host = CarlaHostDLL("/home/falktx/FOSS/GIT-mine/falkTX/Carla/bin/libcarla_standalone2.so", False)
29host.set_engine_option(ENGINE_OPTION_PATH_BINARIES, 0, binaryDir)
30
31if not host.engine_init("JACK", "Carla-uhe-test"):
32    print("Engine failed to initialize, possible reasons:\n%s" % host.get_last_error())
33    exit(1)
34
35if not host.add_plugin(BINARY_NATIVE, PLUGIN_VST2, "/home/falktx/.vst/u-he/ACE.64.so", "", "", 0, None, 0):
36    print("Failed to load plugin, possible reasons:\n%s" % host.get_last_error())
37    host.engine_close()
38    exit(1)
39
40signal(SIGINT,  signalHandler)
41signal(SIGTERM, signalHandler)
42
43while host.is_engine_running() and not gCarla.term:
44    host.engine_idle()
45    sleep(0.5)
46
47if not gCarla.term:
48    print("Engine closed abruptely")
49
50if not host.engine_close():
51    print("Engine failed to close, possible reasons:\n%s" % host.get_last_error())
52    exit(1)
53
54# --------------------------------------------------------------------------------------------------------
55