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.

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