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.

926 lines
32KB

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