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.

988 lines
33KB

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