Skip to content

Instantly share code, notes, and snippets.

@SrMouraSilva
Last active January 19, 2018 13:56
Show Gist options
  • Save SrMouraSilva/ca944c89e577df26ae0f813fa886f475 to your computer and use it in GitHub Desktop.
Save SrMouraSilva/ca944c89e577df26ae0f813fa886f475 to your computer and use it in GitHub Desktop.
Carla host example
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------------------------------------
from carla_backend import *
from signal import signal, SIGINT, SIGTERM
from time import sleep
from sys import exit
# --------------------------------------------------------------------------------------------------------
class CarlaObject(object):
__slots__ = [
'term'
]
gCarla = CarlaObject()
gCarla.term = False
def signalHandler(sig, frame):
if sig in (SIGINT, SIGTERM):
gCarla.term = True
# --------------------------------------------------------------------------------------------------------
binaryDir = "/home/paulo/git/Carla/bin"
host = CarlaHostDLL("/home/paulo/git/Carla/bin/libcarla_standalone2.so", False)
host.set_engine_option(ENGINE_OPTION_PATH_BINARIES, 0, binaryDir)
if not host.engine_init("JACK", "Carla-uhe-test"):
print("Engine failed to initialize, possible reasons:\n%s" % host.get_last_error())
exit(1)
def callback(*args, **kwargs):
print('args:', args)
print('kwargs:', kwargs)
host.set_engine_callback(callback)
#if not host.add_plugin(BINARY_NATIVE, PLUGIN_VST2, "/home/falktx/.vst/u-he/ACE.64.so", "", "", 0, None, 0):
# print("Failed to load plugin, possible reasons:\n%s" % host.get_last_error())
# host.engine_close()
# exit(1)
if not host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "/usr/lib/lv2/gx_echo.lv2/gx_echo.so", "effect_0", "http://guitarix.sourceforge.net/plugins/gx_echo_stereo#_echo_stereo", 6, None, 0):
print("Failed to load plugin, possible reasons:\n%s" % host.get_last_error())
if not host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "/usr/lib/lv2/gx_echo.lv2/gx_echo.so", "effect_1", "http://guitarix.sourceforge.net/plugins/gx_echo_stereo#_echo_stereo", 7, None, 0):
print("Failed to load plugin, possible reasons:\n%s" % host.get_last_error())
print(host.get_plugin_info(0))
print(host.get_plugin_info(1))
print(host.rename_plugin(0, "Teste PM"))
print(host.get_parameter_count_info(0))
print(host.get_parameter_ranges(0, 0))
print(host.set_parameter_value(0, 0, .3))
# Arguments
# groupIdA: Effect output general id
# portIdA: Output unique id
# groupIdB: Effect input general id
# portIdB: Input unique id
# The system effect are id general 2
# The first effect added are id general 3
# If I rename the effect, it will be removed and readded, then your id will be id general 4
# The group general id are diferent from effect id
# The port id I don't know
print(host.patchbay_connect(4, 13, 5, 15))
signal(SIGINT, signalHandler)
signal(SIGTERM, signalHandler)
while host.is_engine_running() and not gCarla.term:
host.engine_idle()
sleep(0.5)
if not gCarla.term:
print("Engine closed abruptely")
if not host.engine_close():
print("Engine failed to close, possible reasons:\n%s" % host.get_last_error())
exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment