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.

1686 lines
52KB

  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, used 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. # Information about a loaded plugin.
  657. # @see carla_get_plugin_info()
  658. class CarlaPluginInfo(Structure):
  659. _fields_ = [
  660. # Plugin type.
  661. ("type", c_enum),
  662. # Plugin category.
  663. ("category", c_enum),
  664. # Plugin hints.
  665. # @see PluginHints
  666. ("hints", c_uint),
  667. # Plugin options available for the user to change.
  668. # @see PluginOptions
  669. ("optionsAvailable", c_uint),
  670. # Plugin options currently enabled.
  671. # Some options are enabled but not available, which means they will always be on.
  672. # @see PluginOptions
  673. ("optionsEnabled", c_uint),
  674. # Plugin filename.
  675. # This can be the plugin binary or resource file.
  676. ("filename", c_char_p),
  677. # Plugin name.
  678. # This name is unique within a Carla instance.
  679. # @see carla_get_real_plugin_name()
  680. ("name", c_char_p),
  681. # Plugin label or URI.
  682. ("label", c_char_p),
  683. # Plugin author/maker.
  684. ("maker", c_char_p),
  685. # Plugin copyright/license.
  686. ("copyright", c_char_p),
  687. # Icon name for this plugin, in lowercase.
  688. # Default is "plugin".
  689. ("iconName", c_char_p),
  690. # Patchbay client Id for this plugin.
  691. # When 0, Id is considered invalid or unused.
  692. ("patchbayClientId", c_int),
  693. # Plugin unique Id.
  694. # This Id is dependant on the plugin type and may sometimes be 0.
  695. ("uniqueId", c_long)
  696. ]
  697. # Information about an internal Carla plugin.
  698. # @see carla_get_internal_plugin_info()
  699. class CarlaNativePluginInfo(Structure):
  700. _fields_ = [
  701. # Plugin category.
  702. ("category", c_enum),
  703. # Plugin hints.
  704. # @see PluginHints
  705. ("hints", c_uint),
  706. # Number of audio inputs.
  707. ("audioIns", c_uint32),
  708. # Number of audio outputs.
  709. ("audioOuts", c_uint32),
  710. # Number of MIDI inputs.
  711. ("midiIns", c_uint32),
  712. # Number of MIDI outputs.
  713. ("midiOuts", c_uint32),
  714. # Number of input parameters.
  715. ("parameterIns", c_uint32),
  716. # Number of output parameters.
  717. ("parameterOuts", c_uint32),
  718. # Plugin name.
  719. ("name", c_char_p),
  720. # Plugin label.
  721. ("label", c_char_p),
  722. # Plugin author/maker.
  723. ("maker", c_char_p),
  724. # Plugin copyright/license.
  725. ("copyright", c_char_p)
  726. ]
  727. # Port count information, used for Audio and MIDI ports and parameters.
  728. # @see carla_get_audio_port_count_info()
  729. # @see carla_get_midi_port_count_info()
  730. # @see carla_get_parameter_count_info()
  731. class CarlaPortCountInfo(Structure):
  732. _fields_ = [
  733. # Number of inputs.
  734. ("ins", c_uint32),
  735. # Number of outputs.
  736. ("outs", c_uint32)
  737. ]
  738. # Parameter information.
  739. # @see carla_get_parameter_info()
  740. class CarlaParameterInfo(Structure):
  741. _fields_ = [
  742. # Parameter name.
  743. ("name", c_char_p),
  744. # Parameter symbol.
  745. ("symbol", c_char_p),
  746. # Parameter unit.
  747. ("unit", c_char_p),
  748. # Number of scale points.
  749. # @see CarlaScalePointInfo
  750. ("scalePointCount", c_uint32)
  751. ]
  752. # Parameter scale point information.
  753. # @see carla_get_parameter_scalepoint_info()
  754. class CarlaScalePointInfo(Structure):
  755. _fields_ = [
  756. # Scale point value.
  757. ("value", c_float),
  758. # Scale point label.
  759. ("label", c_char_p)
  760. ]
  761. # Transport information.
  762. # @see carla_get_transport_info()
  763. class CarlaTransportInfo(Structure):
  764. _fields_ = [
  765. # Wherever transport is playing.
  766. ("playing", c_bool),
  767. # Current transport frame.
  768. ("frame", c_uint64),
  769. # Bar
  770. ("bar", c_int32),
  771. # Beat
  772. ("beat", c_int32),
  773. # Tick
  774. ("tick", c_int32),
  775. # Beats per minute.
  776. ("bpm", c_double)
  777. ]
  778. # ------------------------------------------------------------------------------------------------------------
  779. # Carla Host API (Python compatible stuff)
  780. # @see CarlaPluginInfo
  781. PyCarlaPluginInfo = {
  782. 'type': PLUGIN_NONE,
  783. 'category': PLUGIN_CATEGORY_NONE,
  784. 'hints': 0x0,
  785. 'optionsAvailable': 0x0,
  786. 'optionsEnabled': 0x0,
  787. 'filename': None,
  788. 'name': None,
  789. 'label': None,
  790. 'maker': None,
  791. 'copyright': None,
  792. 'iconName': None,
  793. 'patchbayClientId': 0,
  794. 'uniqueId': 0
  795. }
  796. # @see CarlaPortCountInfo
  797. PyCarlaPortCountInfo = {
  798. 'ins': 0,
  799. 'outs': 0
  800. }
  801. # @see CarlaParameterInfo
  802. PyCarlaParameterInfo = {
  803. 'name': None,
  804. 'symbol': None,
  805. 'unit': None,
  806. 'scalePointCount': 0,
  807. }
  808. # @see CarlaScalePointInfo
  809. PyCarlaScalePointInfo = {
  810. 'value': 0.0,
  811. 'label': None
  812. }
  813. # @see CarlaTransportInfo
  814. PyCarlaTransportInfo = {
  815. "playing": False,
  816. "frame": 0,
  817. "bar": 0,
  818. "beat": 0,
  819. "tick": 0,
  820. "bpm": 0.0
  821. }
  822. # ------------------------------------------------------------------------------------------------------------
  823. # Set BINARY_NATIVE
  824. if HAIKU or LINUX or MACOS:
  825. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  826. elif WINDOWS:
  827. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  828. else:
  829. BINARY_NATIVE = BINARY_OTHER
  830. # ------------------------------------------------------------------------------------------------------------
  831. # Python Host object (Control/Standalone)
  832. class Host(object):
  833. def __init__(self, libName):
  834. object.__init__(self)
  835. self._init(libName)
  836. # Get the complete license text of used third-party code and features.
  837. # Returned string is in basic html format.
  838. def get_complete_license_text(self):
  839. return charPtrToString(self.lib.carla_get_complete_license_text())
  840. # Get all the supported file extensions in carla_load_file().
  841. # Returned string uses this syntax:
  842. # @code
  843. # "*.ext1;*.ext2;*.ext3"
  844. # @endcode
  845. def get_supported_file_extensions(self):
  846. return charPtrToString(self.lib.carla_get_supported_file_extensions())
  847. # Get how many engine drivers are available.
  848. def get_engine_driver_count(self):
  849. return int(self.lib.carla_get_engine_driver_count())
  850. # Get an engine driver name.
  851. # @param index Driver index
  852. def get_engine_driver_name(self, index):
  853. return charPtrToString(self.lib.carla_get_engine_driver_name(index))
  854. # Get the device names of an engine driver.
  855. # @param index Driver index
  856. def get_engine_driver_device_names(self, index):
  857. return charPtrPtrToStringList(self.lib.carla_get_engine_driver_device_names(index))
  858. # Get information about a device driver.
  859. # @param index Driver index
  860. # @param name Device name
  861. def get_engine_driver_device_info(self, index, name):
  862. return structToDict(self.lib.carla_get_engine_driver_device_info(index, name))
  863. # Get how many internal plugins are available.
  864. def get_internal_plugin_count(self):
  865. return int(self.lib.carla_get_internal_plugin_count())
  866. # Get information about an internal plugin.
  867. # @param index Internal plugin Id
  868. def get_internal_plugin_info(self, index):
  869. return structToDict(self.lib.carla_get_internal_plugin_info(index).contents)
  870. # Initialize the engine.
  871. # Make sure to call carla_engine_idle() at regular intervals afterwards.
  872. # @param driverName Driver to use
  873. # @param clientName Engine master client name
  874. def engine_init(self, driverName, clientName):
  875. return bool(self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8")))
  876. # Close the engine.
  877. # This function always closes the engine even if it returns false.
  878. # In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
  879. def engine_close(self):
  880. return bool(self.lib.carla_engine_close())
  881. # Idle the engine.
  882. # Do not call this if the engine is not running.
  883. def engine_idle(self):
  884. self.lib.carla_engine_idle()
  885. # Check if the engine is running.
  886. def is_engine_running(self):
  887. return bool(self.lib.carla_is_engine_running())
  888. # Tell the engine it's about to close.
  889. # This is used to prevent the engine thread(s) from reactivating.
  890. def set_engine_about_to_close(self):
  891. self.lib.carla_set_engine_about_to_close()
  892. # Set the engine callback function.
  893. # @param func Callback function
  894. def set_engine_callback(self, func):
  895. self._engineCallback = EngineCallbackFunc(func)
  896. self.lib.carla_set_engine_callback(self._engineCallback, None)
  897. # Set an engine option.
  898. # @param option Option
  899. # @param value Value as number
  900. # @param valueStr Value as string
  901. def set_engine_option(self, option, value, valueStr):
  902. self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))
  903. # Set the file callback function.
  904. # @param func Callback function
  905. # @param ptr Callback pointer
  906. def set_file_callback(self, func):
  907. self._fileCallback = FileCallbackFunc(func)
  908. self.lib.carla_set_file_callback(self._fileCallback, None)
  909. # Load a file of any type.\n
  910. # This will try to load a generic file as a plugin,
  911. # either by direct handling (Csound, GIG, SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
  912. # @param Filename Filename
  913. # @see carla_get_supported_file_extensions()
  914. def load_file(self, filename):
  915. return bool(self.lib.carla_load_file(filename.encode("utf-8")))
  916. # Load a Carla project file.
  917. # @param Filename Filename
  918. # @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
  919. def load_project(self, filename):
  920. return bool(self.lib.carla_load_project(filename.encode("utf-8")))
  921. # Save current project to a file.
  922. # @param Filename Filename
  923. def save_project(self, filename):
  924. return bool(self.lib.carla_save_project(filename.encode("utf-8")))
  925. def patchbay_connect(self, portIdA, portIdB):
  926. return bool(self.lib.carla_patchbay_connect(portIdA, portIdB))
  927. def patchbay_disconnect(self, connectionId):
  928. return bool(self.lib.carla_patchbay_disconnect(connectionId))
  929. def patchbay_refresh(self):
  930. return bool(self.lib.carla_patchbay_refresh())
  931. def transport_play(self):
  932. self.lib.carla_transport_play()
  933. def transport_pause(self):
  934. self.lib.carla_transport_pause()
  935. def transport_relocate(self, frames):
  936. self.lib.carla_transport_relocate(frames)
  937. def get_current_transport_frame(self):
  938. return bool(self.lib.carla_get_current_transport_frame())
  939. def get_transport_info(self):
  940. return structToDict(self.lib.carla_get_transport_info().contents)
  941. def add_plugin(self, btype, ptype, filename, name, label, extraStuff):
  942. cfilename = filename.encode("utf-8") if filename else None
  943. cname = name.encode("utf-8") if name else None
  944. clabel = label.encode("utf-8") if label else None
  945. return bool(self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, cast(extraStuff, c_void_p)))
  946. def remove_plugin(self, pluginId):
  947. return bool(self.lib.carla_remove_plugin(pluginId))
  948. def remove_all_plugins(self):
  949. return bool(self.lib.carla_remove_all_plugins())
  950. def rename_plugin(self, pluginId, newName):
  951. return bool(self.lib.carla_rename_plugin(pluginId, newName.encode("utf-8")))
  952. def clone_plugin(self, pluginId):
  953. return bool(self.lib.carla_clone_plugin(pluginId))
  954. def replace_plugin(self, pluginId):
  955. return bool(self.lib.carla_replace_plugin(pluginId))
  956. def switch_plugins(self, pluginIdA, pluginIdB):
  957. return bool(self.lib.carla_switch_plugins(pluginIdA, pluginIdB))
  958. def load_plugin_state(self, pluginId, filename):
  959. return bool(self.lib.carla_load_plugin_state(pluginId, filename.encode("utf-8")))
  960. def save_plugin_state(self, pluginId, filename):
  961. return bool(self.lib.carla_save_plugin_state(pluginId, filename.encode("utf-8")))
  962. def get_plugin_info(self, pluginId):
  963. return structToDict(self.lib.carla_get_plugin_info(pluginId).contents)
  964. def get_audio_port_count_info(self, pluginId):
  965. return structToDict(self.lib.carla_get_audio_port_count_info(pluginId).contents)
  966. def get_midi_port_count_info(self, pluginId):
  967. return structToDict(self.lib.carla_get_midi_port_count_info(pluginId).contents)
  968. def get_parameter_count_info(self, pluginId):
  969. return structToDict(self.lib.carla_get_parameter_count_info(pluginId).contents)
  970. def get_parameter_info(self, pluginId, parameterId):
  971. return structToDict(self.lib.carla_get_parameter_info(pluginId, parameterId).contents)
  972. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  973. return structToDict(self.lib.carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId).contents)
  974. def get_parameter_data(self, pluginId, parameterId):
  975. return structToDict(self.lib.carla_get_parameter_data(pluginId, parameterId).contents)
  976. def get_parameter_ranges(self, pluginId, parameterId):
  977. return structToDict(self.lib.carla_get_parameter_ranges(pluginId, parameterId).contents)
  978. def get_midi_program_data(self, pluginId, midiProgramId):
  979. return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents)
  980. def get_custom_data(self, pluginId, customDataId):
  981. return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents)
  982. def get_chunk_data(self, pluginId):
  983. return charPtrToString(self.lib.carla_get_chunk_data(pluginId))
  984. def get_parameter_count(self, pluginId):
  985. return int(self.lib.carla_get_parameter_count(pluginId))
  986. def get_program_count(self, pluginId):
  987. return int(self.lib.carla_get_program_count(pluginId))
  988. def get_midi_program_count(self, pluginId):
  989. return int(self.lib.carla_get_midi_program_count(pluginId))
  990. def get_custom_data_count(self, pluginId):
  991. return int(self.lib.carla_get_custom_data_count(pluginId))
  992. def get_parameter_text(self, pluginId, parameterId):
  993. return charPtrToString(self.lib.carla_get_parameter_text(pluginId, parameterId))
  994. def get_program_name(self, pluginId, programId):
  995. return charPtrToString(self.lib.carla_get_program_name(pluginId, programId))
  996. def get_midi_program_name(self, pluginId, midiProgramId):
  997. return charPtrToString(self.lib.carla_get_midi_program_name(pluginId, midiProgramId))
  998. def get_real_plugin_name(self, pluginId):
  999. return charPtrToString(self.lib.carla_get_real_plugin_name(pluginId))
  1000. def get_current_program_index(self, pluginId):
  1001. return self.lib.carla_get_current_program_index(pluginId)
  1002. def get_current_midi_program_index(self, pluginId):
  1003. return self.lib.carla_get_current_midi_program_index(pluginId)
  1004. def get_default_parameter_value(self, pluginId, parameterId):
  1005. return self.lib.carla_get_default_parameter_value(pluginId, parameterId)
  1006. def get_current_parameter_value(self, pluginId, parameterId):
  1007. return self.lib.carla_get_current_parameter_value(pluginId, parameterId)
  1008. def get_input_peak_value(self, pluginId, portId):
  1009. return self.lib.carla_get_input_peak_value(pluginId, portId)
  1010. def get_output_peak_value(self, pluginId, portId):
  1011. return self.lib.carla_get_output_peak_value(pluginId, portId)
  1012. def set_option(self, pluginId, option, yesNo):
  1013. self.lib.carla_set_option(pluginId, option, yesNo)
  1014. def set_active(self, pluginId, onOff):
  1015. self.lib.carla_set_active(pluginId, onOff)
  1016. def set_drywet(self, pluginId, value):
  1017. self.lib.carla_set_drywet(pluginId, value)
  1018. def set_volume(self, pluginId, value):
  1019. self.lib.carla_set_volume(pluginId, value)
  1020. def set_balance_left(self, pluginId, value):
  1021. self.lib.carla_set_balance_left(pluginId, value)
  1022. def set_balance_right(self, pluginId, value):
  1023. self.lib.carla_set_balance_right(pluginId, value)
  1024. def set_panning(self, pluginId, value):
  1025. self.lib.carla_set_panning(pluginId, value)
  1026. def set_ctrl_channel(self, pluginId, channel):
  1027. self.lib.carla_set_ctrl_channel(pluginId, channel)
  1028. def set_parameter_value(self, pluginId, parameterId, value):
  1029. self.lib.carla_set_parameter_value(pluginId, parameterId, value)
  1030. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  1031. self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc)
  1032. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  1033. self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel)
  1034. def set_program(self, pluginId, programId):
  1035. self.lib.carla_set_program(pluginId, programId)
  1036. def set_midi_program(self, pluginId, midiProgramId):
  1037. self.lib.carla_set_midi_program(pluginId, midiProgramId)
  1038. def set_custom_data(self, pluginId, type_, key, value):
  1039. self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8"))
  1040. def set_chunk_data(self, pluginId, chunkData):
  1041. self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8"))
  1042. def prepare_for_save(self, pluginId):
  1043. self.lib.carla_prepare_for_save(pluginId)
  1044. def send_midi_note(self, pluginId, channel, note, velocity):
  1045. self.lib.carla_send_midi_note(pluginId, channel, note, velocity)
  1046. def show_gui(self, pluginId, yesNo):
  1047. self.lib.carla_show_gui(pluginId, yesNo)
  1048. def get_last_error(self):
  1049. return self.lib.carla_get_last_error()
  1050. def get_host_osc_url_tcp(self):
  1051. return self.lib.carla_get_host_osc_url_tcp()
  1052. def get_host_osc_url_udp(self):
  1053. return self.lib.carla_get_host_osc_url_udp()
  1054. def get_buffer_size(self):
  1055. return self.lib.carla_get_buffer_size()
  1056. def get_sample_rate(self):
  1057. return self.lib.carla_get_sample_rate()
  1058. def nsm_announce(self, url, appName_, pid):
  1059. self.lib.carla_nsm_announce(url.encode("utf-8"), appName_.encode("utf-8"), pid)
  1060. def nsm_ready(self):
  1061. self.lib.carla_nsm_ready()
  1062. def nsm_reply_open(self):
  1063. self.lib.carla_nsm_reply_open()
  1064. def nsm_reply_save(self):
  1065. self.lib.carla_nsm_reply_save()
  1066. def _init(self, libName):
  1067. self.lib = cdll.LoadLibrary(libName)
  1068. self.lib.carla_get_complete_license_text.argtypes = None
  1069. self.lib.carla_get_complete_license_text.restype = c_char_p
  1070. self.lib.carla_get_supported_file_extensions.argtypes = None
  1071. self.lib.carla_get_supported_file_extensions.restype = c_char_p
  1072. self.lib.carla_get_engine_driver_count.argtypes = None
  1073. self.lib.carla_get_engine_driver_count.restype = c_uint
  1074. self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
  1075. self.lib.carla_get_engine_driver_name.restype = c_char_p
  1076. self.lib.carla_get_engine_driver_device_names.argtypes = [c_uint]
  1077. self.lib.carla_get_engine_driver_device_names.restype = POINTER(c_char_p)
  1078. self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p]
  1079. self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo)
  1080. self.lib.carla_get_internal_plugin_count.argtypes = None
  1081. self.lib.carla_get_internal_plugin_count.restype = c_uint
  1082. self.lib.carla_get_internal_plugin_info.argtypes = [c_uint]
  1083. self.lib.carla_get_internal_plugin_info.restype = POINTER(CarlaNativePluginInfo)
  1084. self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p]
  1085. self.lib.carla_engine_init.restype = c_bool
  1086. self.lib.carla_engine_close.argtypes = None
  1087. self.lib.carla_engine_close.restype = c_bool
  1088. self.lib.carla_engine_idle.argtypes = None
  1089. self.lib.carla_engine_idle.restype = None
  1090. self.lib.carla_is_engine_running.argtypes = None
  1091. self.lib.carla_is_engine_running.restype = c_bool
  1092. self.lib.carla_set_engine_about_to_close.argtypes = None
  1093. self.lib.carla_set_engine_about_to_close.restype = None
  1094. self.lib.carla_set_engine_callback.argtypes = [EngineCallbackFunc, c_void_p]
  1095. self.lib.carla_set_engine_callback.restype = None
  1096. self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
  1097. self.lib.carla_set_engine_option.restype = None
  1098. self.lib.carla_load_file.argtypes = [c_char_p]
  1099. self.lib.carla_load_file.restype = c_bool
  1100. self.lib.carla_load_project.argtypes = [c_char_p]
  1101. self.lib.carla_load_project.restype = c_bool
  1102. self.lib.carla_save_project.argtypes = [c_char_p]
  1103. self.lib.carla_save_project.restype = c_bool
  1104. self.lib.carla_patchbay_connect.argtypes = [c_int, c_int]
  1105. self.lib.carla_patchbay_connect.restype = c_bool
  1106. self.lib.carla_patchbay_disconnect.argtypes = [c_int]
  1107. self.lib.carla_patchbay_disconnect.restype = c_bool
  1108. self.lib.carla_patchbay_refresh.argtypes = None
  1109. self.lib.carla_patchbay_refresh.restype = c_bool
  1110. self.lib.carla_transport_play.argtypes = None
  1111. self.lib.carla_transport_play.restype = None
  1112. self.lib.carla_transport_pause.argtypes = None
  1113. self.lib.carla_transport_pause.restype = None
  1114. self.lib.carla_transport_relocate.argtypes = [c_uint32]
  1115. self.lib.carla_transport_relocate.restype = None
  1116. self.lib.carla_get_current_transport_frame.argtypes = None
  1117. self.lib.carla_get_current_transport_frame.restype = c_uint64
  1118. self.lib.carla_get_transport_info.argtypes = None
  1119. self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)
  1120. self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_void_p]
  1121. self.lib.carla_add_plugin.restype = c_bool
  1122. self.lib.carla_remove_plugin.argtypes = [c_uint]
  1123. self.lib.carla_remove_plugin.restype = c_bool
  1124. self.lib.carla_remove_all_plugins.argtypes = None
  1125. self.lib.carla_remove_all_plugins.restype = c_bool
  1126. self.lib.carla_rename_plugin.argtypes = [c_uint, c_char_p]
  1127. self.lib.carla_rename_plugin.restype = c_char_p
  1128. self.lib.carla_clone_plugin.argtypes = [c_uint]
  1129. self.lib.carla_clone_plugin.restype = c_bool
  1130. self.lib.carla_replace_plugin.argtypes = [c_uint]
  1131. self.lib.carla_replace_plugin.restype = c_bool
  1132. self.lib.carla_switch_plugins.argtypes = [c_uint, c_uint]
  1133. self.lib.carla_switch_plugins.restype = c_bool
  1134. self.lib.carla_load_plugin_state.argtypes = [c_uint, c_char_p]
  1135. self.lib.carla_load_plugin_state.restype = c_bool
  1136. self.lib.carla_save_plugin_state.argtypes = [c_uint, c_char_p]
  1137. self.lib.carla_save_plugin_state.restype = c_bool
  1138. self.lib.carla_get_plugin_info.argtypes = [c_uint]
  1139. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  1140. self.lib.carla_get_audio_port_count_info.argtypes = [c_uint]
  1141. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1142. self.lib.carla_get_midi_port_count_info.argtypes = [c_uint]
  1143. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1144. self.lib.carla_get_parameter_count_info.argtypes = [c_uint]
  1145. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  1146. self.lib.carla_get_parameter_info.argtypes = [c_uint, c_uint32]
  1147. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  1148. self.lib.carla_get_parameter_scalepoint_info.argtypes = [c_uint, c_uint32, c_uint32]
  1149. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  1150. self.lib.carla_get_parameter_data.argtypes = [c_uint, c_uint32]
  1151. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  1152. self.lib.carla_get_parameter_ranges.argtypes = [c_uint, c_uint32]
  1153. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  1154. self.lib.carla_get_midi_program_data.argtypes = [c_uint, c_uint32]
  1155. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  1156. self.lib.carla_get_custom_data.argtypes = [c_uint, c_uint32]
  1157. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  1158. self.lib.carla_get_chunk_data.argtypes = [c_uint]
  1159. self.lib.carla_get_chunk_data.restype = c_char_p
  1160. self.lib.carla_get_parameter_count.argtypes = [c_uint]
  1161. self.lib.carla_get_parameter_count.restype = c_uint32
  1162. self.lib.carla_get_program_count.argtypes = [c_uint]
  1163. self.lib.carla_get_program_count.restype = c_uint32
  1164. self.lib.carla_get_midi_program_count.argtypes = [c_uint]
  1165. self.lib.carla_get_midi_program_count.restype = c_uint32
  1166. self.lib.carla_get_custom_data_count.argtypes = [c_uint]
  1167. self.lib.carla_get_custom_data_count.restype = c_uint32
  1168. self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32]
  1169. self.lib.carla_get_parameter_text.restype = c_char_p
  1170. self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32]
  1171. self.lib.carla_get_program_name.restype = c_char_p
  1172. self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32]
  1173. self.lib.carla_get_midi_program_name.restype = c_char_p
  1174. self.lib.carla_get_real_plugin_name.argtypes = [c_uint]
  1175. self.lib.carla_get_real_plugin_name.restype = c_char_p
  1176. self.lib.carla_get_current_program_index.argtypes = [c_uint]
  1177. self.lib.carla_get_current_program_index.restype = c_int32
  1178. self.lib.carla_get_current_midi_program_index.argtypes = [c_uint]
  1179. self.lib.carla_get_current_midi_program_index.restype = c_int32
  1180. self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32]
  1181. self.lib.carla_get_default_parameter_value.restype = c_float
  1182. self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
  1183. self.lib.carla_get_current_parameter_value.restype = c_float
  1184. self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_ushort]
  1185. self.lib.carla_get_input_peak_value.restype = c_float
  1186. self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_ushort]
  1187. self.lib.carla_get_output_peak_value.restype = c_float
  1188. self.lib.carla_set_option.argtypes = [c_uint, c_uint, c_bool]
  1189. self.lib.carla_set_option.restype = None
  1190. self.lib.carla_set_active.argtypes = [c_uint, c_bool]
  1191. self.lib.carla_set_active.restype = None
  1192. self.lib.carla_set_drywet.argtypes = [c_uint, c_float]
  1193. self.lib.carla_set_drywet.restype = None
  1194. self.lib.carla_set_volume.argtypes = [c_uint, c_float]
  1195. self.lib.carla_set_volume.restype = None
  1196. self.lib.carla_set_balance_left.argtypes = [c_uint, c_float]
  1197. self.lib.carla_set_balance_left.restype = None
  1198. self.lib.carla_set_balance_right.argtypes = [c_uint, c_float]
  1199. self.lib.carla_set_balance_right.restype = None
  1200. self.lib.carla_set_panning.argtypes = [c_uint, c_float]
  1201. self.lib.carla_set_panning.restype = None
  1202. self.lib.carla_set_ctrl_channel.argtypes = [c_uint, c_int8]
  1203. self.lib.carla_set_ctrl_channel.restype = None
  1204. self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float]
  1205. self.lib.carla_set_parameter_value.restype = None
  1206. self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16]
  1207. self.lib.carla_set_parameter_midi_cc.restype = None
  1208. self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8]
  1209. self.lib.carla_set_parameter_midi_channel.restype = None
  1210. self.lib.carla_set_program.argtypes = [c_uint, c_uint32]
  1211. self.lib.carla_set_program.restype = None
  1212. self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32]
  1213. self.lib.carla_set_midi_program.restype = None
  1214. self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p]
  1215. self.lib.carla_set_custom_data.restype = None
  1216. self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p]
  1217. self.lib.carla_set_chunk_data.restype = None
  1218. self.lib.carla_prepare_for_save.argtypes = [c_uint]
  1219. self.lib.carla_prepare_for_save.restype = None
  1220. self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8]
  1221. self.lib.carla_send_midi_note.restype = None
  1222. self.lib.carla_show_gui.argtypes = [c_uint, c_bool]
  1223. self.lib.carla_show_gui.restype = None
  1224. self.lib.carla_get_buffer_size.argtypes = None
  1225. self.lib.carla_get_buffer_size.restype = c_uint32
  1226. self.lib.carla_get_sample_rate.argtypes = None
  1227. self.lib.carla_get_sample_rate.restype = c_double
  1228. self.lib.carla_get_last_error.argtypes = None
  1229. self.lib.carla_get_last_error.restype = c_char_p
  1230. self.lib.carla_get_host_osc_url_tcp.argtypes = None
  1231. self.lib.carla_get_host_osc_url_tcp.restype = c_char_p
  1232. self.lib.carla_get_host_osc_url_udp.argtypes = None
  1233. self.lib.carla_get_host_osc_url_udp.restype = c_char_p
  1234. return
  1235. self.lib.carla_nsm_announce.argtypes = [c_char_p, c_char_p, c_int]
  1236. self.lib.carla_nsm_announce.restype = None
  1237. self.lib.carla_nsm_ready.argtypes = None
  1238. self.lib.carla_nsm_ready.restype = None
  1239. self.lib.carla_nsm_reply_open.argtypes = None
  1240. self.lib.carla_nsm_reply_open.restype = None
  1241. self.lib.carla_nsm_reply_save.argtypes = None
  1242. self.lib.carla_nsm_reply_save.restype = None