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.

1705 lines
53KB

  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. # Define enum type (integer)
  27. c_enum = c_int
  28. # ------------------------------------------------------------------------------------------------------------
  29. # Set Platform
  30. if platform == "darwin":
  31. HAIKU = False
  32. LINUX = False
  33. MACOS = True
  34. WINDOWS = False
  35. elif "haiku" in platform:
  36. HAIKU = True
  37. LINUX = False
  38. MACOS = False
  39. WINDOWS = False
  40. elif "linux" in platform:
  41. HAIKU = False
  42. LINUX = True
  43. MACOS = False
  44. WINDOWS = False
  45. elif platform in ("win32", "win64", "cygwin"):
  46. HAIKU = False
  47. LINUX = False
  48. MACOS = False
  49. WINDOWS = True
  50. else:
  51. HAIKU = False
  52. LINUX = False
  53. MACOS = False
  54. WINDOWS = False
  55. # ------------------------------------------------------------------------------------------------------------
  56. # Convert a ctypes c_char_p into a python string
  57. def charPtrToString(value):
  58. if not value:
  59. return ""
  60. if isinstance(value, str):
  61. return value
  62. return value.decode("utf-8", errors="ignore")
  63. # ------------------------------------------------------------------------------------------------------------
  64. # Convert a ctypes POINTER(c_char_p) into a python string list
  65. def charPtrPtrToStringList(charPtrPtr):
  66. if not charPtrPtr:
  67. return []
  68. i = 0
  69. charPtr = charPtrPtr[0]
  70. strList = []
  71. while charPtr:
  72. strList.append(charPtr.decode("utf-8", errors="ignore"))
  73. i += 1
  74. charPtr = charPtrPtr[i]
  75. return strList
  76. # ------------------------------------------------------------------------------------------------------------
  77. # Convert a ctypes POINTER(c_<num>) into a python number list
  78. def numPtrToList(numPtr):
  79. if not numPtr:
  80. return []
  81. i = 0
  82. num = numPtr[0].value
  83. numList = []
  84. while num not in (0, 0.0):
  85. numList.append(num)
  86. i += 1
  87. num = numPtr[i].value
  88. return numList
  89. # ------------------------------------------------------------------------------------------------------------
  90. # Convert a ctypes struct into a python dict
  91. def structToDict(struct):
  92. return dict((attr, getattr(struct, attr)) for attr, value in struct._fields_)
  93. # ------------------------------------------------------------------------------------------------------------
  94. # Carla Backend API (base definitions)
  95. # Maximum default number of loadable plugins.
  96. MAX_DEFAULT_PLUGINS = 99
  97. # Maximum number of loadable plugins in rack mode.
  98. MAX_RACK_PLUGINS = 16
  99. # Maximum number of loadable plugins in patchbay mode.
  100. MAX_PATCHBAY_PLUGINS = 255
  101. # Maximum default number of parameters allowed.
  102. # @see ENGINE_OPTION_MAX_PARAMETERS
  103. MAX_DEFAULT_PARAMETERS = 200
  104. # ------------------------------------------------------------------------------------------------------------
  105. # Engine Driver Device Hints
  106. # Various engine driver device hints.
  107. # @see carla_get_engine_driver_device_info()
  108. # Engine driver device has custom control-panel.
  109. ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL = 0x1
  110. # Engine driver device can change buffer-size on the fly.
  111. # @see ENGINE_OPTION_AUDIO_BUFFER_SIZE
  112. ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE = 0x2
  113. # Engine driver device can change sample-rate on the fly.
  114. # @see ENGINE_OPTION_AUDIO_SAMPLE_RATE
  115. ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x4
  116. # ------------------------------------------------------------------------------------------------------------
  117. # Plugin Hints
  118. # Various plugin hints.
  119. # @see carla_get_plugin_info()
  120. # Plugin is a bridge.
  121. # This hint is required because "bridge" itself is not a plugin type.
  122. PLUGIN_IS_BRIDGE = 0x01
  123. # Plugin is hard real-time safe.
  124. PLUGIN_IS_RTSAFE = 0x02
  125. # Plugin is a synth (produces sound).
  126. PLUGIN_IS_SYNTH = 0x04
  127. # Plugin has its own custom UI.
  128. # @see carla_show_custom_ui()
  129. PLUGIN_HAS_CUSTOM_UI = 0x08
  130. # Plugin can use internal Dry/Wet control.
  131. PLUGIN_CAN_DRYWET = 0x10
  132. # Plugin can use internal Volume control.
  133. PLUGIN_CAN_VOLUME = 0x20
  134. # Plugin can use internal (Stereo) Balance controls.
  135. PLUGIN_CAN_BALANCE = 0x40
  136. # Plugin can use internal (Mono) Panning control.
  137. PLUGIN_CAN_PANNING = 0x80
  138. # ------------------------------------------------------------------------------------------------------------
  139. # Plugin Options
  140. # Various plugin options.
  141. # @see carla_get_plugin_info() and carla_set_option()
  142. # Use constant/fixed-size audio buffers.
  143. PLUGIN_OPTION_FIXED_BUFFERS = 0x001
  144. # Force mono plugin as stereo.
  145. PLUGIN_OPTION_FORCE_STEREO = 0x002
  146. # Map MIDI programs to plugin programs.
  147. PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004
  148. # Use chunks to save and restore data.
  149. PLUGIN_OPTION_USE_CHUNKS = 0x008
  150. # Send MIDI control change events.
  151. PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010
  152. # Send MIDI channel pressure events.
  153. PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020
  154. # Send MIDI note after-touch events.
  155. PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040
  156. # Send MIDI pitch-bend events.
  157. PLUGIN_OPTION_SEND_PITCHBEND = 0x080
  158. # Send MIDI all-sounds/notes-off events, single note-offs otherwise.
  159. PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100
  160. # ------------------------------------------------------------------------------------------------------------
  161. # Parameter Hints
  162. # Various parameter hints.
  163. # @see CarlaPlugin::getParameterData() and carla_get_parameter_data()
  164. # Parameter is input.
  165. # When this hint is not set, parameter is assumed to be output.
  166. PARAMETER_IS_INPUT = 0x001
  167. # Parameter value is boolean.
  168. PARAMETER_IS_BOOLEAN = 0x002
  169. # Parameter value is integer.
  170. PARAMETER_IS_INTEGER = 0x004
  171. # Parameter value is logarithmic.
  172. PARAMETER_IS_LOGARITHMIC = 0x008
  173. # Parameter is enabled.
  174. # It can be viewed, changed and stored.
  175. PARAMETER_IS_ENABLED = 0x010
  176. # Parameter is automable (real-time safe).
  177. PARAMETER_IS_AUTOMABLE = 0x020
  178. # Parameter is read-only.
  179. # It cannot be changed.
  180. PARAMETER_IS_READ_ONLY = 0x040
  181. # Parameter needs sample rate to work.
  182. # Value and ranges are multiplied by sample rate on usage and divided by sample rate on save.
  183. PARAMETER_USES_SAMPLERATE = 0x100
  184. # Parameter uses scale points to define internal values in a meaningful way.
  185. PARAMETER_USES_SCALEPOINTS = 0x200
  186. # Parameter uses custom text for displaying its value.
  187. # @see carla_get_parameter_text()
  188. PARAMETER_USES_CUSTOM_TEXT = 0x400
  189. # ------------------------------------------------------------------------------------------------------------
  190. # Patchbay Port Hints
  191. # Various patchbay port hints.
  192. # Patchbay port is input.
  193. # When this hint is not set, port is assumed to be output.
  194. PATCHBAY_PORT_IS_INPUT = 0x1
  195. # Patchbay port is of Audio type.
  196. PATCHBAY_PORT_TYPE_AUDIO = 0x2
  197. # Patchbay port is of CV type (Control Voltage).
  198. PATCHBAY_PORT_TYPE_CV = 0x4
  199. # Patchbay port is of MIDI type.
  200. PATCHBAY_PORT_TYPE_MIDI = 0x8
  201. # ------------------------------------------------------------------------------------------------------------
  202. # Custom Data Types
  203. # These types define how the value in the CustomData struct is stored.
  204. # @see CustomData.type
  205. # Boolean string type URI.
  206. # Only "true" and "false" are valid values.
  207. CUSTOM_DATA_TYPE_BOOLEAN = "http://kxstudio.sf.net/ns/carla/boolean"
  208. # Chunk type URI.
  209. CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"
  210. # String type URI.
  211. CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string"
  212. # ------------------------------------------------------------------------------------------------------------
  213. # Custom Data Keys
  214. # Pre-defined keys used internally in Carla.
  215. # @see CustomData.key
  216. # Plugin options key.
  217. CUSTOM_DATA_KEY_PLUGIN_OPTIONS = "CarlaPluginOptions"
  218. # UI position key.
  219. CUSTOM_DATA_KEY_UI_POSITION = "CarlaUiPosition"
  220. # UI size key.
  221. CUSTOM_DATA_KEY_UI_SIZE = "CarlaUiSize"
  222. # UI visible key.
  223. CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUiVisible"
  224. # ------------------------------------------------------------------------------------------------------------
  225. # Binary Type
  226. # The binary type of a plugin.
  227. # Null binary type.
  228. BINARY_NONE = 0
  229. # POSIX 32bit binary.
  230. BINARY_POSIX32 = 1
  231. # POSIX 64bit binary.
  232. BINARY_POSIX64 = 2
  233. # Windows 32bit binary.
  234. BINARY_WIN32 = 3
  235. # Windows 64bit binary.
  236. BINARY_WIN64 = 4
  237. # Other binary type.
  238. BINARY_OTHER = 5
  239. # ------------------------------------------------------------------------------------------------------------
  240. # Plugin Type
  241. # Plugin type.
  242. # Some files are handled as if they were plugins.
  243. # Null plugin type.
  244. PLUGIN_NONE = 0
  245. # Internal plugin.
  246. PLUGIN_INTERNAL = 1
  247. # LADSPA plugin.
  248. PLUGIN_LADSPA = 2
  249. # DSSI plugin.
  250. PLUGIN_DSSI = 3
  251. # LV2 plugin.
  252. PLUGIN_LV2 = 4
  253. # VST plugin.
  254. PLUGIN_VST = 5
  255. # AU plugin.
  256. # @note MacOS only
  257. PLUGIN_AU = 6
  258. # Csound file.
  259. PLUGIN_CSOUND = 7
  260. # GIG file.
  261. PLUGIN_GIG = 8
  262. # SF2 file (also known as SoundFont).
  263. PLUGIN_SF2 = 9
  264. # SFZ file.
  265. PLUGIN_SFZ = 10
  266. # ------------------------------------------------------------------------------------------------------------
  267. # Plugin Category
  268. # Plugin category, which describes the functionality of a plugin.
  269. # Null plugin category.
  270. PLUGIN_CATEGORY_NONE = 0
  271. # A synthesizer or generator.
  272. PLUGIN_CATEGORY_SYNTH = 1
  273. # A delay or reverb.
  274. PLUGIN_CATEGORY_DELAY = 2
  275. # An equalizer.
  276. PLUGIN_CATEGORY_EQ = 3
  277. # A filter.
  278. PLUGIN_CATEGORY_FILTER = 4
  279. # A distortion plugin.
  280. PLUGIN_CATEGORY_DISTORTION = 5
  281. # A 'dynamic' plugin (amplifier, compressor, gate, etc).
  282. PLUGIN_CATEGORY_DYNAMICS = 6
  283. # A 'modulator' plugin (chorus, flanger, phaser, etc).
  284. PLUGIN_CATEGORY_MODULATOR = 7
  285. # An 'utility' plugin (analyzer, converter, mixer, etc).
  286. PLUGIN_CATEGORY_UTILITY = 8
  287. # Miscellaneous plugin (used to check if the plugin has a category).
  288. PLUGIN_CATEGORY_OTHER = 9
  289. # ------------------------------------------------------------------------------------------------------------
  290. # Internal Parameter Index
  291. # Special parameters used internally in Carla.
  292. # Plugins do not know about their existence.
  293. # Null parameter.
  294. PARAMETER_NULL = -1
  295. # Active parameter, boolean type.
  296. # Default is 'false'.
  297. PARAMETER_ACTIVE = -2
  298. # Dry/Wet parameter.
  299. # Range 0.0...1.0; default is 1.0.
  300. PARAMETER_DRYWET = -3
  301. # Volume parameter.
  302. # Range 0.0...1.27; default is 1.0.
  303. PARAMETER_VOLUME = -4
  304. # Stereo Balance-Left parameter.
  305. # Range -1.0...1.0; default is -1.0.
  306. PARAMETER_BALANCE_LEFT = -5
  307. # Stereo Balance-Right parameter.
  308. # Range -1.0...1.0; default is 1.0.
  309. PARAMETER_BALANCE_RIGHT = -6
  310. # Mono Panning parameter.
  311. # Range -1.0...1.0; default is 0.0.
  312. PARAMETER_PANNING = -7
  313. # MIDI Control channel, integer type.
  314. # Range -1...15 (-1 = off).
  315. PARAMETER_CTRL_CHANNEL = -8
  316. # Max value, defined only for convenience.
  317. PARAMETER_MAX = -9
  318. # ------------------------------------------------------------------------------------------------------------
  319. # Engine Callback Opcode
  320. # Engine callback opcodes.
  321. # Front-ends must never block indefinitely during a callback.
  322. # @see EngineCallbackFunc and carla_set_engine_callback()
  323. # Debug.
  324. # This opcode is undefined and used only for testing purposes.
  325. ENGINE_CALLBACK_DEBUG = 0
  326. # A plugin has been added.
  327. # @param pluginId Plugin Id
  328. # @param valueStr Plugin name
  329. ENGINE_CALLBACK_PLUGIN_ADDED = 1
  330. # A plugin has been removed.
  331. # @param pluginId Plugin Id
  332. ENGINE_CALLBACK_PLUGIN_REMOVED = 2
  333. # A plugin has been renamed.
  334. # @param pluginId Plugin Id
  335. # @param valueStr New plugin name
  336. ENGINE_CALLBACK_PLUGIN_RENAMED = 3
  337. # A plugin has become unavailable.
  338. # @param pluginId Plugin Id
  339. # @param valueStr Related error string
  340. ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4
  341. # A parameter value has changed.
  342. # @param pluginId Plugin Id
  343. # @param value1 Parameter index
  344. # @param value3 New parameter value
  345. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5
  346. # A parameter default has changed.
  347. # @param pluginId Plugin Id
  348. # @param value1 Parameter index
  349. # @param value3 New default value
  350. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6
  351. # A parameter's MIDI CC has changed.
  352. # @param pluginId Plugin Id
  353. # @param value1 Parameter index
  354. # @param value2 New MIDI CC
  355. ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7
  356. # A parameter's MIDI channel has changed.
  357. # @param pluginId Plugin Id
  358. # @param value1 Parameter index
  359. # @param value2 New MIDI channel
  360. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8
  361. # The current program of a plugin has changed.
  362. # @param pluginId Plugin Id
  363. # @param value1 New program index
  364. ENGINE_CALLBACK_PROGRAM_CHANGED = 9
  365. # The current MIDI program of a plugin has changed.
  366. # @param pluginId Plugin Id
  367. # @param value1 New MIDI bank
  368. # @param value2 New MIDI program
  369. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 10
  370. # A plugin's custom UI state has changed.
  371. # @param pluginId Plugin Id
  372. # @param value1 New state, as follows:
  373. # 0: UI is now hidden
  374. # 1: UI is now visible
  375. # -1: UI has crashed and should not be shown again
  376. ENGINE_CALLBACK_UI_STATE_CHANGED = 11
  377. # A note has been pressed.
  378. # @param pluginId Plugin Id
  379. # @param value1 Channel
  380. # @param value2 Note
  381. # @param value3 Velocity
  382. ENGINE_CALLBACK_NOTE_ON = 12
  383. # A note has been released.
  384. # @param pluginId Plugin Id
  385. # @param value1 Channel
  386. # @param value2 Note
  387. ENGINE_CALLBACK_NOTE_OFF = 13
  388. # A plugin needs update.
  389. # @param pluginId Plugin Id
  390. ENGINE_CALLBACK_UPDATE = 14
  391. # A plugin's data/information has changed.
  392. # @param pluginId Plugin Id
  393. ENGINE_CALLBACK_RELOAD_INFO = 15
  394. # A plugin's parameters have changed.
  395. # @param pluginId Plugin Id
  396. ENGINE_CALLBACK_RELOAD_PARAMETERS = 16
  397. # A plugin's programs have changed.
  398. # @param pluginId Plugin Id
  399. ENGINE_CALLBACK_RELOAD_PROGRAMS = 17
  400. # A plugin state has changed.
  401. # @param pluginId Plugin Id
  402. ENGINE_CALLBACK_RELOAD_ALL = 18
  403. # A patchbay client has been added.
  404. # @param pluginId Client Id
  405. # @param valueStr Client name and icon, as "name:icon"
  406. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 19
  407. # A patchbay client has been removed.
  408. # @param pluginId Client Id
  409. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 20
  410. # A patchbay client has been renamed.
  411. # @param pluginId Client Id
  412. # @param valueStr New client name
  413. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 21
  414. # A patchbay client icon has changed.
  415. # @param pluginId Client Id
  416. # @param valueStr New icon name
  417. ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED = 22
  418. # A patchbay port has been added.
  419. # @param pluginId Client Id
  420. # @param value1 Port Id
  421. # @param value2 Port hints
  422. # @param valueStr Port name
  423. # @see PatchbayPortHints
  424. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 23
  425. # A patchbay port has been removed.
  426. # @param pluginId Client Id
  427. # @param value1 Port Id
  428. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 24
  429. # A patchbay port has been renamed.
  430. # @param pluginId Client Id
  431. # @param value1 Port Id
  432. # @param valueStr New port name
  433. ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 25
  434. # A patchbay connection has been added.
  435. # @param value1 Output port Id
  436. # @param value2 Input port Id
  437. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 26
  438. # A patchbay connection has been removed.
  439. # @param value1 Output port Id
  440. # @param value2 Input port Id
  441. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 27
  442. # Engine started.
  443. # @param value1 Process mode
  444. # @param value2 Transport mode
  445. # @param valuestr Engine driver
  446. # @see EngineProcessMode
  447. # @see EngineTransportMode
  448. ENGINE_CALLBACK_ENGINE_STARTED = 28
  449. # Engine stopped.
  450. ENGINE_CALLBACK_ENGINE_STOPPED = 29
  451. # Engine process mode has changed.
  452. # @param value1 New process mode
  453. # @see EngineProcessMode
  454. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 30
  455. # Engine transport mode has changed.
  456. # @param value1 New transport mode
  457. # @see EngineTransportMode
  458. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 31
  459. # Engine buffer-size changed.
  460. # @param value1 New buffer size
  461. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 32
  462. # Engine sample-rate changed.
  463. # @param value3 New sample rate
  464. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 33
  465. # Show a message as information.
  466. # @param valueStr The message
  467. ENGINE_CALLBACK_INFO = 34
  468. # Show a message as an error.
  469. # @param valueStr The message
  470. ENGINE_CALLBACK_ERROR = 35
  471. # The engine has crashed or malfunctioned and will no longer work.
  472. ENGINE_CALLBACK_QUIT = 36
  473. # ------------------------------------------------------------------------------------------------------------
  474. # Engine Option
  475. # Engine options.
  476. # @see carla_set_engine_option()
  477. # Debug.
  478. # This option is undefined and used only for testing purposes.
  479. ENGINE_OPTION_DEBUG = 0
  480. # Set the engine processing mode.
  481. # Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_CONTINUOUS_RACK for all other OSes.
  482. # @see EngineProcessMode
  483. ENGINE_OPTION_PROCESS_MODE = 1
  484. # Set the engine transport mode.
  485. # Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  486. # @see EngineTransportMode
  487. ENGINE_OPTION_TRANSPORT_MODE = 2
  488. # Force mono plugins as stereo, by running 2 instances at the same time.
  489. # Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  490. # @note Not supported by all plugins
  491. # @see PLUGIN_OPTION_FORCE_STEREO
  492. ENGINE_OPTION_FORCE_STEREO = 3
  493. # Use plugin bridges whenever possible.
  494. # Default is no, EXPERIMENTAL.
  495. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4
  496. # Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  497. # Default is yes.
  498. ENGINE_OPTION_PREFER_UI_BRIDGES = 5
  499. # Make custom plugin UIs always-on-top.
  500. # Default is yes.
  501. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6
  502. # Maximum number of parameters allowed.
  503. # Default is MAX_DEFAULT_PARAMETERS.
  504. ENGINE_OPTION_MAX_PARAMETERS = 7
  505. # Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  506. # Default is 4000 (4 seconds).
  507. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8
  508. # Audio number of periods.
  509. # Default is 2.
  510. ENGINE_OPTION_AUDIO_NUM_PERIODS = 9
  511. # Audio buffer size.
  512. # Default is 512.
  513. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10
  514. # Audio sample rate.
  515. # Default is 44100.
  516. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11
  517. # Audio device (within a driver).
  518. # Default unset.
  519. ENGINE_OPTION_AUDIO_DEVICE = 12
  520. # Set path to the binary files.
  521. # Default unset.
  522. # @note Must be set for plugin and UI bridges to work
  523. ENGINE_OPTION_PATH_BINARIES = 13
  524. # Set path to the resource files.
  525. # Default unset.
  526. # @note Must be set for some internal plugins to work
  527. ENGINE_OPTION_PATH_RESOURCES = 14
  528. # ------------------------------------------------------------------------------------------------------------
  529. # Engine Process Mode
  530. # Engine process mode.
  531. # @see ENGINE_OPTION_PROCESS_MODE
  532. # Single client mode.
  533. # Inputs and outputs are added dynamically as needed by plugins.
  534. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0
  535. # Multiple client mode.
  536. # It has 1 master client + 1 client per plugin.
  537. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1
  538. # Single client, 'rack' mode.
  539. # Processes plugins in order of Id, with forced stereo always on.
  540. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2
  541. # Single client, 'patchbay' mode.
  542. ENGINE_PROCESS_MODE_PATCHBAY = 3
  543. # Special mode, used in plugin-bridges only.
  544. ENGINE_PROCESS_MODE_BRIDGE = 4
  545. # ------------------------------------------------------------------------------------------------------------
  546. # Engine Transport Mode
  547. # Engine transport mode.
  548. # @see ENGINE_OPTION_TRANSPORT_MODE
  549. # Internal transport mode.
  550. ENGINE_TRANSPORT_MODE_INTERNAL = 0
  551. # Transport from JACK.
  552. # Only available if driver name is "JACK".
  553. ENGINE_TRANSPORT_MODE_JACK = 1
  554. # Transport from host, used when Carla is a plugin.
  555. ENGINE_TRANSPORT_MODE_PLUGIN = 2
  556. # Special mode, used in plugin-bridges only.
  557. ENGINE_TRANSPORT_MODE_BRIDGE = 3
  558. # ------------------------------------------------------------------------------------------------------------
  559. # Carla Backend API (C stuff)
  560. # Engine callback function.
  561. # Front-ends must never block indefinitely during a callback.
  562. # @see EngineCallbackOpcode and carla_set_engine_callback()
  563. EngineCallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_float, c_char_p)
  564. # Parameter data.
  565. class ParameterData(Structure):
  566. _fields_ = [
  567. # Index as seen by Carla.
  568. ("index", c_int32),
  569. # Real index as seen by plugins.
  570. ("rindex", c_int32),
  571. # This parameter hints.
  572. # @see ParameterHints
  573. ("hints", c_uint),
  574. # Currently mapped MIDI CC.
  575. # A value lower than 0 means invalid or unused.
  576. # Maximum allowed value is 95 (0x5F).
  577. ("midiCC", c_int16),
  578. # Currently mapped MIDI channel.
  579. # Counts from 0 to 15.
  580. ("midiChannel", c_uint8)
  581. ]
  582. # Parameter ranges.
  583. class ParameterRanges(Structure):
  584. _fields_ = [
  585. # Default value.
  586. ("def", c_float),
  587. # Minimum value.
  588. ("min", c_float),
  589. # Maximum value.
  590. ("max", c_float),
  591. # Regular, single step value.
  592. ("step", c_float),
  593. # Small step value.
  594. ("stepSmall", c_float),
  595. # Large step value.
  596. ("stepLarge", c_float)
  597. ]
  598. # MIDI Program data.
  599. class MidiProgramData(Structure):
  600. _fields_ = [
  601. # MIDI bank.
  602. ("bank", c_uint32),
  603. # MIDI program.
  604. ("program", c_uint32),
  605. # MIDI program name.
  606. ("name", c_char_p)
  607. ]
  608. # Custom data, used for saving key:value 'dictionaries'.
  609. class CustomData(Structure):
  610. _fields_ = [
  611. # Value type, in URI form.
  612. # @see CustomDataTypes
  613. ("type", c_char_p),
  614. # Key.
  615. # @see CustomDataKeys
  616. ("key", c_char_p),
  617. # Value.
  618. ("value", c_char_p)
  619. ]
  620. # Engine driver device information.
  621. class EngineDriverDeviceInfo(Structure):
  622. _fields_ = [
  623. # This driver device hints.
  624. # @see EngineDriverHints
  625. ("hints", c_uint),
  626. # Available buffer sizes.
  627. # Terminated with 0.
  628. ("bufferSizes", POINTER(c_uint32)),
  629. # Available sample rates.
  630. # Terminated with 0.0.
  631. ("sampleRates", POINTER(c_double))
  632. ]
  633. # ------------------------------------------------------------------------------------------------------------
  634. # Carla Backend API (Python compatible stuff)
  635. # @see ParameterData
  636. PyParameterData = {
  637. 'index': PARAMETER_NULL,
  638. 'rindex': -1,
  639. 'hints': 0x0,
  640. 'midiCC': -1,
  641. 'midiChannel': 0
  642. }
  643. # @see ParameterRanges
  644. PyParameterRanges = {
  645. 'def': 0.0,
  646. 'min': 0.0,
  647. 'max': 1.0,
  648. 'step': 0.01,
  649. 'stepSmall': 0.0001,
  650. 'stepLarge': 0.1
  651. }
  652. # @see MidiProgramData
  653. PyMidiProgramData = {
  654. 'bank': 0,
  655. 'program': 0,
  656. 'name': None
  657. }
  658. # @see CustomData
  659. PyCustomData = {
  660. 'type': None,
  661. 'key': None,
  662. 'value': None
  663. }
  664. # @see EngineDriverDeviceInfo
  665. PyEngineDriverDeviceInfo = {
  666. 'hints': 0x0,
  667. 'bufferSizes': [],
  668. 'sampleRates': []
  669. }
  670. # ------------------------------------------------------------------------------------------------------------
  671. # File Callback Opcode
  672. # File callback opcodes.
  673. # Front-ends must always block-wait for user input.
  674. # @see FileCallbackFunc and carla_set_file_callback()
  675. # Debug.
  676. # This opcode is undefined and used only for testing purposes.
  677. FILE_CALLBACK_DEBUG = 0
  678. # Open file or folder.
  679. FILE_CALLBACK_OPEN = 1
  680. # Save file or folder.
  681. FILE_CALLBACK_SAVE = 2
  682. # ------------------------------------------------------------------------------------------------------------
  683. # Carla Host API (C stuff)
  684. # File callback function.
  685. # @see FileCallbackOpcode
  686. FileCallbackFunc = CFUNCTYPE(c_char_p, c_void_p, c_enum, c_bool, c_char_p, c_char_p)
  687. # Information about a loaded plugin.
  688. # @see carla_get_plugin_info()
  689. class CarlaPluginInfo(Structure):
  690. _fields_ = [
  691. # Plugin type.
  692. ("type", c_enum),
  693. # Plugin category.
  694. ("category", c_enum),
  695. # Plugin hints.
  696. # @see PluginHints
  697. ("hints", c_uint),
  698. # Plugin options available for the user to change.
  699. # @see PluginOptions
  700. ("optionsAvailable", c_uint),
  701. # Plugin options currently enabled.
  702. # Some options are enabled but not available, which means they will always be on.
  703. # @see PluginOptions
  704. ("optionsEnabled", c_uint),
  705. # Plugin filename.
  706. # This can be the plugin binary or resource file.
  707. ("filename", c_char_p),
  708. # Plugin name.
  709. # This name is unique within a Carla instance.
  710. # @see carla_get_real_plugin_name()
  711. ("name", c_char_p),
  712. # Plugin label or URI.
  713. ("label", c_char_p),
  714. # Plugin author/maker.
  715. ("maker", c_char_p),
  716. # Plugin copyright/license.
  717. ("copyright", c_char_p),
  718. # Icon name for this plugin, in lowercase.
  719. # Default is "plugin".
  720. ("iconName", c_char_p),
  721. # Patchbay client Id for this plugin.
  722. # When 0, Id is considered invalid or unused.
  723. ("patchbayClientId", c_int),
  724. # Plugin unique Id.
  725. # This Id is dependant on the plugin type and may sometimes be 0.
  726. ("uniqueId", c_long)
  727. ]
  728. # Information about an internal Carla plugin.
  729. # @see carla_get_internal_plugin_info()
  730. class CarlaNativePluginInfo(Structure):
  731. _fields_ = [
  732. # Plugin category.
  733. ("category", c_enum),
  734. # Plugin hints.
  735. # @see PluginHints
  736. ("hints", c_uint),
  737. # Number of audio inputs.
  738. ("audioIns", c_uint32),
  739. # Number of audio outputs.
  740. ("audioOuts", c_uint32),
  741. # Number of MIDI inputs.
  742. ("midiIns", c_uint32),
  743. # Number of MIDI outputs.
  744. ("midiOuts", c_uint32),
  745. # Number of input parameters.
  746. ("parameterIns", c_uint32),
  747. # Number of output parameters.
  748. ("parameterOuts", c_uint32),
  749. # Plugin name.
  750. ("name", c_char_p),
  751. # Plugin label.
  752. ("label", c_char_p),
  753. # Plugin author/maker.
  754. ("maker", c_char_p),
  755. # Plugin copyright/license.
  756. ("copyright", c_char_p)
  757. ]
  758. # Port count information, used for Audio and MIDI ports and parameters.
  759. # @see carla_get_audio_port_count_info()
  760. # @see carla_get_midi_port_count_info()
  761. # @see carla_get_parameter_count_info()
  762. class CarlaPortCountInfo(Structure):
  763. _fields_ = [
  764. # Number of inputs.
  765. ("ins", c_uint32),
  766. # Number of outputs.
  767. ("outs", c_uint32)
  768. ]
  769. # Parameter information.
  770. # @see carla_get_parameter_info()
  771. class CarlaParameterInfo(Structure):
  772. _fields_ = [
  773. # Parameter name.
  774. ("name", c_char_p),
  775. # Parameter symbol.
  776. ("symbol", c_char_p),
  777. # Parameter unit.
  778. ("unit", c_char_p),
  779. # Number of scale points.
  780. # @see CarlaScalePointInfo
  781. ("scalePointCount", c_uint32)
  782. ]
  783. # Parameter scale point information.
  784. # @see carla_get_parameter_scalepoint_info()
  785. class CarlaScalePointInfo(Structure):
  786. _fields_ = [
  787. # Scale point value.
  788. ("value", c_float),
  789. # Scale point label.
  790. ("label", c_char_p)
  791. ]
  792. # Transport information.
  793. # @see carla_get_transport_info()
  794. class CarlaTransportInfo(Structure):
  795. _fields_ = [
  796. # Wherever transport is playing.
  797. ("playing", c_bool),
  798. # Current transport frame.
  799. ("frame", c_uint64),
  800. # Bar
  801. ("bar", c_int32),
  802. # Beat
  803. ("beat", c_int32),
  804. # Tick
  805. ("tick", c_int32),
  806. # Beats per minute.
  807. ("bpm", c_double)
  808. ]
  809. # ------------------------------------------------------------------------------------------------------------
  810. # Carla Host API (Python compatible stuff)
  811. # @see CarlaPluginInfo
  812. PyCarlaPluginInfo = {
  813. 'type': PLUGIN_NONE,
  814. 'category': PLUGIN_CATEGORY_NONE,
  815. 'hints': 0x0,
  816. 'optionsAvailable': 0x0,
  817. 'optionsEnabled': 0x0,
  818. 'filename': None,
  819. 'name': None,
  820. 'label': None,
  821. 'maker': None,
  822. 'copyright': None,
  823. 'iconName': None,
  824. 'patchbayClientId': 0,
  825. 'uniqueId': 0
  826. }
  827. # @see CarlaPortCountInfo
  828. PyCarlaPortCountInfo = {
  829. 'ins': 0,
  830. 'outs': 0
  831. }
  832. # @see CarlaParameterInfo
  833. PyCarlaParameterInfo = {
  834. 'name': None,
  835. 'symbol': None,
  836. 'unit': None,
  837. 'scalePointCount': 0,
  838. }
  839. # @see CarlaScalePointInfo
  840. PyCarlaScalePointInfo = {
  841. 'value': 0.0,
  842. 'label': None
  843. }
  844. # @see CarlaTransportInfo
  845. PyCarlaTransportInfo = {
  846. "playing": False,
  847. "frame": 0,
  848. "bar": 0,
  849. "beat": 0,
  850. "tick": 0,
  851. "bpm": 0.0
  852. }
  853. # ------------------------------------------------------------------------------------------------------------
  854. # Set BINARY_NATIVE
  855. if HAIKU or LINUX or MACOS:
  856. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  857. elif WINDOWS:
  858. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  859. else:
  860. BINARY_NATIVE = BINARY_OTHER
  861. # ------------------------------------------------------------------------------------------------------------
  862. # Python Host object (Control/Standalone)
  863. class Host(object):
  864. def __init__(self, libName):
  865. object.__init__(self)
  866. self._init(libName)
  867. # Get the complete license text of used third-party code and features.
  868. # Returned string is in basic html format.
  869. def get_complete_license_text(self):
  870. return charPtrToString(self.lib.carla_get_complete_license_text())
  871. # Get all the supported file extensions in carla_load_file().
  872. # Returned string uses this syntax:
  873. # @code
  874. # "*.ext1;*.ext2;*.ext3"
  875. # @endcode
  876. def get_supported_file_extensions(self):
  877. return charPtrToString(self.lib.carla_get_supported_file_extensions())
  878. # Get how many engine drivers are available.
  879. def get_engine_driver_count(self):
  880. return int(self.lib.carla_get_engine_driver_count())
  881. # Get an engine driver name.
  882. # @param index Driver index
  883. def get_engine_driver_name(self, index):
  884. return charPtrToString(self.lib.carla_get_engine_driver_name(index))
  885. # Get the device names of an engine driver.
  886. # @param index Driver index
  887. def get_engine_driver_device_names(self, index):
  888. return charPtrPtrToStringList(self.lib.carla_get_engine_driver_device_names(index))
  889. # Get information about a device driver.
  890. # @param index Driver index
  891. # @param name Device name
  892. def get_engine_driver_device_info(self, index, name):
  893. return structToDict(self.lib.carla_get_engine_driver_device_info(index, name))
  894. # Get how many internal plugins are available.
  895. def get_internal_plugin_count(self):
  896. return int(self.lib.carla_get_internal_plugin_count())
  897. # Get information about an internal plugin.
  898. # @param index Internal plugin Id
  899. def get_internal_plugin_info(self, index):
  900. return structToDict(self.lib.carla_get_internal_plugin_info(index).contents)
  901. # Initialize the engine.
  902. # Make sure to call carla_engine_idle() at regular intervals afterwards.
  903. # @param driverName Driver to use
  904. # @param clientName Engine master client name
  905. def engine_init(self, driverName, clientName):
  906. return bool(self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8")))
  907. # Close the engine.
  908. # This function always closes the engine even if it returns false.
  909. # In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
  910. def engine_close(self):
  911. return bool(self.lib.carla_engine_close())
  912. # Idle the engine.
  913. # Do not call this if the engine is not running.
  914. def engine_idle(self):
  915. self.lib.carla_engine_idle()
  916. # Check if the engine is running.
  917. def is_engine_running(self):
  918. return bool(self.lib.carla_is_engine_running())
  919. # Tell the engine it's about to close.
  920. # This is used to prevent the engine thread(s) from reactivating.
  921. def set_engine_about_to_close(self):
  922. self.lib.carla_set_engine_about_to_close()
  923. # Set the engine callback function.
  924. # @param func Callback function
  925. def set_engine_callback(self, func):
  926. self._engineCallback = EngineCallbackFunc(func)
  927. self.lib.carla_set_engine_callback(self._engineCallback, None)
  928. # Set an engine option.
  929. # @param option Option
  930. # @param value Value as number
  931. # @param valueStr Value as string
  932. def set_engine_option(self, option, value, valueStr):
  933. self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))
  934. # Set the file callback function.
  935. # @param func Callback function
  936. # @param ptr Callback pointer
  937. def set_file_callback(self, func):
  938. self._fileCallback = FileCallbackFunc(func)
  939. self.lib.carla_set_file_callback(self._fileCallback, None)
  940. # Load a file of any type.\n
  941. # This will try to load a generic file as a plugin,
  942. # either by direct handling (Csound, GIG, SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
  943. # @param Filename Filename
  944. # @see carla_get_supported_file_extensions()
  945. def load_file(self, filename):
  946. return bool(self.lib.carla_load_file(filename.encode("utf-8")))
  947. # Load a Carla project file.
  948. # @param Filename Filename
  949. # @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
  950. def load_project(self, filename):
  951. return bool(self.lib.carla_load_project(filename.encode("utf-8")))
  952. # Save current project to a file.
  953. # @param Filename Filename
  954. def save_project(self, filename):
  955. return bool(self.lib.carla_save_project(filename.encode("utf-8")))
  956. # Connect two patchbay ports.
  957. # @param portA Output port
  958. # @param portB Input port
  959. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
  960. def patchbay_connect(self, portIdA, portIdB):
  961. return bool(self.lib.carla_patchbay_connect(portIdA, portIdB))
  962. # Disconnect two patchbay ports.
  963. # @param connectionId Connection Id
  964. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
  965. def patchbay_disconnect(self, connectionId):
  966. return bool(self.lib.carla_patchbay_disconnect(connectionId))
  967. # Force the engine to resend all patchbay clients, ports and connections again.
  968. def patchbay_refresh(self):
  969. return bool(self.lib.carla_patchbay_refresh())
  970. # Start playback of the engine transport.
  971. def transport_play(self):
  972. self.lib.carla_transport_play()
  973. # Pause the engine transport.
  974. def transport_pause(self):
  975. self.lib.carla_transport_pause()
  976. # Relocate the engine transport to a specific frame.
  977. # @param frames Frame to relocate to.
  978. def transport_relocate(self, frames):
  979. self.lib.carla_transport_relocate(frames)
  980. # Get the current transport frame.
  981. def get_current_transport_frame(self):
  982. return bool(self.lib.carla_get_current_transport_frame())
  983. # Get the engine transport information.
  984. def get_transport_info(self):
  985. return structToDict(self.lib.carla_get_transport_info().contents)
  986. def add_plugin(self, btype, ptype, filename, name, label, extraStuff):
  987. cfilename = filename.encode("utf-8") if filename else None
  988. cname = name.encode("utf-8") if name else None
  989. clabel = label.encode("utf-8") if label else None
  990. return bool(self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, cast(extraStuff, c_void_p)))
  991. def remove_plugin(self, pluginId):
  992. return bool(self.lib.carla_remove_plugin(pluginId))
  993. def remove_all_plugins(self):
  994. return bool(self.lib.carla_remove_all_plugins())
  995. def rename_plugin(self, pluginId, newName):
  996. return bool(self.lib.carla_rename_plugin(pluginId, newName.encode("utf-8")))
  997. def clone_plugin(self, pluginId):
  998. return bool(self.lib.carla_clone_plugin(pluginId))
  999. def replace_plugin(self, pluginId):
  1000. return bool(self.lib.carla_replace_plugin(pluginId))
  1001. def switch_plugins(self, pluginIdA, pluginIdB):
  1002. return bool(self.lib.carla_switch_plugins(pluginIdA, pluginIdB))
  1003. def load_plugin_state(self, pluginId, filename):
  1004. return bool(self.lib.carla_load_plugin_state(pluginId, filename.encode("utf-8")))
  1005. def save_plugin_state(self, pluginId, filename):
  1006. return bool(self.lib.carla_save_plugin_state(pluginId, filename.encode("utf-8")))
  1007. def get_plugin_info(self, pluginId):
  1008. return structToDict(self.lib.carla_get_plugin_info(pluginId).contents)
  1009. def get_audio_port_count_info(self, pluginId):
  1010. return structToDict(self.lib.carla_get_audio_port_count_info(pluginId).contents)
  1011. def get_midi_port_count_info(self, pluginId):
  1012. return structToDict(self.lib.carla_get_midi_port_count_info(pluginId).contents)
  1013. def get_parameter_count_info(self, pluginId):
  1014. return structToDict(self.lib.carla_get_parameter_count_info(pluginId).contents)
  1015. def get_parameter_info(self, pluginId, parameterId):
  1016. return structToDict(self.lib.carla_get_parameter_info(pluginId, parameterId).contents)
  1017. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  1018. return structToDict(self.lib.carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId).contents)
  1019. def get_parameter_data(self, pluginId, parameterId):
  1020. return structToDict(self.lib.carla_get_parameter_data(pluginId, parameterId).contents)
  1021. def get_parameter_ranges(self, pluginId, parameterId):
  1022. return structToDict(self.lib.carla_get_parameter_ranges(pluginId, parameterId).contents)
  1023. def get_midi_program_data(self, pluginId, midiProgramId):
  1024. return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents)
  1025. def get_custom_data(self, pluginId, customDataId):
  1026. return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents)
  1027. def get_chunk_data(self, pluginId):
  1028. return charPtrToString(self.lib.carla_get_chunk_data(pluginId))
  1029. def get_parameter_count(self, pluginId):
  1030. return int(self.lib.carla_get_parameter_count(pluginId))
  1031. def get_program_count(self, pluginId):
  1032. return int(self.lib.carla_get_program_count(pluginId))
  1033. def get_midi_program_count(self, pluginId):
  1034. return int(self.lib.carla_get_midi_program_count(pluginId))
  1035. def get_custom_data_count(self, pluginId):
  1036. return int(self.lib.carla_get_custom_data_count(pluginId))
  1037. def get_parameter_text(self, pluginId, parameterId):
  1038. return charPtrToString(self.lib.carla_get_parameter_text(pluginId, parameterId))
  1039. def get_program_name(self, pluginId, programId):
  1040. return charPtrToString(self.lib.carla_get_program_name(pluginId, programId))
  1041. def get_midi_program_name(self, pluginId, midiProgramId):
  1042. return charPtrToString(self.lib.carla_get_midi_program_name(pluginId, midiProgramId))
  1043. def get_real_plugin_name(self, pluginId):
  1044. return charPtrToString(self.lib.carla_get_real_plugin_name(pluginId))
  1045. def get_current_program_index(self, pluginId):
  1046. return self.lib.carla_get_current_program_index(pluginId)
  1047. def get_current_midi_program_index(self, pluginId):
  1048. return self.lib.carla_get_current_midi_program_index(pluginId)
  1049. def get_default_parameter_value(self, pluginId, parameterId):
  1050. return self.lib.carla_get_default_parameter_value(pluginId, parameterId)
  1051. def get_current_parameter_value(self, pluginId, parameterId):
  1052. return self.lib.carla_get_current_parameter_value(pluginId, parameterId)
  1053. def get_input_peak_value(self, pluginId, portId):
  1054. return self.lib.carla_get_input_peak_value(pluginId, portId)
  1055. def get_output_peak_value(self, pluginId, portId):
  1056. return self.lib.carla_get_output_peak_value(pluginId, portId)
  1057. def set_option(self, pluginId, option, yesNo):
  1058. self.lib.carla_set_option(pluginId, option, yesNo)
  1059. def set_active(self, pluginId, onOff):
  1060. self.lib.carla_set_active(pluginId, onOff)
  1061. def set_drywet(self, pluginId, value):
  1062. self.lib.carla_set_drywet(pluginId, value)
  1063. def set_volume(self, pluginId, value):
  1064. self.lib.carla_set_volume(pluginId, value)
  1065. def set_balance_left(self, pluginId, value):
  1066. self.lib.carla_set_balance_left(pluginId, value)
  1067. def set_balance_right(self, pluginId, value):
  1068. self.lib.carla_set_balance_right(pluginId, value)
  1069. def set_panning(self, pluginId, value):
  1070. self.lib.carla_set_panning(pluginId, value)
  1071. def set_ctrl_channel(self, pluginId, channel):
  1072. self.lib.carla_set_ctrl_channel(pluginId, channel)
  1073. def set_parameter_value(self, pluginId, parameterId, value):
  1074. self.lib.carla_set_parameter_value(pluginId, parameterId, value)
  1075. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  1076. self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc)
  1077. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  1078. self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel)
  1079. def set_program(self, pluginId, programId):
  1080. self.lib.carla_set_program(pluginId, programId)
  1081. def set_midi_program(self, pluginId, midiProgramId):
  1082. self.lib.carla_set_midi_program(pluginId, midiProgramId)
  1083. def set_custom_data(self, pluginId, type_, key, value):
  1084. self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8"))
  1085. def set_chunk_data(self, pluginId, chunkData):
  1086. self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8"))
  1087. def prepare_for_save(self, pluginId):
  1088. self.lib.carla_prepare_for_save(pluginId)
  1089. def send_midi_note(self, pluginId, channel, note, velocity):
  1090. self.lib.carla_send_midi_note(pluginId, channel, note, velocity)
  1091. def show_gui(self, pluginId, yesNo):
  1092. self.lib.carla_show_gui(pluginId, yesNo)
  1093. def get_last_error(self):
  1094. return self.lib.carla_get_last_error()
  1095. def get_host_osc_url_tcp(self):
  1096. return self.lib.carla_get_host_osc_url_tcp()
  1097. def get_host_osc_url_udp(self):
  1098. return self.lib.carla_get_host_osc_url_udp()
  1099. def get_buffer_size(self):
  1100. return self.lib.carla_get_buffer_size()
  1101. def get_sample_rate(self):
  1102. return self.lib.carla_get_sample_rate()
  1103. def _init(self, libName):
  1104. self.lib = cdll.LoadLibrary(libName)
  1105. self.lib.carla_get_complete_license_text.argtypes = None
  1106. self.lib.carla_get_complete_license_text.restype = c_char_p
  1107. self.lib.carla_get_supported_file_extensions.argtypes = None
  1108. self.lib.carla_get_supported_file_extensions.restype = c_char_p
  1109. self.lib.carla_get_engine_driver_count.argtypes = None
  1110. self.lib.carla_get_engine_driver_count.restype = c_uint
  1111. self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
  1112. self.lib.carla_get_engine_driver_name.restype = c_char_p
  1113. self.lib.carla_get_engine_driver_device_names.argtypes = [c_uint]
  1114. self.lib.carla_get_engine_driver_device_names.restype = POINTER(c_char_p)
  1115. self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p]
  1116. self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo)
  1117. self.lib.carla_get_internal_plugin_count.argtypes = None
  1118. self.lib.carla_get_internal_plugin_count.restype = c_uint
  1119. self.lib.carla_get_internal_plugin_info.argtypes = [c_uint]
  1120. self.lib.carla_get_internal_plugin_info.restype = POINTER(CarlaNativePluginInfo)
  1121. self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p]
  1122. self.lib.carla_engine_init.restype = c_bool
  1123. self.lib.carla_engine_close.argtypes = None
  1124. self.lib.carla_engine_close.restype = c_bool
  1125. self.lib.carla_engine_idle.argtypes = None
  1126. self.lib.carla_engine_idle.restype = None
  1127. self.lib.carla_is_engine_running.argtypes = None
  1128. self.lib.carla_is_engine_running.restype = c_bool
  1129. self.lib.carla_set_engine_about_to_close.argtypes = None
  1130. self.lib.carla_set_engine_about_to_close.restype = None
  1131. self.lib.carla_set_engine_callback.argtypes = [EngineCallbackFunc, c_void_p]
  1132. self.lib.carla_set_engine_callback.restype = None
  1133. self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
  1134. self.lib.carla_set_engine_option.restype = None
  1135. self.lib.carla_load_file.argtypes = [c_char_p]
  1136. self.lib.carla_load_file.restype = c_bool
  1137. self.lib.carla_load_project.argtypes = [c_char_p]
  1138. self.lib.carla_load_project.restype = c_bool
  1139. self.lib.carla_save_project.argtypes = [c_char_p]
  1140. self.lib.carla_save_project.restype = c_bool
  1141. self.lib.carla_patchbay_connect.argtypes = [c_int, c_int]
  1142. self.lib.carla_patchbay_connect.restype = c_bool
  1143. self.lib.carla_patchbay_disconnect.argtypes = [c_int]
  1144. self.lib.carla_patchbay_disconnect.restype = c_bool
  1145. self.lib.carla_patchbay_refresh.argtypes = None
  1146. self.lib.carla_patchbay_refresh.restype = c_bool
  1147. self.lib.carla_transport_play.argtypes = None
  1148. self.lib.carla_transport_play.restype = None
  1149. self.lib.carla_transport_pause.argtypes = None
  1150. self.lib.carla_transport_pause.restype = None
  1151. self.lib.carla_transport_relocate.argtypes = [c_uint32]
  1152. self.lib.carla_transport_relocate.restype = None
  1153. self.lib.carla_get_current_transport_frame.argtypes = None
  1154. self.lib.carla_get_current_transport_frame.restype = c_uint64
  1155. self.lib.carla_get_transport_info.argtypes = None
  1156. self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)
  1157. self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_void_p]
  1158. self.lib.carla_add_plugin.restype = c_bool
  1159. self.lib.carla_remove_plugin.argtypes = [c_uint]
  1160. self.lib.carla_remove_plugin.restype = c_bool
  1161. self.lib.carla_remove_all_plugins.argtypes = None
  1162. self.lib.carla_remove_all_plugins.restype = c_bool
  1163. self.lib.carla_rename_plugin.argtypes = [c_uint, c_char_p]
  1164. self.lib.carla_rename_plugin.restype = c_char_p
  1165. self.lib.carla_clone_plugin.argtypes = [c_uint]
  1166. self.lib.carla_clone_plugin.restype = c_bool
  1167. self.lib.carla_replace_plugin.argtypes = [c_uint]
  1168. self.lib.carla_replace_plugin.restype = c_bool
  1169. self.lib.carla_switch_plugins.argtypes = [c_uint, c_uint]
  1170. self.lib.carla_switch_plugins.restype = c_bool
  1171. self.lib.carla_load_plugin_state.argtypes = [c_uint, c_char_p]
  1172. self.lib.carla_load_plugin_state.restype = c_bool
  1173. self.lib.carla_save_plugin_state.argtypes = [c_uint, c_char_p]
  1174. self.lib.carla_save_plugin_state.restype = c_bool
  1175. self.lib.carla_get_plugin_info.argtypes = [c_uint]
  1176. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  1177. self.lib.carla_get_audio_port_count_info.argtypes = [c_uint]
  1178. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1179. self.lib.carla_get_midi_port_count_info.argtypes = [c_uint]
  1180. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1181. self.lib.carla_get_parameter_count_info.argtypes = [c_uint]
  1182. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  1183. self.lib.carla_get_parameter_info.argtypes = [c_uint, c_uint32]
  1184. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  1185. self.lib.carla_get_parameter_scalepoint_info.argtypes = [c_uint, c_uint32, c_uint32]
  1186. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  1187. self.lib.carla_get_parameter_data.argtypes = [c_uint, c_uint32]
  1188. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  1189. self.lib.carla_get_parameter_ranges.argtypes = [c_uint, c_uint32]
  1190. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  1191. self.lib.carla_get_midi_program_data.argtypes = [c_uint, c_uint32]
  1192. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  1193. self.lib.carla_get_custom_data.argtypes = [c_uint, c_uint32]
  1194. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  1195. self.lib.carla_get_chunk_data.argtypes = [c_uint]
  1196. self.lib.carla_get_chunk_data.restype = c_char_p
  1197. self.lib.carla_get_parameter_count.argtypes = [c_uint]
  1198. self.lib.carla_get_parameter_count.restype = c_uint32
  1199. self.lib.carla_get_program_count.argtypes = [c_uint]
  1200. self.lib.carla_get_program_count.restype = c_uint32
  1201. self.lib.carla_get_midi_program_count.argtypes = [c_uint]
  1202. self.lib.carla_get_midi_program_count.restype = c_uint32
  1203. self.lib.carla_get_custom_data_count.argtypes = [c_uint]
  1204. self.lib.carla_get_custom_data_count.restype = c_uint32
  1205. self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32]
  1206. self.lib.carla_get_parameter_text.restype = c_char_p
  1207. self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32]
  1208. self.lib.carla_get_program_name.restype = c_char_p
  1209. self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32]
  1210. self.lib.carla_get_midi_program_name.restype = c_char_p
  1211. self.lib.carla_get_real_plugin_name.argtypes = [c_uint]
  1212. self.lib.carla_get_real_plugin_name.restype = c_char_p
  1213. self.lib.carla_get_current_program_index.argtypes = [c_uint]
  1214. self.lib.carla_get_current_program_index.restype = c_int32
  1215. self.lib.carla_get_current_midi_program_index.argtypes = [c_uint]
  1216. self.lib.carla_get_current_midi_program_index.restype = c_int32
  1217. self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32]
  1218. self.lib.carla_get_default_parameter_value.restype = c_float
  1219. self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
  1220. self.lib.carla_get_current_parameter_value.restype = c_float
  1221. self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_ushort]
  1222. self.lib.carla_get_input_peak_value.restype = c_float
  1223. self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_ushort]
  1224. self.lib.carla_get_output_peak_value.restype = c_float
  1225. self.lib.carla_set_option.argtypes = [c_uint, c_uint, c_bool]
  1226. self.lib.carla_set_option.restype = None
  1227. self.lib.carla_set_active.argtypes = [c_uint, c_bool]
  1228. self.lib.carla_set_active.restype = None
  1229. self.lib.carla_set_drywet.argtypes = [c_uint, c_float]
  1230. self.lib.carla_set_drywet.restype = None
  1231. self.lib.carla_set_volume.argtypes = [c_uint, c_float]
  1232. self.lib.carla_set_volume.restype = None
  1233. self.lib.carla_set_balance_left.argtypes = [c_uint, c_float]
  1234. self.lib.carla_set_balance_left.restype = None
  1235. self.lib.carla_set_balance_right.argtypes = [c_uint, c_float]
  1236. self.lib.carla_set_balance_right.restype = None
  1237. self.lib.carla_set_panning.argtypes = [c_uint, c_float]
  1238. self.lib.carla_set_panning.restype = None
  1239. self.lib.carla_set_ctrl_channel.argtypes = [c_uint, c_int8]
  1240. self.lib.carla_set_ctrl_channel.restype = None
  1241. self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float]
  1242. self.lib.carla_set_parameter_value.restype = None
  1243. self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16]
  1244. self.lib.carla_set_parameter_midi_cc.restype = None
  1245. self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8]
  1246. self.lib.carla_set_parameter_midi_channel.restype = None
  1247. self.lib.carla_set_program.argtypes = [c_uint, c_uint32]
  1248. self.lib.carla_set_program.restype = None
  1249. self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32]
  1250. self.lib.carla_set_midi_program.restype = None
  1251. self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p]
  1252. self.lib.carla_set_custom_data.restype = None
  1253. self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p]
  1254. self.lib.carla_set_chunk_data.restype = None
  1255. self.lib.carla_prepare_for_save.argtypes = [c_uint]
  1256. self.lib.carla_prepare_for_save.restype = None
  1257. self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8]
  1258. self.lib.carla_send_midi_note.restype = None
  1259. self.lib.carla_show_gui.argtypes = [c_uint, c_bool]
  1260. self.lib.carla_show_gui.restype = None
  1261. self.lib.carla_get_buffer_size.argtypes = None
  1262. self.lib.carla_get_buffer_size.restype = c_uint32
  1263. self.lib.carla_get_sample_rate.argtypes = None
  1264. self.lib.carla_get_sample_rate.restype = c_double
  1265. self.lib.carla_get_last_error.argtypes = None
  1266. self.lib.carla_get_last_error.restype = c_char_p
  1267. self.lib.carla_get_host_osc_url_tcp.argtypes = None
  1268. self.lib.carla_get_host_osc_url_tcp.restype = c_char_p
  1269. self.lib.carla_get_host_osc_url_udp.argtypes = None
  1270. self.lib.carla_get_host_osc_url_udp.restype = c_char_p