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.

1035 lines
35KB

  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. # Engine Driver Hints
  77. ENGINE_DRIVER_HAS_CONTROL_PANEL = 0x1
  78. ENGINE_DRIVER_VARIABLE_BUFFER_SIZE = 0x2
  79. ENGINE_DRIVER_VARIABLE_SAMPLE_RATE = 0x4
  80. # Plugin Hints
  81. PLUGIN_IS_BRIDGE = 0x001
  82. PLUGIN_IS_RTSAFE = 0x002
  83. PLUGIN_IS_SYNTH = 0x004
  84. PLUGIN_HAS_GUI = 0x008
  85. PLUGIN_CAN_DRYWET = 0x010
  86. PLUGIN_CAN_VOLUME = 0x020
  87. PLUGIN_CAN_BALANCE = 0x040
  88. PLUGIN_CAN_PANNING = 0x080
  89. PLUGIN_NEEDS_FIXED_BUFFERS = 0x100
  90. PLUGIN_NEEDS_SINGLE_THREAD = 0x200
  91. # Plugin Options
  92. PLUGIN_OPTION_FIXED_BUFFERS = 0x001
  93. PLUGIN_OPTION_FORCE_STEREO = 0x002
  94. PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004
  95. PLUGIN_OPTION_USE_CHUNKS = 0x008
  96. PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010
  97. PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020
  98. PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040
  99. PLUGIN_OPTION_SEND_PITCHBEND = 0x080
  100. PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100
  101. # Parameter Hints
  102. PARAMETER_IS_BOOLEAN = 0x001
  103. PARAMETER_IS_INTEGER = 0x002
  104. PARAMETER_IS_LOGARITHMIC = 0x004
  105. PARAMETER_IS_ENABLED = 0x010
  106. PARAMETER_IS_AUTOMABLE = 0x020
  107. PARAMETER_IS_READ_ONLY = 0x040
  108. PARAMETER_USES_SAMPLERATE = 0x100
  109. PARAMETER_USES_SCALEPOINTS = 0x200
  110. PARAMETER_USES_CUSTOM_TEXT = 0x400
  111. # Custom Data Types
  112. CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"
  113. CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string"
  114. # Custom Data Keys
  115. CUSTOM_DATA_KEY_OPTIONS = "CarlaOptions"
  116. CUSTOM_DATA_KEY_UI_X = "CarlaUI:X"
  117. CUSTOM_DATA_KEY_UI_Y = "CarlaUI:Y"
  118. CUSTOM_DATA_KEY_UI_WIDTH = "CarlaUI:Width"
  119. CUSTOM_DATA_KEY_UI_HEIGHT = "CarlaUI:Height"
  120. CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUI:Visible"
  121. # Patchbay Port Hints
  122. PATCHBAY_PORT_IS_INPUT = 0x01
  123. PATCHBAY_PORT_IS_OUTPUT = 0x02
  124. PATCHBAY_PORT_IS_AUDIO = 0x10
  125. PATCHBAY_PORT_IS_CV = 0x20
  126. PATCHBAY_PORT_IS_MIDI = 0x40
  127. # Binary Type
  128. BINARY_NONE = 0
  129. BINARY_POSIX32 = 1
  130. BINARY_POSIX64 = 2
  131. BINARY_WIN32 = 3
  132. BINARY_WIN64 = 4
  133. BINARY_OTHER = 5
  134. # Plugin Type
  135. PLUGIN_NONE = 0
  136. PLUGIN_INTERNAL = 1
  137. PLUGIN_LADSPA = 2
  138. PLUGIN_DSSI = 3
  139. PLUGIN_LV2 = 4
  140. PLUGIN_VST = 5
  141. PLUGIN_AU = 6
  142. PLUGIN_CSOUND = 7
  143. PLUGIN_GIG = 8
  144. PLUGIN_SF2 = 9
  145. PLUGIN_SFZ = 10
  146. # Plugin Category
  147. PLUGIN_CATEGORY_NONE = 0
  148. PLUGIN_CATEGORY_SYNTH = 1
  149. PLUGIN_CATEGORY_DELAY = 2
  150. PLUGIN_CATEGORY_EQ = 3
  151. PLUGIN_CATEGORY_FILTER = 4
  152. PLUGIN_CATEGORY_DISTORTION = 5
  153. PLUGIN_CATEGORY_DYNAMICS = 6
  154. PLUGIN_CATEGORY_MODULATOR = 7
  155. PLUGIN_CATEGORY_UTILITY = 8
  156. PLUGIN_CATEGORY_OTHER = 9
  157. # Parameter Type
  158. PARAMETER_UNKNOWN = 0
  159. PARAMETER_INPUT = 1
  160. PARAMETER_OUTPUT = 2
  161. PARAMETER_SPECIAL = 3
  162. # Internal Parameters Index
  163. PARAMETER_NULL = -1
  164. PARAMETER_ACTIVE = -2
  165. PARAMETER_DRYWET = -3
  166. PARAMETER_VOLUME = -4
  167. PARAMETER_BALANCE_LEFT = -5
  168. PARAMETER_BALANCE_RIGHT = -6
  169. PARAMETER_PANNING = -7
  170. PARAMETER_CTRL_CHANNEL = -8
  171. PARAMETER_MAX = -9
  172. # Process Mode
  173. PROCESS_MODE_SINGLE_CLIENT = 0
  174. PROCESS_MODE_MULTIPLE_CLIENTS = 1
  175. PROCESS_MODE_CONTINUOUS_RACK = 2
  176. PROCESS_MODE_PATCHBAY = 3
  177. PROCESS_MODE_BRIDGE = 4
  178. # Transport Mode
  179. TRANSPORT_MODE_INTERNAL = 0
  180. TRANSPORT_MODE_JACK = 1
  181. TRANSPORT_MODE_PLUGIN = 2
  182. TRANSPORT_MODE_BRIDGE = 3
  183. # Engine Options Type
  184. ENGINE_OPTION_PROCESS_NAME = 0
  185. ENGINE_OPTION_PROCESS_MODE = 1
  186. ENGINE_OPTION_TRANSPORT_MODE = 2
  187. ENGINE_OPTION_FORCE_STEREO = 3
  188. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4
  189. ENGINE_OPTION_PREFER_UI_BRIDGES = 5
  190. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6
  191. ENGINE_OPTION_MAX_PARAMETERS = 7
  192. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8
  193. ENGINE_OPTION_AUDIO_NUM_PERIODS = 9
  194. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10
  195. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11
  196. ENGINE_OPTION_AUDIO_DEVICE = 12
  197. ENGINE_OPTION_PATH_RESOURCES = 13
  198. ENGINE_OPTION_PATH_BRIDGE_NATIVE = 14
  199. ENGINE_OPTION_PATH_BRIDGE_POSIX32 = 15
  200. ENGINE_OPTION_PATH_BRIDGE_POSIX64 = 16
  201. ENGINE_OPTION_PATH_BRIDGE_WIN32 = 17
  202. ENGINE_OPTION_PATH_BRIDGE_WIN64 = 18
  203. ENGINE_OPTION_PATH_BRIDGE_LV2_EXTERNAL = 19
  204. ENGINE_OPTION_PATH_BRIDGE_LV2_GTK2 = 20
  205. ENGINE_OPTION_PATH_BRIDGE_LV2_GTK3 = 21
  206. ENGINE_OPTION_PATH_BRIDGE_LV2_NTK = 22
  207. ENGINE_OPTION_PATH_BRIDGE_LV2_QT4 = 23
  208. ENGINE_OPTION_PATH_BRIDGE_LV2_QT5 = 24
  209. ENGINE_OPTION_PATH_BRIDGE_LV2_COCOA = 25
  210. ENGINE_OPTION_PATH_BRIDGE_LV2_WINDOWS = 26
  211. ENGINE_OPTION_PATH_BRIDGE_LV2_X11 = 27
  212. ENGINE_OPTION_PATH_BRIDGE_VST_MAC = 28
  213. ENGINE_OPTION_PATH_BRIDGE_VST_HWND = 29
  214. ENGINE_OPTION_PATH_BRIDGE_VST_X11 = 30
  215. # Engine Callback Type
  216. ENGINE_CALLBACK_DEBUG = 0
  217. ENGINE_CALLBACK_PLUGIN_ADDED = 1
  218. ENGINE_CALLBACK_PLUGIN_REMOVED = 2
  219. ENGINE_CALLBACK_PLUGIN_RENAMED = 3
  220. ENGINE_CALLBACK_PLUGIN_DISABLED = 4
  221. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5
  222. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6
  223. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 7
  224. ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED = 8
  225. ENGINE_CALLBACK_PROGRAM_CHANGED = 9
  226. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 10
  227. ENGINE_CALLBACK_UI_STATE_CHANGED = 11
  228. ENGINE_CALLBACK_NOTE_ON = 12
  229. ENGINE_CALLBACK_NOTE_OFF = 13
  230. ENGINE_CALLBACK_UPDATE = 14
  231. ENGINE_CALLBACK_RELOAD_INFO = 15
  232. ENGINE_CALLBACK_RELOAD_PARAMETERS = 16
  233. ENGINE_CALLBACK_RELOAD_PROGRAMS = 17
  234. ENGINE_CALLBACK_RELOAD_ALL = 18
  235. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 19
  236. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 20
  237. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 21
  238. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 22
  239. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 23
  240. ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 24
  241. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 25
  242. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 26
  243. ENGINE_CALLBACK_PATCHBAY_ICON_CHANGED = 27
  244. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 28
  245. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 29
  246. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 30
  247. ENGINE_CALLBACK_ENGINE_STARTED = 31
  248. ENGINE_CALLBACK_ENGINE_STOPPED = 32
  249. ENGINE_CALLBACK_NSM_ANNOUNCE = 33
  250. ENGINE_CALLBACK_NSM_OPEN = 34
  251. ENGINE_CALLBACK_NSM_SAVE = 35
  252. ENGINE_CALLBACK_INFO = 36
  253. ENGINE_CALLBACK_ERROR = 37
  254. ENGINE_CALLBACK_QUIT = 38
  255. # File Callback Type
  256. FILE_CALLBACK_DEBUG = 0
  257. FILE_CALLBACK_OPEN = 1
  258. FILE_CALLBACK_SAVE = 2
  259. # Set BINARY_NATIVE
  260. if HAIKU or LINUX or MACOS:
  261. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  262. elif WINDOWS:
  263. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  264. else:
  265. BINARY_NATIVE = BINARY_OTHER
  266. # ------------------------------------------------------------------------------------------------------------
  267. # Backend C++ -> Python variables
  268. c_enum = c_int
  269. c_nullptr = None
  270. EngineCallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_float, c_char_p)
  271. FileCallbackFunc = CFUNCTYPE(c_char_p, c_void_p, c_enum, c_bool, c_char_p, c_char_p)
  272. class ParameterData(Structure):
  273. _fields_ = [
  274. ("type", c_enum),
  275. ("index", c_int32),
  276. ("rindex", c_int32),
  277. ("hints", c_uint),
  278. ("midiChannel", c_uint8),
  279. ("midiCC", c_int16)
  280. ]
  281. class ParameterRanges(Structure):
  282. _fields_ = [
  283. ("def", c_float),
  284. ("min", c_float),
  285. ("max", c_float),
  286. ("step", c_float),
  287. ("stepSmall", c_float),
  288. ("stepLarge", c_float)
  289. ]
  290. class MidiProgramData(Structure):
  291. _fields_ = [
  292. ("bank", c_uint32),
  293. ("program", c_uint32),
  294. ("name", c_char_p)
  295. ]
  296. class CustomData(Structure):
  297. _fields_ = [
  298. ("type", c_char_p),
  299. ("key", c_char_p),
  300. ("value", c_char_p)
  301. ]
  302. class EngineDriverDeviceInfo(Structure):
  303. _fields_ = [
  304. ("hints", c_uint),
  305. ("bufferSizes", POINTER(c_uint32)),
  306. ("sampleRates", POINTER(c_double))
  307. ]
  308. # ------------------------------------------------------------------------------------------------------------
  309. # Host C++ -> Python variables
  310. class CarlaPluginInfo(Structure):
  311. _fields_ = [
  312. ("type", c_enum),
  313. ("category", c_enum),
  314. ("hints", c_uint),
  315. ("optionsAvailable", c_uint),
  316. ("optionsEnabled", c_uint),
  317. ("binary", c_char_p),
  318. ("name", c_char_p),
  319. ("label", c_char_p),
  320. ("maker", c_char_p),
  321. ("copyright", c_char_p),
  322. ("iconName", c_char_p),
  323. ("patchbayClientId", c_int),
  324. ("uniqueId", c_long)
  325. ]
  326. class CarlaNativePluginInfo(Structure):
  327. _fields_ = [
  328. ("category", c_enum),
  329. ("hints", c_uint),
  330. ("audioIns", c_uint32),
  331. ("audioOuts", c_uint32),
  332. ("midiIns", c_uint32),
  333. ("midiOuts", c_uint32),
  334. ("parameterIns", c_uint32),
  335. ("parameterOuts", c_uint32),
  336. ("name", c_char_p),
  337. ("label", c_char_p),
  338. ("maker", c_char_p),
  339. ("copyright", c_char_p)
  340. ]
  341. class CarlaPortCountInfo(Structure):
  342. _fields_ = [
  343. ("ins", c_uint32),
  344. ("outs", c_uint32),
  345. ("total", c_uint32)
  346. ]
  347. class CarlaParameterInfo(Structure):
  348. _fields_ = [
  349. ("name", c_char_p),
  350. ("symbol", c_char_p),
  351. ("unit", c_char_p),
  352. ("scalePointCount", c_uint32)
  353. ]
  354. class CarlaScalePointInfo(Structure):
  355. _fields_ = [
  356. ("value", c_float),
  357. ("label", c_char_p)
  358. ]
  359. class CarlaTransportInfo(Structure):
  360. _fields_ = [
  361. ("playing", c_bool),
  362. ("frame", c_uint64),
  363. ("bar", c_int32),
  364. ("beat", c_int32),
  365. ("tick", c_int32),
  366. ("bpm", c_double)
  367. ]
  368. # ------------------------------------------------------------------------------------------------------------
  369. # Python object dicts compatible with ctypes struct
  370. PyParameterData = {
  371. 'type': PARAMETER_NULL,
  372. 'index': PARAMETER_NULL,
  373. 'rindex': -1,
  374. 'hints': 0x0,
  375. 'midiChannel': 0,
  376. 'midiCC': -1
  377. }
  378. PyParameterRanges = {
  379. 'def': 0.0,
  380. 'min': 0.0,
  381. 'max': 1.0,
  382. 'step': 0.01,
  383. 'stepSmall': 0.0001,
  384. 'stepLarge': 0.1
  385. }
  386. PyMidiProgramData = {
  387. 'bank': 0,
  388. 'program': 0,
  389. 'name': None
  390. }
  391. PyCustomData = {
  392. 'type': None,
  393. 'key': None,
  394. 'value': None
  395. }
  396. PyCarlaPluginInfo = {
  397. 'type': PLUGIN_NONE,
  398. 'category': PLUGIN_CATEGORY_NONE,
  399. 'hints': 0x0,
  400. 'optionsAvailable': 0x0,
  401. 'optionsEnabled': 0x0,
  402. 'binary': None,
  403. 'name': None,
  404. 'label': None,
  405. 'maker': None,
  406. 'copyright': None,
  407. 'iconName': None,
  408. 'patchbayClientId': 0,
  409. 'uniqueId': 0
  410. }
  411. PyCarlaPortCountInfo = {
  412. 'ins': 0,
  413. 'outs': 0,
  414. 'total': 0
  415. }
  416. PyCarlaParameterInfo = {
  417. 'name': None,
  418. 'symbol': None,
  419. 'unit': None,
  420. 'scalePointCount': 0,
  421. }
  422. PyCarlaScalePointInfo = {
  423. 'value': 0.0,
  424. 'label': None
  425. }
  426. PyCarlaTransportInfo = {
  427. "playing": False,
  428. "frame": 0,
  429. "bar": 0,
  430. "beat": 0,
  431. "tick": 0,
  432. "bpm": 0.0
  433. }
  434. PyCarlaEngineDriverInfo = {
  435. "name": None,
  436. "hints": 0x0
  437. }
  438. # ------------------------------------------------------------------------------------------------------------
  439. # Host Python object (Control/Standalone)
  440. class Host(object):
  441. def __init__(self, libName):
  442. object.__init__(self)
  443. self.lib = cdll.LoadLibrary(libName)
  444. self.lib.carla_get_extended_license_text.argtypes = None
  445. self.lib.carla_get_extended_license_text.restype = c_char_p
  446. self.lib.carla_get_supported_file_types.argtypes = None
  447. self.lib.carla_get_supported_file_types.restype = c_char_p
  448. self.lib.carla_get_engine_driver_count.argtypes = None
  449. self.lib.carla_get_engine_driver_count.restype = c_uint
  450. self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
  451. self.lib.carla_get_engine_driver_name.restype = c_char_p
  452. self.lib.carla_get_engine_driver_device_names.argtypes = [c_uint]
  453. self.lib.carla_get_engine_driver_device_names.restype = POINTER(c_char_p)
  454. self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p]
  455. self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo)
  456. self.lib.carla_get_internal_plugin_count.argtypes = None
  457. self.lib.carla_get_internal_plugin_count.restype = c_uint
  458. self.lib.carla_get_internal_plugin_info.argtypes = [c_uint]
  459. self.lib.carla_get_internal_plugin_info.restype = POINTER(CarlaNativePluginInfo)
  460. self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p]
  461. self.lib.carla_engine_init.restype = c_bool
  462. self.lib.carla_engine_close.argtypes = None
  463. self.lib.carla_engine_close.restype = c_bool
  464. self.lib.carla_engine_idle.argtypes = None
  465. self.lib.carla_engine_idle.restype = None
  466. self.lib.carla_is_engine_running.argtypes = None
  467. self.lib.carla_is_engine_running.restype = c_bool
  468. self.lib.carla_set_engine_about_to_close.argtypes = None
  469. self.lib.carla_set_engine_about_to_close.restype = None
  470. self.lib.carla_set_engine_callback.argtypes = [EngineCallbackFunc, c_void_p]
  471. self.lib.carla_set_engine_callback.restype = None
  472. self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
  473. self.lib.carla_set_engine_option.restype = None
  474. self.lib.carla_load_filename.argtypes = [c_char_p]
  475. self.lib.carla_load_filename.restype = c_bool
  476. self.lib.carla_load_project.argtypes = [c_char_p]
  477. self.lib.carla_load_project.restype = c_bool
  478. self.lib.carla_save_project.argtypes = [c_char_p]
  479. self.lib.carla_save_project.restype = c_bool
  480. self.lib.carla_patchbay_connect.argtypes = [c_int, c_int]
  481. self.lib.carla_patchbay_connect.restype = c_bool
  482. self.lib.carla_patchbay_disconnect.argtypes = [c_int]
  483. self.lib.carla_patchbay_disconnect.restype = c_bool
  484. self.lib.carla_patchbay_refresh.argtypes = None
  485. self.lib.carla_patchbay_refresh.restype = c_bool
  486. self.lib.carla_transport_play.argtypes = None
  487. self.lib.carla_transport_play.restype = None
  488. self.lib.carla_transport_pause.argtypes = None
  489. self.lib.carla_transport_pause.restype = None
  490. self.lib.carla_transport_relocate.argtypes = [c_uint32]
  491. self.lib.carla_transport_relocate.restype = None
  492. self.lib.carla_get_current_transport_frame.argtypes = None
  493. self.lib.carla_get_current_transport_frame.restype = c_uint64
  494. self.lib.carla_get_transport_info.argtypes = None
  495. self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)
  496. self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_void_p]
  497. self.lib.carla_add_plugin.restype = c_bool
  498. self.lib.carla_remove_plugin.argtypes = [c_uint]
  499. self.lib.carla_remove_plugin.restype = c_bool
  500. self.lib.carla_remove_all_plugins.argtypes = None
  501. self.lib.carla_remove_all_plugins.restype = c_bool
  502. self.lib.carla_rename_plugin.argtypes = [c_uint, c_char_p]
  503. self.lib.carla_rename_plugin.restype = c_char_p
  504. self.lib.carla_clone_plugin.argtypes = [c_uint]
  505. self.lib.carla_clone_plugin.restype = c_bool
  506. self.lib.carla_replace_plugin.argtypes = [c_uint]
  507. self.lib.carla_replace_plugin.restype = c_bool
  508. self.lib.carla_switch_plugins.argtypes = [c_uint, c_uint]
  509. self.lib.carla_switch_plugins.restype = c_bool
  510. self.lib.carla_load_plugin_state.argtypes = [c_uint, c_char_p]
  511. self.lib.carla_load_plugin_state.restype = c_bool
  512. self.lib.carla_save_plugin_state.argtypes = [c_uint, c_char_p]
  513. self.lib.carla_save_plugin_state.restype = c_bool
  514. self.lib.carla_get_plugin_info.argtypes = [c_uint]
  515. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  516. self.lib.carla_get_audio_port_count_info.argtypes = [c_uint]
  517. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  518. self.lib.carla_get_midi_port_count_info.argtypes = [c_uint]
  519. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  520. self.lib.carla_get_parameter_count_info.argtypes = [c_uint]
  521. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  522. self.lib.carla_get_parameter_info.argtypes = [c_uint, c_uint32]
  523. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  524. self.lib.carla_get_parameter_scalepoint_info.argtypes = [c_uint, c_uint32, c_uint32]
  525. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  526. self.lib.carla_get_parameter_data.argtypes = [c_uint, c_uint32]
  527. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  528. self.lib.carla_get_parameter_ranges.argtypes = [c_uint, c_uint32]
  529. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  530. self.lib.carla_get_midi_program_data.argtypes = [c_uint, c_uint32]
  531. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  532. self.lib.carla_get_custom_data.argtypes = [c_uint, c_uint32]
  533. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  534. self.lib.carla_get_chunk_data.argtypes = [c_uint]
  535. self.lib.carla_get_chunk_data.restype = c_char_p
  536. self.lib.carla_get_parameter_count.argtypes = [c_uint]
  537. self.lib.carla_get_parameter_count.restype = c_uint32
  538. self.lib.carla_get_program_count.argtypes = [c_uint]
  539. self.lib.carla_get_program_count.restype = c_uint32
  540. self.lib.carla_get_midi_program_count.argtypes = [c_uint]
  541. self.lib.carla_get_midi_program_count.restype = c_uint32
  542. self.lib.carla_get_custom_data_count.argtypes = [c_uint]
  543. self.lib.carla_get_custom_data_count.restype = c_uint32
  544. self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32]
  545. self.lib.carla_get_parameter_text.restype = c_char_p
  546. self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32]
  547. self.lib.carla_get_program_name.restype = c_char_p
  548. self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32]
  549. self.lib.carla_get_midi_program_name.restype = c_char_p
  550. self.lib.carla_get_real_plugin_name.argtypes = [c_uint]
  551. self.lib.carla_get_real_plugin_name.restype = c_char_p
  552. self.lib.carla_get_current_program_index.argtypes = [c_uint]
  553. self.lib.carla_get_current_program_index.restype = c_int32
  554. self.lib.carla_get_current_midi_program_index.argtypes = [c_uint]
  555. self.lib.carla_get_current_midi_program_index.restype = c_int32
  556. self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32]
  557. self.lib.carla_get_default_parameter_value.restype = c_float
  558. self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
  559. self.lib.carla_get_current_parameter_value.restype = c_float
  560. self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_ushort]
  561. self.lib.carla_get_input_peak_value.restype = c_float
  562. self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_ushort]
  563. self.lib.carla_get_output_peak_value.restype = c_float
  564. self.lib.carla_set_option.argtypes = [c_uint, c_uint, c_bool]
  565. self.lib.carla_set_option.restype = None
  566. self.lib.carla_set_active.argtypes = [c_uint, c_bool]
  567. self.lib.carla_set_active.restype = None
  568. self.lib.carla_set_drywet.argtypes = [c_uint, c_float]
  569. self.lib.carla_set_drywet.restype = None
  570. self.lib.carla_set_volume.argtypes = [c_uint, c_float]
  571. self.lib.carla_set_volume.restype = None
  572. self.lib.carla_set_balance_left.argtypes = [c_uint, c_float]
  573. self.lib.carla_set_balance_left.restype = None
  574. self.lib.carla_set_balance_right.argtypes = [c_uint, c_float]
  575. self.lib.carla_set_balance_right.restype = None
  576. self.lib.carla_set_panning.argtypes = [c_uint, c_float]
  577. self.lib.carla_set_panning.restype = None
  578. self.lib.carla_set_ctrl_channel.argtypes = [c_uint, c_int8]
  579. self.lib.carla_set_ctrl_channel.restype = None
  580. self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float]
  581. self.lib.carla_set_parameter_value.restype = None
  582. self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16]
  583. self.lib.carla_set_parameter_midi_cc.restype = None
  584. self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8]
  585. self.lib.carla_set_parameter_midi_channel.restype = None
  586. self.lib.carla_set_program.argtypes = [c_uint, c_uint32]
  587. self.lib.carla_set_program.restype = None
  588. self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32]
  589. self.lib.carla_set_midi_program.restype = None
  590. self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p]
  591. self.lib.carla_set_custom_data.restype = None
  592. self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p]
  593. self.lib.carla_set_chunk_data.restype = None
  594. self.lib.carla_prepare_for_save.argtypes = [c_uint]
  595. self.lib.carla_prepare_for_save.restype = None
  596. self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8]
  597. self.lib.carla_send_midi_note.restype = None
  598. self.lib.carla_show_gui.argtypes = [c_uint, c_bool]
  599. self.lib.carla_show_gui.restype = None
  600. self.lib.carla_get_buffer_size.argtypes = None
  601. self.lib.carla_get_buffer_size.restype = c_uint32
  602. self.lib.carla_get_sample_rate.argtypes = None
  603. self.lib.carla_get_sample_rate.restype = c_double
  604. self.lib.carla_get_last_error.argtypes = None
  605. self.lib.carla_get_last_error.restype = c_char_p
  606. self.lib.carla_get_host_osc_url_tcp.argtypes = None
  607. self.lib.carla_get_host_osc_url_tcp.restype = c_char_p
  608. self.lib.carla_get_host_osc_url_udp.argtypes = None
  609. self.lib.carla_get_host_osc_url_udp.restype = c_char_p
  610. self.lib.carla_nsm_announce.argtypes = [c_char_p, c_char_p, c_int]
  611. self.lib.carla_nsm_announce.restype = None
  612. self.lib.carla_nsm_ready.argtypes = None
  613. self.lib.carla_nsm_ready.restype = None
  614. self.lib.carla_nsm_reply_open.argtypes = None
  615. self.lib.carla_nsm_reply_open.restype = None
  616. self.lib.carla_nsm_reply_save.argtypes = None
  617. self.lib.carla_nsm_reply_save.restype = None
  618. def get_extended_license_text(self):
  619. return self.lib.carla_get_extended_license_text()
  620. def get_supported_file_types(self):
  621. return self.lib.carla_get_supported_file_types()
  622. def get_engine_driver_count(self):
  623. return self.lib.carla_get_engine_driver_count()
  624. def get_engine_driver_name(self, index):
  625. return self.lib.carla_get_engine_driver_name(index)
  626. def get_engine_driver_device_names(self, index):
  627. return charStringList(self.lib.carla_get_engine_driver_device_names(index))
  628. def get_engine_driver_device_info(self, index, deviceName):
  629. return structToDict(self.lib.carla_get_engine_driver_device_info(index, deviceName))
  630. def get_internal_plugin_count(self):
  631. return self.lib.carla_get_internal_plugin_count()
  632. def get_internal_plugin_info(self, internalPluginId):
  633. return structToDict(self.lib.carla_get_internal_plugin_info(internalPluginId).contents)
  634. def engine_init(self, driverName, clientName):
  635. return self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8"))
  636. def engine_close(self):
  637. return self.lib.carla_engine_close()
  638. def engine_idle(self):
  639. self.lib.carla_engine_idle()
  640. def is_engine_running(self):
  641. return self.lib.carla_is_engine_running()
  642. def set_engine_about_to_close(self):
  643. self.lib.carla_set_engine_about_to_close()
  644. def set_engine_callback(self, func):
  645. self._callback = CallbackFunc(func)
  646. self.lib.carla_set_engine_callback(self._callback, c_nullptr)
  647. def set_engine_option(self, option, value, valueStr):
  648. self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))
  649. def load_filename(self, filename):
  650. return self.lib.carla_load_filename(filename.encode("utf-8"))
  651. def load_project(self, filename):
  652. return self.lib.carla_load_project(filename.encode("utf-8"))
  653. def save_project(self, filename):
  654. return self.lib.carla_save_project(filename.encode("utf-8"))
  655. def patchbay_connect(self, portIdA, portIdB):
  656. return self.lib.carla_patchbay_connect(portIdA, portIdB)
  657. def patchbay_disconnect(self, connectionId):
  658. return self.lib.carla_patchbay_disconnect(connectionId)
  659. def patchbay_refresh(self):
  660. return self.lib.carla_patchbay_refresh()
  661. def transport_play(self):
  662. self.lib.carla_transport_play()
  663. def transport_pause(self):
  664. self.lib.carla_transport_pause()
  665. def transport_relocate(self, frames):
  666. self.lib.carla_transport_relocate(frames)
  667. def get_current_transport_frame(self):
  668. return self.lib.carla_get_current_transport_frame()
  669. def get_transport_info(self):
  670. return structToDict(self.lib.carla_get_transport_info().contents)
  671. def add_plugin(self, btype, ptype, filename, name, label, extraStuff):
  672. cfilename = filename.encode("utf-8") if filename else c_nullptr
  673. cname = name.encode("utf-8") if name else c_nullptr
  674. clabel = label.encode("utf-8") if label else c_nullptr
  675. return self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, cast(extraStuff, c_void_p))
  676. def remove_plugin(self, pluginId):
  677. return self.lib.carla_remove_plugin(pluginId)
  678. def remove_all_plugins(self):
  679. return self.lib.carla_remove_all_plugins()
  680. def rename_plugin(self, pluginId, newName):
  681. return self.lib.carla_rename_plugin(pluginId, newName.encode("utf-8"))
  682. def clone_plugin(self, pluginId):
  683. return self.lib.carla_clone_plugin(pluginId)
  684. def replace_plugin(self, pluginId):
  685. return self.lib.carla_replace_plugin(pluginId)
  686. def switch_plugins(self, pluginIdA, pluginIdB):
  687. return self.lib.carla_switch_plugins(pluginIdA, pluginIdB)
  688. def load_plugin_state(self, pluginId, filename):
  689. return self.lib.carla_load_plugin_state(pluginId, filename.encode("utf-8"))
  690. def save_plugin_state(self, pluginId, filename):
  691. return self.lib.carla_save_plugin_state(pluginId, filename.encode("utf-8"))
  692. def get_plugin_info(self, pluginId):
  693. return structToDict(self.lib.carla_get_plugin_info(pluginId).contents)
  694. def get_audio_port_count_info(self, pluginId):
  695. return structToDict(self.lib.carla_get_audio_port_count_info(pluginId).contents)
  696. def get_midi_port_count_info(self, pluginId):
  697. return structToDict(self.lib.carla_get_midi_port_count_info(pluginId).contents)
  698. def get_parameter_count_info(self, pluginId):
  699. return structToDict(self.lib.carla_get_parameter_count_info(pluginId).contents)
  700. def get_parameter_info(self, pluginId, parameterId):
  701. return structToDict(self.lib.carla_get_parameter_info(pluginId, parameterId).contents)
  702. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  703. return structToDict(self.lib.carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId).contents)
  704. def get_parameter_data(self, pluginId, parameterId):
  705. return structToDict(self.lib.carla_get_parameter_data(pluginId, parameterId).contents)
  706. def get_parameter_ranges(self, pluginId, parameterId):
  707. return structToDict(self.lib.carla_get_parameter_ranges(pluginId, parameterId).contents)
  708. def get_midi_program_data(self, pluginId, midiProgramId):
  709. return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents)
  710. def get_custom_data(self, pluginId, customDataId):
  711. return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents)
  712. def get_chunk_data(self, pluginId):
  713. return self.lib.carla_get_chunk_data(pluginId)
  714. def get_parameter_count(self, pluginId):
  715. return self.lib.carla_get_parameter_count(pluginId)
  716. def get_program_count(self, pluginId):
  717. return self.lib.carla_get_program_count(pluginId)
  718. def get_midi_program_count(self, pluginId):
  719. return self.lib.carla_get_midi_program_count(pluginId)
  720. def get_custom_data_count(self, pluginId):
  721. return self.lib.carla_get_custom_data_count(pluginId)
  722. def get_parameter_text(self, pluginId, parameterId):
  723. return self.lib.carla_get_parameter_text(pluginId, parameterId)
  724. def get_program_name(self, pluginId, programId):
  725. return self.lib.carla_get_program_name(pluginId, programId)
  726. def get_midi_program_name(self, pluginId, midiProgramId):
  727. return self.lib.carla_get_midi_program_name(pluginId, midiProgramId)
  728. def get_real_plugin_name(self, pluginId):
  729. return self.lib.carla_get_real_plugin_name(pluginId)
  730. def get_current_program_index(self, pluginId):
  731. return self.lib.carla_get_current_program_index(pluginId)
  732. def get_current_midi_program_index(self, pluginId):
  733. return self.lib.carla_get_current_midi_program_index(pluginId)
  734. def get_default_parameter_value(self, pluginId, parameterId):
  735. return self.lib.carla_get_default_parameter_value(pluginId, parameterId)
  736. def get_current_parameter_value(self, pluginId, parameterId):
  737. return self.lib.carla_get_current_parameter_value(pluginId, parameterId)
  738. def get_input_peak_value(self, pluginId, portId):
  739. return self.lib.carla_get_input_peak_value(pluginId, portId)
  740. def get_output_peak_value(self, pluginId, portId):
  741. return self.lib.carla_get_output_peak_value(pluginId, portId)
  742. def set_option(self, pluginId, option, yesNo):
  743. self.lib.carla_set_option(pluginId, option, yesNo)
  744. def set_active(self, pluginId, onOff):
  745. self.lib.carla_set_active(pluginId, onOff)
  746. def set_drywet(self, pluginId, value):
  747. self.lib.carla_set_drywet(pluginId, value)
  748. def set_volume(self, pluginId, value):
  749. self.lib.carla_set_volume(pluginId, value)
  750. def set_balance_left(self, pluginId, value):
  751. self.lib.carla_set_balance_left(pluginId, value)
  752. def set_balance_right(self, pluginId, value):
  753. self.lib.carla_set_balance_right(pluginId, value)
  754. def set_panning(self, pluginId, value):
  755. self.lib.carla_set_panning(pluginId, value)
  756. def set_ctrl_channel(self, pluginId, channel):
  757. self.lib.carla_set_ctrl_channel(pluginId, channel)
  758. def set_parameter_value(self, pluginId, parameterId, value):
  759. self.lib.carla_set_parameter_value(pluginId, parameterId, value)
  760. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  761. self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc)
  762. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  763. self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel)
  764. def set_program(self, pluginId, programId):
  765. self.lib.carla_set_program(pluginId, programId)
  766. def set_midi_program(self, pluginId, midiProgramId):
  767. self.lib.carla_set_midi_program(pluginId, midiProgramId)
  768. def set_custom_data(self, pluginId, type_, key, value):
  769. self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8"))
  770. def set_chunk_data(self, pluginId, chunkData):
  771. self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8"))
  772. def prepare_for_save(self, pluginId):
  773. self.lib.carla_prepare_for_save(pluginId)
  774. def send_midi_note(self, pluginId, channel, note, velocity):
  775. self.lib.carla_send_midi_note(pluginId, channel, note, velocity)
  776. def show_gui(self, pluginId, yesNo):
  777. self.lib.carla_show_gui(pluginId, yesNo)
  778. def get_last_error(self):
  779. return self.lib.carla_get_last_error()
  780. def get_host_osc_url_tcp(self):
  781. return self.lib.carla_get_host_osc_url_tcp()
  782. def get_host_osc_url_udp(self):
  783. return self.lib.carla_get_host_osc_url_udp()
  784. def get_buffer_size(self):
  785. return self.lib.carla_get_buffer_size()
  786. def get_sample_rate(self):
  787. return self.lib.carla_get_sample_rate()
  788. def nsm_announce(self, url, appName_, pid):
  789. self.lib.carla_nsm_announce(url.encode("utf-8"), appName_.encode("utf-8"), pid)
  790. def nsm_ready(self):
  791. self.lib.carla_nsm_ready()
  792. def nsm_reply_open(self):
  793. self.lib.carla_nsm_reply_open()
  794. def nsm_reply_save(self):
  795. self.lib.carla_nsm_reply_save()