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.

998 lines
33KB

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