Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

carla_backend.py 33KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla Backend code
  4. # Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. from ctypes import *
  20. from platform import architecture
  21. from sys import platform, maxsize
  22. # ------------------------------------------------------------------------------------------------------------
  23. # 64bit check
  24. kIs64bit = bool(architecture()[0] == "64bit" and maxsize > 2**32)
  25. # ------------------------------------------------------------------------------------------------------------
  26. # Set Platform
  27. if platform == "darwin":
  28. HAIKU = False
  29. LINUX = False
  30. MACOS = True
  31. WINDOWS = False
  32. elif "haiku" in platform:
  33. HAIKU = True
  34. LINUX = False
  35. MACOS = False
  36. WINDOWS = False
  37. elif "linux" in platform:
  38. HAIKU = False
  39. LINUX = True
  40. MACOS = False
  41. WINDOWS = False
  42. elif platform in ("win32", "win64", "cygwin"):
  43. HAIKU = False
  44. LINUX = False
  45. MACOS = False
  46. WINDOWS = True
  47. else:
  48. HAIKU = False
  49. LINUX = False
  50. MACOS = False
  51. WINDOWS = False
  52. # ------------------------------------------------------------------------------------------------------------
  53. # Convert a ctypes char** into a python string list
  54. def charStringList(charPtrPtr):
  55. if not charPtrPtr:
  56. return []
  57. i = 0
  58. strList = []
  59. while True:
  60. charPtr = charPtrPtr[i]
  61. if not charPtr:
  62. break
  63. strList.append(charPtr.decode("utf-8", errors="ignore"))
  64. i += 1
  65. return strList
  66. # ------------------------------------------------------------------------------------------------------------
  67. # Convert a ctypes struct into a python dict
  68. def structToDict(struct):
  69. return dict((attr, getattr(struct, attr)) for attr, value in struct._fields_)
  70. # ------------------------------------------------------------------------------------------------
  71. # Backend defines
  72. MAX_DEFAULT_PLUGINS = 99
  73. MAX_RACK_PLUGINS = 16
  74. MAX_PATCHBAY_PLUGINS = 255
  75. MAX_DEFAULT_PARAMETERS = 200
  76. # Plugin Hints
  77. PLUGIN_IS_BRIDGE = 0x001
  78. PLUGIN_IS_RTSAFE = 0x002
  79. PLUGIN_IS_SYNTH = 0x004
  80. PLUGIN_HAS_GUI = 0x008
  81. PLUGIN_CAN_DRYWET = 0x010
  82. PLUGIN_CAN_VOLUME = 0x020
  83. PLUGIN_CAN_BALANCE = 0x040
  84. PLUGIN_CAN_PANNING = 0x080
  85. PLUGIN_NEEDS_SINGLE_THREAD = 0x100
  86. PLUGIN_NEEDS_FIXED_BUFFERS = 0x200
  87. # Plugin Options
  88. PLUGIN_OPTION_FIXED_BUFFERS = 0x001
  89. PLUGIN_OPTION_FORCE_STEREO = 0x002
  90. PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004
  91. PLUGIN_OPTION_USE_CHUNKS = 0x008
  92. PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010
  93. PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020
  94. PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040
  95. PLUGIN_OPTION_SEND_PITCHBEND = 0x080
  96. PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100
  97. # Parameter Hints
  98. PARAMETER_IS_BOOLEAN = 0x001
  99. PARAMETER_IS_INTEGER = 0x002
  100. PARAMETER_IS_LOGARITHMIC = 0x004
  101. PARAMETER_IS_ENABLED = 0x008
  102. PARAMETER_IS_AUTOMABLE = 0x010
  103. PARAMETER_IS_READ_ONLY = 0x020
  104. PARAMETER_USES_SAMPLERATE = 0x040
  105. PARAMETER_USES_SCALEPOINTS = 0x080
  106. PARAMETER_USES_CUSTOM_TEXT = 0x100
  107. # Custom Data types
  108. CUSTOM_DATA_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"
  109. CUSTOM_DATA_STRING = "http://kxstudio.sf.net/ns/carla/string"
  110. # Patchbay Port Hints
  111. PATCHBAY_PORT_IS_INPUT = 0x001
  112. PATCHBAY_PORT_IS_OUTPUT = 0x002
  113. PATCHBAY_PORT_IS_AUDIO = 0x010
  114. PATCHBAY_PORT_IS_CV = 0x020
  115. PATCHBAY_PORT_IS_MIDI = 0x040
  116. PATCHBAY_PORT_IS_OSC = 0x100
  117. PATCHBAY_PORT_IS_PARAMETER = 0x200
  118. # Binary Type
  119. BINARY_NONE = 0
  120. BINARY_POSIX32 = 1
  121. BINARY_POSIX64 = 2
  122. BINARY_WIN32 = 3
  123. BINARY_WIN64 = 4
  124. BINARY_OTHER = 5
  125. # Plugin Type
  126. PLUGIN_NONE = 0
  127. PLUGIN_INTERNAL = 1
  128. PLUGIN_LADSPA = 2
  129. PLUGIN_DSSI = 3
  130. PLUGIN_LV2 = 4
  131. PLUGIN_VST = 5
  132. PLUGIN_AU = 6
  133. PLUGIN_CSOUND = 7
  134. PLUGIN_GIG = 8
  135. PLUGIN_SF2 = 9
  136. PLUGIN_SFZ = 10
  137. # Plugin Category
  138. PLUGIN_CATEGORY_NONE = 0
  139. PLUGIN_CATEGORY_SYNTH = 1
  140. PLUGIN_CATEGORY_DELAY = 2
  141. PLUGIN_CATEGORY_EQ = 3
  142. PLUGIN_CATEGORY_FILTER = 4
  143. PLUGIN_CATEGORY_DYNAMICS = 5
  144. PLUGIN_CATEGORY_MODULATOR = 6
  145. PLUGIN_CATEGORY_UTILITY = 7
  146. PLUGIN_CATEGORY_OTHER = 8
  147. # Parameter Type
  148. PARAMETER_UNKNOWN = 0
  149. PARAMETER_INPUT = 1
  150. PARAMETER_OUTPUT = 2
  151. PARAMETER_LATENCY = 3
  152. PARAMETER_SAMPLE_RATE = 4
  153. PARAMETER_LV2_FREEWHEEL = 5
  154. PARAMETER_LV2_TIME = 6
  155. # Internal Parameters Index
  156. PARAMETER_NULL = -1
  157. PARAMETER_ACTIVE = -2
  158. PARAMETER_DRYWET = -3
  159. PARAMETER_VOLUME = -4
  160. PARAMETER_BALANCE_LEFT = -5
  161. PARAMETER_BALANCE_RIGHT = -6
  162. PARAMETER_PANNING = -7
  163. PARAMETER_CTRL_CHANNEL = -8
  164. PARAMETER_MAX = -9
  165. # Patchbay Icon Type
  166. PATCHBAY_ICON_APPLICATION = 0
  167. PATCHBAY_ICON_HARDWARE = 1
  168. PATCHBAY_ICON_CARLA = 2
  169. PATCHBAY_ICON_DISTRHO = 3
  170. PATCHBAY_ICON_FILE = 4
  171. PATCHBAY_ICON_PLUGIN = 5
  172. # Options Type
  173. OPTION_PROCESS_NAME = 0
  174. OPTION_PROCESS_MODE = 1
  175. OPTION_TRANSPORT_MODE = 2
  176. OPTION_FORCE_STEREO = 3
  177. OPTION_PREFER_PLUGIN_BRIDGES = 4
  178. OPTION_PREFER_UI_BRIDGES = 5
  179. OPTION_UIS_ALWAYS_ON_TOP = 6
  180. OPTION_MAX_PARAMETERS = 7
  181. OPTION_UI_BRIDGES_TIMEOUT = 8
  182. OPTION_AUDIO_NUM_PERIODS = 9
  183. OPTION_AUDIO_BUFFER_SIZE = 10
  184. OPTION_AUDIO_SAMPLE_RATE = 11
  185. OPTION_AUDIO_DEVICE = 12
  186. OPTION_PATH_RESOURCES = 13
  187. OPTION_PATH_BRIDGE_NATIVE = 14
  188. OPTION_PATH_BRIDGE_POSIX32 = 15
  189. OPTION_PATH_BRIDGE_POSIX64 = 16
  190. OPTION_PATH_BRIDGE_WIN32 = 17
  191. OPTION_PATH_BRIDGE_WIN64 = 18
  192. OPTION_PATH_BRIDGE_LV2_EXTERNAL = 19
  193. OPTION_PATH_BRIDGE_LV2_GTK2 = 20
  194. OPTION_PATH_BRIDGE_LV2_GTK3 = 21
  195. OPTION_PATH_BRIDGE_LV2_QT4 = 22
  196. OPTION_PATH_BRIDGE_LV2_QT5 = 23
  197. OPTION_PATH_BRIDGE_LV2_COCOA = 24
  198. OPTION_PATH_BRIDGE_LV2_WINDOWS = 25
  199. OPTION_PATH_BRIDGE_LV2_X11 = 26
  200. OPTION_PATH_BRIDGE_VST_MAC = 27
  201. OPTION_PATH_BRIDGE_VST_HWND = 28
  202. OPTION_PATH_BRIDGE_VST_X11 = 29
  203. # Callback Type
  204. CALLBACK_DEBUG = 0
  205. CALLBACK_PLUGIN_ADDED = 1
  206. CALLBACK_PLUGIN_REMOVED = 2
  207. CALLBACK_PLUGIN_RENAMED = 3
  208. CALLBACK_PARAMETER_VALUE_CHANGED = 4
  209. CALLBACK_PARAMETER_DEFAULT_CHANGED = 5
  210. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 6
  211. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7
  212. CALLBACK_PROGRAM_CHANGED = 8
  213. CALLBACK_MIDI_PROGRAM_CHANGED = 9
  214. CALLBACK_NOTE_ON = 10
  215. CALLBACK_NOTE_OFF = 11
  216. CALLBACK_SHOW_GUI = 12
  217. CALLBACK_UPDATE = 13
  218. CALLBACK_RELOAD_INFO = 14
  219. CALLBACK_RELOAD_PARAMETERS = 15
  220. CALLBACK_RELOAD_PROGRAMS = 16
  221. CALLBACK_RELOAD_ALL = 17
  222. CALLBACK_PATCHBAY_CLIENT_ADDED = 18
  223. CALLBACK_PATCHBAY_CLIENT_REMOVED = 19
  224. CALLBACK_PATCHBAY_CLIENT_RENAMED = 20
  225. CALLBACK_PATCHBAY_PORT_ADDED = 21
  226. CALLBACK_PATCHBAY_PORT_REMOVED = 22
  227. CALLBACK_PATCHBAY_PORT_RENAMED = 23
  228. CALLBACK_PATCHBAY_CONNECTION_ADDED = 24
  229. CALLBACK_PATCHBAY_CONNECTION_REMOVED = 25
  230. CALLBACK_PATCHBAY_ICON_CHANGED = 26
  231. CALLBACK_BUFFER_SIZE_CHANGED = 27
  232. CALLBACK_SAMPLE_RATE_CHANGED = 28
  233. CALLBACK_PROCESS_MODE_CHANGED = 29
  234. CALLBACK_ENGINE_STARTED = 30
  235. CALLBACK_ENGINE_STOPPED = 31
  236. CALLBACK_NSM_ANNOUNCE = 32
  237. CALLBACK_NSM_OPEN = 33
  238. CALLBACK_NSM_SAVE = 34
  239. CALLBACK_ERROR = 35
  240. CALLBACK_INFO = 36
  241. CALLBACK_QUIT = 37
  242. # Process Mode
  243. PROCESS_MODE_SINGLE_CLIENT = 0
  244. PROCESS_MODE_MULTIPLE_CLIENTS = 1
  245. PROCESS_MODE_CONTINUOUS_RACK = 2
  246. PROCESS_MODE_PATCHBAY = 3
  247. PROCESS_MODE_BRIDGE = 4
  248. # Transport Mode
  249. TRANSPORT_MODE_INTERNAL = 0
  250. TRANSPORT_MODE_JACK = 1
  251. TRANSPORT_MODE_PLUGIN = 2
  252. TRANSPORT_MODE_BRIDGE = 3
  253. # Set BINARY_NATIVE
  254. if HAIKU or LINUX or MACOS:
  255. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  256. elif WINDOWS:
  257. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  258. else:
  259. BINARY_NATIVE = BINARY_OTHER
  260. # ------------------------------------------------------------------------------------------------------------
  261. # Backend C++ -> Python variables
  262. c_enum = c_int
  263. c_nullptr = None
  264. CallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_float, c_char_p)
  265. class ParameterData(Structure):
  266. _fields_ = [
  267. ("type", c_enum),
  268. ("index", c_int32),
  269. ("rindex", c_int32),
  270. ("hints", c_uint),
  271. ("midiChannel", c_uint8),
  272. ("midiCC", c_int16)
  273. ]
  274. class ParameterRanges(Structure):
  275. _fields_ = [
  276. ("def", c_float),
  277. ("min", c_float),
  278. ("max", c_float),
  279. ("step", c_float),
  280. ("stepSmall", c_float),
  281. ("stepLarge", c_float)
  282. ]
  283. class MidiProgramData(Structure):
  284. _fields_ = [
  285. ("bank", c_uint32),
  286. ("program", c_uint32),
  287. ("name", c_char_p)
  288. ]
  289. class CustomData(Structure):
  290. _fields_ = [
  291. ("type", c_char_p),
  292. ("key", c_char_p),
  293. ("value", c_char_p)
  294. ]
  295. # ------------------------------------------------------------------------------------------------------------
  296. # Host C++ -> Python variables
  297. class CarlaPluginInfo(Structure):
  298. _fields_ = [
  299. ("type", c_enum),
  300. ("category", c_enum),
  301. ("hints", c_uint),
  302. ("optionsAvailable", c_uint),
  303. ("optionsEnabled", c_uint),
  304. ("binary", c_char_p),
  305. ("name", c_char_p),
  306. ("label", c_char_p),
  307. ("maker", c_char_p),
  308. ("copyright", c_char_p),
  309. ("iconName", c_char_p),
  310. ("uniqueId", c_long),
  311. ("latency", c_uint32)
  312. ]
  313. class CarlaNativePluginInfo(Structure):
  314. _fields_ = [
  315. ("category", c_enum),
  316. ("hints", c_uint),
  317. ("audioIns", c_uint32),
  318. ("audioOuts", c_uint32),
  319. ("midiIns", c_uint32),
  320. ("midiOuts", c_uint32),
  321. ("parameterIns", c_uint32),
  322. ("parameterOuts", c_uint32),
  323. ("name", c_char_p),
  324. ("label", c_char_p),
  325. ("maker", c_char_p),
  326. ("copyright", c_char_p)
  327. ]
  328. class CarlaPortCountInfo(Structure):
  329. _fields_ = [
  330. ("ins", c_uint32),
  331. ("outs", c_uint32),
  332. ("total", c_uint32)
  333. ]
  334. class CarlaParameterInfo(Structure):
  335. _fields_ = [
  336. ("name", c_char_p),
  337. ("symbol", c_char_p),
  338. ("unit", c_char_p),
  339. ("scalePointCount", c_uint32)
  340. ]
  341. class CarlaScalePointInfo(Structure):
  342. _fields_ = [
  343. ("value", c_float),
  344. ("label", c_char_p)
  345. ]
  346. class CarlaTransportInfo(Structure):
  347. _fields_ = [
  348. ("playing", c_bool),
  349. ("frame", c_uint64),
  350. ("bar", c_int32),
  351. ("beat", c_int32),
  352. ("tick", c_int32),
  353. ("bpm", c_double)
  354. ]
  355. # ------------------------------------------------------------------------------------------------------------
  356. # Python object dicts compatible with ctypes struct
  357. PyParameterData = {
  358. 'type': PARAMETER_NULL,
  359. 'index': 0,
  360. 'rindex': -1,
  361. 'hints': 0x0,
  362. 'midiChannel': 0,
  363. 'midiCC': -1
  364. }
  365. PyParameterRanges = {
  366. 'def': 0.0,
  367. 'min': 0.0,
  368. 'max': 1.0,
  369. 'step': 0.0,
  370. 'stepSmall': 0.0,
  371. 'stepLarge': 0.0
  372. }
  373. PyMidiProgramData = {
  374. 'bank': 0,
  375. 'program': 0,
  376. 'name': None
  377. }
  378. PyCustomData = {
  379. 'type': None,
  380. 'key': None,
  381. 'value': None
  382. }
  383. PyCarlaPluginInfo = {
  384. 'type': PLUGIN_NONE,
  385. 'category': PLUGIN_CATEGORY_NONE,
  386. 'hints': 0x0,
  387. 'optionsAvailable': 0x0,
  388. 'optionsEnabled': 0x0,
  389. 'binary': None,
  390. 'name': None,
  391. 'label': None,
  392. 'maker': None,
  393. 'copyright': None,
  394. 'iconName': None,
  395. 'uniqueId': 0,
  396. 'latency': 0
  397. }
  398. PyCarlaPortCountInfo = {
  399. 'ins': 0,
  400. 'outs': 0,
  401. 'total': 0
  402. }
  403. PyCarlaParameterInfo = {
  404. 'name': None,
  405. 'symbol': None,
  406. 'unit': None,
  407. 'scalePointCount': 0,
  408. }
  409. PyCarlaScalePointInfo = {
  410. 'value': 0.0,
  411. 'label': None
  412. }
  413. # ------------------------------------------------------------------------------------------------------------
  414. # Host Python object (Control/Standalone)
  415. class Host(object):
  416. def __init__(self, libName):
  417. object.__init__(self)
  418. self.lib = cdll.LoadLibrary(libName)
  419. self.lib.carla_get_extended_license_text.argtypes = None
  420. self.lib.carla_get_extended_license_text.restype = c_char_p
  421. self.lib.carla_get_supported_file_types.argtypes = None
  422. self.lib.carla_get_supported_file_types.restype = c_char_p
  423. self.lib.carla_get_engine_driver_count.argtypes = None
  424. self.lib.carla_get_engine_driver_count.restype = c_uint
  425. self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
  426. self.lib.carla_get_engine_driver_name.restype = c_char_p
  427. self.lib.carla_get_engine_driver_device_names.argtypes = [c_uint]
  428. self.lib.carla_get_engine_driver_device_names.restype = POINTER(c_char_p)
  429. self.lib.carla_get_internal_plugin_count.argtypes = None
  430. self.lib.carla_get_internal_plugin_count.restype = c_uint
  431. self.lib.carla_get_internal_plugin_info.argtypes = [c_uint]
  432. self.lib.carla_get_internal_plugin_info.restype = POINTER(CarlaNativePluginInfo)
  433. self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p]
  434. self.lib.carla_engine_init.restype = c_bool
  435. self.lib.carla_engine_close.argtypes = None
  436. self.lib.carla_engine_close.restype = c_bool
  437. self.lib.carla_engine_idle.argtypes = None
  438. self.lib.carla_engine_idle.restype = None
  439. self.lib.carla_is_engine_running.argtypes = None
  440. self.lib.carla_is_engine_running.restype = c_bool
  441. self.lib.carla_set_engine_about_to_close.argtypes = None
  442. self.lib.carla_set_engine_about_to_close.restype = None
  443. self.lib.carla_set_engine_callback.argtypes = [CallbackFunc, c_void_p]
  444. self.lib.carla_set_engine_callback.restype = None
  445. self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
  446. self.lib.carla_set_engine_option.restype = None
  447. self.lib.carla_load_filename.argtypes = [c_char_p]
  448. self.lib.carla_load_filename.restype = c_bool
  449. self.lib.carla_load_project.argtypes = [c_char_p]
  450. self.lib.carla_load_project.restype = c_bool
  451. self.lib.carla_save_project.argtypes = [c_char_p]
  452. self.lib.carla_save_project.restype = c_bool
  453. self.lib.carla_patchbay_connect.argtypes = [c_int, c_int]
  454. self.lib.carla_patchbay_connect.restype = c_bool
  455. self.lib.carla_patchbay_disconnect.argtypes = [c_int]
  456. self.lib.carla_patchbay_disconnect.restype = c_bool
  457. self.lib.carla_patchbay_refresh.argtypes = None
  458. self.lib.carla_patchbay_refresh.restype = c_bool
  459. self.lib.carla_transport_play.argtypes = None
  460. self.lib.carla_transport_play.restype = None
  461. self.lib.carla_transport_pause.argtypes = None
  462. self.lib.carla_transport_pause.restype = None
  463. self.lib.carla_transport_relocate.argtypes = [c_uint32]
  464. self.lib.carla_transport_relocate.restype = None
  465. self.lib.carla_get_current_transport_frame.argtypes = None
  466. self.lib.carla_get_current_transport_frame.restype = c_uint64
  467. self.lib.carla_get_transport_info.argtypes = None
  468. self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)
  469. self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_void_p]
  470. self.lib.carla_add_plugin.restype = c_bool
  471. self.lib.carla_remove_plugin.argtypes = [c_uint]
  472. self.lib.carla_remove_plugin.restype = c_bool
  473. self.lib.carla_remove_all_plugins.argtypes = None
  474. self.lib.carla_remove_all_plugins.restype = c_bool
  475. self.lib.carla_rename_plugin.argtypes = [c_uint, c_char_p]
  476. self.lib.carla_rename_plugin.restype = c_char_p
  477. self.lib.carla_clone_plugin.argtypes = [c_uint]
  478. self.lib.carla_clone_plugin.restype = c_bool
  479. self.lib.carla_replace_plugin.argtypes = [c_uint]
  480. self.lib.carla_replace_plugin.restype = c_bool
  481. self.lib.carla_switch_plugins.argtypes = [c_uint, c_uint]
  482. self.lib.carla_switch_plugins.restype = c_bool
  483. self.lib.carla_load_plugin_state.argtypes = [c_uint, c_char_p]
  484. self.lib.carla_load_plugin_state.restype = c_bool
  485. self.lib.carla_save_plugin_state.argtypes = [c_uint, c_char_p]
  486. self.lib.carla_save_plugin_state.restype = c_bool
  487. self.lib.carla_get_plugin_info.argtypes = [c_uint]
  488. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  489. self.lib.carla_get_audio_port_count_info.argtypes = [c_uint]
  490. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  491. self.lib.carla_get_midi_port_count_info.argtypes = [c_uint]
  492. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  493. self.lib.carla_get_parameter_count_info.argtypes = [c_uint]
  494. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  495. self.lib.carla_get_parameter_info.argtypes = [c_uint, c_uint32]
  496. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  497. self.lib.carla_get_parameter_scalepoint_info.argtypes = [c_uint, c_uint32, c_uint32]
  498. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  499. self.lib.carla_get_parameter_data.argtypes = [c_uint, c_uint32]
  500. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  501. self.lib.carla_get_parameter_ranges.argtypes = [c_uint, c_uint32]
  502. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  503. self.lib.carla_get_midi_program_data.argtypes = [c_uint, c_uint32]
  504. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  505. self.lib.carla_get_custom_data.argtypes = [c_uint, c_uint32]
  506. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  507. self.lib.carla_get_chunk_data.argtypes = [c_uint]
  508. self.lib.carla_get_chunk_data.restype = c_char_p
  509. self.lib.carla_get_parameter_count.argtypes = [c_uint]
  510. self.lib.carla_get_parameter_count.restype = c_uint32
  511. self.lib.carla_get_program_count.argtypes = [c_uint]
  512. self.lib.carla_get_program_count.restype = c_uint32
  513. self.lib.carla_get_midi_program_count.argtypes = [c_uint]
  514. self.lib.carla_get_midi_program_count.restype = c_uint32
  515. self.lib.carla_get_custom_data_count.argtypes = [c_uint]
  516. self.lib.carla_get_custom_data_count.restype = c_uint32
  517. self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32]
  518. self.lib.carla_get_parameter_text.restype = c_char_p
  519. self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32]
  520. self.lib.carla_get_program_name.restype = c_char_p
  521. self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32]
  522. self.lib.carla_get_midi_program_name.restype = c_char_p
  523. self.lib.carla_get_real_plugin_name.argtypes = [c_uint]
  524. self.lib.carla_get_real_plugin_name.restype = c_char_p
  525. self.lib.carla_get_current_program_index.argtypes = [c_uint]
  526. self.lib.carla_get_current_program_index.restype = c_int32
  527. self.lib.carla_get_current_midi_program_index.argtypes = [c_uint]
  528. self.lib.carla_get_current_midi_program_index.restype = c_int32
  529. self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32]
  530. self.lib.carla_get_default_parameter_value.restype = c_float
  531. self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
  532. self.lib.carla_get_current_parameter_value.restype = c_float
  533. self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_ushort]
  534. self.lib.carla_get_input_peak_value.restype = c_float
  535. self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_ushort]
  536. self.lib.carla_get_output_peak_value.restype = c_float
  537. self.lib.carla_set_option.argtypes = [c_uint, c_uint, c_bool]
  538. self.lib.carla_set_option.restype = None
  539. self.lib.carla_set_active.argtypes = [c_uint, c_bool]
  540. self.lib.carla_set_active.restype = None
  541. self.lib.carla_set_drywet.argtypes = [c_uint, c_float]
  542. self.lib.carla_set_drywet.restype = None
  543. self.lib.carla_set_volume.argtypes = [c_uint, c_float]
  544. self.lib.carla_set_volume.restype = None
  545. self.lib.carla_set_balance_left.argtypes = [c_uint, c_float]
  546. self.lib.carla_set_balance_left.restype = None
  547. self.lib.carla_set_balance_right.argtypes = [c_uint, c_float]
  548. self.lib.carla_set_balance_right.restype = None
  549. self.lib.carla_set_panning.argtypes = [c_uint, c_float]
  550. self.lib.carla_set_panning.restype = None
  551. self.lib.carla_set_ctrl_channel.argtypes = [c_uint, c_int8]
  552. self.lib.carla_set_ctrl_channel.restype = None
  553. self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float]
  554. self.lib.carla_set_parameter_value.restype = None
  555. self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16]
  556. self.lib.carla_set_parameter_midi_cc.restype = None
  557. self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8]
  558. self.lib.carla_set_parameter_midi_channel.restype = None
  559. self.lib.carla_set_program.argtypes = [c_uint, c_uint32]
  560. self.lib.carla_set_program.restype = None
  561. self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32]
  562. self.lib.carla_set_midi_program.restype = None
  563. self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p]
  564. self.lib.carla_set_custom_data.restype = None
  565. self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p]
  566. self.lib.carla_set_chunk_data.restype = None
  567. self.lib.carla_prepare_for_save.argtypes = [c_uint]
  568. self.lib.carla_prepare_for_save.restype = None
  569. self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8]
  570. self.lib.carla_send_midi_note.restype = None
  571. self.lib.carla_show_gui.argtypes = [c_uint, c_bool]
  572. self.lib.carla_show_gui.restype = None
  573. self.lib.carla_get_buffer_size.argtypes = None
  574. self.lib.carla_get_buffer_size.restype = c_uint32
  575. self.lib.carla_get_sample_rate.argtypes = None
  576. self.lib.carla_get_sample_rate.restype = c_double
  577. self.lib.carla_get_last_error.argtypes = None
  578. self.lib.carla_get_last_error.restype = c_char_p
  579. self.lib.carla_get_host_osc_url_tcp.argtypes = None
  580. self.lib.carla_get_host_osc_url_tcp.restype = c_char_p
  581. self.lib.carla_get_host_osc_url_udp.argtypes = None
  582. self.lib.carla_get_host_osc_url_udp.restype = c_char_p
  583. self.lib.carla_nsm_announce.argtypes = [c_char_p, c_char_p, c_int]
  584. self.lib.carla_nsm_announce.restype = None
  585. self.lib.carla_nsm_ready.argtypes = None
  586. self.lib.carla_nsm_ready.restype = None
  587. self.lib.carla_nsm_reply_open.argtypes = None
  588. self.lib.carla_nsm_reply_open.restype = None
  589. self.lib.carla_nsm_reply_save.argtypes = None
  590. self.lib.carla_nsm_reply_save.restype = None
  591. def get_extended_license_text(self):
  592. return self.lib.carla_get_extended_license_text()
  593. def get_supported_file_types(self):
  594. return self.lib.carla_get_supported_file_types()
  595. def get_engine_driver_count(self):
  596. return self.lib.carla_get_engine_driver_count()
  597. def get_engine_driver_name(self, index):
  598. return self.lib.carla_get_engine_driver_name(index)
  599. def get_engine_driver_device_names(self, index):
  600. return charStringList(self.lib.carla_get_engine_driver_device_names(index))
  601. def get_internal_plugin_count(self):
  602. return self.lib.carla_get_internal_plugin_count()
  603. def get_internal_plugin_info(self, internalPluginId):
  604. return structToDict(self.lib.carla_get_internal_plugin_info(internalPluginId).contents)
  605. def engine_init(self, driverName, clientName):
  606. return self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8"))
  607. def engine_close(self):
  608. return self.lib.carla_engine_close()
  609. def engine_idle(self):
  610. self.lib.carla_engine_idle()
  611. def is_engine_running(self):
  612. return self.lib.carla_is_engine_running()
  613. def set_engine_about_to_close(self):
  614. self.lib.carla_set_engine_about_to_close()
  615. def set_engine_callback(self, func):
  616. self._callback = CallbackFunc(func)
  617. self.lib.carla_set_engine_callback(self._callback, c_nullptr)
  618. def set_engine_option(self, option, value, valueStr):
  619. self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))
  620. def load_filename(self, filename):
  621. return self.lib.carla_load_filename(filename.encode("utf-8"))
  622. def load_project(self, filename):
  623. return self.lib.carla_load_project(filename.encode("utf-8"))
  624. def save_project(self, filename):
  625. return self.lib.carla_save_project(filename.encode("utf-8"))
  626. def patchbay_connect(self, portIdA, portIdB):
  627. return self.lib.carla_patchbay_connect(portIdA, portIdB)
  628. def patchbay_disconnect(self, connectionId):
  629. return self.lib.carla_patchbay_disconnect(connectionId)
  630. def patchbay_refresh(self):
  631. return self.lib.carla_patchbay_refresh()
  632. def transport_play(self):
  633. self.lib.carla_transport_play()
  634. def transport_pause(self):
  635. self.lib.carla_transport_pause()
  636. def transport_relocate(self, frames):
  637. self.lib.carla_transport_relocate(frames)
  638. def get_current_transport_frame(self):
  639. return self.lib.carla_get_current_transport_frame()
  640. def get_transport_info(self):
  641. return structToDict(self.lib.carla_get_transport_info().contents)
  642. def add_plugin(self, btype, ptype, filename, name, label, extraStuff):
  643. cfilename = filename.encode("utf-8") if filename else c_nullptr
  644. cname = name.encode("utf-8") if name else c_nullptr
  645. clabel = label.encode("utf-8") if label else c_nullptr
  646. return self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, cast(extraStuff, c_void_p))
  647. def remove_plugin(self, pluginId):
  648. return self.lib.carla_remove_plugin(pluginId)
  649. def remove_all_plugins(self):
  650. return self.lib.carla_remove_all_plugins()
  651. def rename_plugin(self, pluginId, newName):
  652. return self.lib.carla_rename_plugin(pluginId, newName.encode("utf-8"))
  653. def clone_plugin(self, pluginId):
  654. return self.lib.carla_clone_plugin(pluginId)
  655. def replace_plugin(self, pluginId):
  656. return self.lib.carla_replace_plugin(pluginId)
  657. def switch_plugins(self, pluginIdA, pluginIdB):
  658. return self.lib.carla_switch_plugins(pluginIdA, pluginIdB)
  659. def load_plugin_state(self, pluginId, filename):
  660. return self.lib.carla_load_plugin_state(pluginId, filename.encode("utf-8"))
  661. def save_plugin_state(self, pluginId, filename):
  662. return self.lib.carla_save_plugin_state(pluginId, filename.encode("utf-8"))
  663. def get_plugin_info(self, pluginId):
  664. return structToDict(self.lib.carla_get_plugin_info(pluginId).contents)
  665. def get_audio_port_count_info(self, pluginId):
  666. return structToDict(self.lib.carla_get_audio_port_count_info(pluginId).contents)
  667. def get_midi_port_count_info(self, pluginId):
  668. return structToDict(self.lib.carla_get_midi_port_count_info(pluginId).contents)
  669. def get_parameter_count_info(self, pluginId):
  670. return structToDict(self.lib.carla_get_parameter_count_info(pluginId).contents)
  671. def get_parameter_info(self, pluginId, parameterId):
  672. return structToDict(self.lib.carla_get_parameter_info(pluginId, parameterId).contents)
  673. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  674. return structToDict(self.lib.carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId).contents)
  675. def get_parameter_data(self, pluginId, parameterId):
  676. return structToDict(self.lib.carla_get_parameter_data(pluginId, parameterId).contents)
  677. def get_parameter_ranges(self, pluginId, parameterId):
  678. return structToDict(self.lib.carla_get_parameter_ranges(pluginId, parameterId).contents)
  679. def get_midi_program_data(self, pluginId, midiProgramId):
  680. return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents)
  681. def get_custom_data(self, pluginId, customDataId):
  682. return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents)
  683. def get_chunk_data(self, pluginId):
  684. return self.lib.carla_get_chunk_data(pluginId)
  685. def get_parameter_count(self, pluginId):
  686. return self.lib.carla_get_parameter_count(pluginId)
  687. def get_program_count(self, pluginId):
  688. return self.lib.carla_get_program_count(pluginId)
  689. def get_midi_program_count(self, pluginId):
  690. return self.lib.carla_get_midi_program_count(pluginId)
  691. def get_custom_data_count(self, pluginId):
  692. return self.lib.carla_get_custom_data_count(pluginId)
  693. def get_parameter_text(self, pluginId, parameterId):
  694. return self.lib.carla_get_parameter_text(pluginId, parameterId)
  695. def get_program_name(self, pluginId, programId):
  696. return self.lib.carla_get_program_name(pluginId, programId)
  697. def get_midi_program_name(self, pluginId, midiProgramId):
  698. return self.lib.carla_get_midi_program_name(pluginId, midiProgramId)
  699. def get_real_plugin_name(self, pluginId):
  700. return self.lib.carla_get_real_plugin_name(pluginId)
  701. def get_current_program_index(self, pluginId):
  702. return self.lib.carla_get_current_program_index(pluginId)
  703. def get_current_midi_program_index(self, pluginId):
  704. return self.lib.carla_get_current_midi_program_index(pluginId)
  705. def get_default_parameter_value(self, pluginId, parameterId):
  706. return self.lib.carla_get_default_parameter_value(pluginId, parameterId)
  707. def get_current_parameter_value(self, pluginId, parameterId):
  708. return self.lib.carla_get_current_parameter_value(pluginId, parameterId)
  709. def get_input_peak_value(self, pluginId, portId):
  710. return self.lib.carla_get_input_peak_value(pluginId, portId)
  711. def get_output_peak_value(self, pluginId, portId):
  712. return self.lib.carla_get_output_peak_value(pluginId, portId)
  713. def set_option(self, pluginId, option, yesNo):
  714. self.lib.carla_set_option(pluginId, option, yesNo)
  715. def set_active(self, pluginId, onOff):
  716. self.lib.carla_set_active(pluginId, onOff)
  717. def set_drywet(self, pluginId, value):
  718. self.lib.carla_set_drywet(pluginId, value)
  719. def set_volume(self, pluginId, value):
  720. self.lib.carla_set_volume(pluginId, value)
  721. def set_balance_left(self, pluginId, value):
  722. self.lib.carla_set_balance_left(pluginId, value)
  723. def set_balance_right(self, pluginId, value):
  724. self.lib.carla_set_balance_right(pluginId, value)
  725. def set_panning(self, pluginId, value):
  726. self.lib.carla_set_panning(pluginId, value)
  727. def set_ctrl_channel(self, pluginId, channel):
  728. self.lib.carla_set_ctrl_channel(pluginId, channel)
  729. def set_parameter_value(self, pluginId, parameterId, value):
  730. self.lib.carla_set_parameter_value(pluginId, parameterId, value)
  731. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  732. self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc)
  733. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  734. self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel)
  735. def set_program(self, pluginId, programId):
  736. self.lib.carla_set_program(pluginId, programId)
  737. def set_midi_program(self, pluginId, midiProgramId):
  738. self.lib.carla_set_midi_program(pluginId, midiProgramId)
  739. def set_custom_data(self, pluginId, type_, key, value):
  740. self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8"))
  741. def set_chunk_data(self, pluginId, chunkData):
  742. self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8"))
  743. def prepare_for_save(self, pluginId):
  744. self.lib.carla_prepare_for_save(pluginId)
  745. def send_midi_note(self, pluginId, channel, note, velocity):
  746. self.lib.carla_send_midi_note(pluginId, channel, note, velocity)
  747. def show_gui(self, pluginId, yesNo):
  748. self.lib.carla_show_gui(pluginId, yesNo)
  749. def get_last_error(self):
  750. return self.lib.carla_get_last_error()
  751. def get_host_osc_url_tcp(self):
  752. return self.lib.carla_get_host_osc_url_tcp()
  753. def get_host_osc_url_udp(self):
  754. return self.lib.carla_get_host_osc_url_udp()
  755. def get_buffer_size(self):
  756. return self.lib.carla_get_buffer_size()
  757. def get_sample_rate(self):
  758. return self.lib.carla_get_sample_rate()
  759. def nsm_announce(self, url, appName_, pid):
  760. self.lib.carla_nsm_announce(url.encode("utf-8"), appName_.encode("utf-8"), pid)
  761. def nsm_ready(self):
  762. self.lib.carla_nsm_ready()
  763. def nsm_reply_open(self):
  764. self.lib.carla_nsm_reply_open()
  765. def nsm_reply_save(self):
  766. self.lib.carla_nsm_reply_save()