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.

849 lines
29KB

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