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.

1531 lines
47KB

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