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.

4026 lines
132KB

  1. #!/usr/bin/env python3
  2. # SPDX-FileCopyrightText: 2011-2025 Filipe Coelho <falktx@falktx.com>
  3. # SPDX-License-Identifier: GPL-2.0-or-later
  4. # ---------------------------------------------------------------------------------------------------------------------
  5. # Imports (Global)
  6. from abc import abstractmethod
  7. from struct import pack
  8. # ---------------------------------------------------------------------------------------------------------------------
  9. # Imports (ctypes)
  10. from ctypes import (
  11. c_bool, c_char_p, c_double, c_float, c_int, c_long, c_longdouble, c_longlong, c_ubyte, c_uint, c_void_p,
  12. c_int8, c_int16, c_int32, c_int64, c_uint8, c_uint16, c_uint32, c_uint64,
  13. cast, Structure,
  14. CDLL, CFUNCTYPE, RTLD_GLOBAL, RTLD_LOCAL, POINTER
  15. )
  16. # ------------------------------------------------------------------------------------------------------------
  17. # Imports (Custom)
  18. from common import (
  19. CARLA_OS_64BIT,
  20. CARLA_OS_BSD,
  21. CARLA_OS_GNU_HURD,
  22. CARLA_OS_HAIKU,
  23. CARLA_OS_LINUX,
  24. CARLA_OS_MAC,
  25. CARLA_OS_UNIX,
  26. CARLA_OS_WASM,
  27. CARLA_OS_WIN,
  28. CARLA_OS_WIN32,
  29. CARLA_OS_WIN64,
  30. CARLA_VERSION_HEX,
  31. CARLA_VERSION_STRING,
  32. CARLA_VERSION_STRMIN,
  33. )
  34. # ---------------------------------------------------------------------------------------------------------------------
  35. # Define custom types
  36. c_enum = c_int
  37. c_uintptr = c_uint64 if CARLA_OS_64BIT else c_uint32
  38. # ---------------------------------------------------------------------------------------------------------------------
  39. # Convert a ctypes c_char_p into a python string
  40. def charPtrToString(charPtr):
  41. if not charPtr:
  42. return ""
  43. if isinstance(charPtr, str):
  44. return charPtr
  45. return charPtr.decode("utf-8", errors="ignore")
  46. # ---------------------------------------------------------------------------------------------------------------------
  47. # Convert a ctypes POINTER(c_char_p) into a python string list
  48. def charPtrPtrToStringList(charPtrPtr):
  49. if not charPtrPtr:
  50. return []
  51. i = 0
  52. charPtr = charPtrPtr[0]
  53. strList = []
  54. while charPtr:
  55. strList.append(charPtr.decode("utf-8", errors="ignore"))
  56. i += 1
  57. charPtr = charPtrPtr[i]
  58. return strList
  59. # ---------------------------------------------------------------------------------------------------------------------
  60. # Convert a ctypes POINTER(c_<num>) into a python number list
  61. def numPtrToList(numPtr):
  62. if not numPtr:
  63. return []
  64. i = 0
  65. num = numPtr[0] #.value
  66. numList = []
  67. while num not in (0, 0.0):
  68. numList.append(num)
  69. i += 1
  70. num = numPtr[i] #.value
  71. return numList
  72. # ---------------------------------------------------------------------------------------------------------------------
  73. # Convert a ctypes value into a python one
  74. c_int_types = (c_int, c_int8, c_int16, c_int32, c_int64,
  75. c_uint, c_uint8, c_uint16, c_uint32, c_uint64, c_long, c_longlong)
  76. c_float_types = (c_float, c_double, c_longdouble)
  77. c_intp_types = tuple(POINTER(i) for i in c_int_types)
  78. c_floatp_types = tuple(POINTER(i) for i in c_float_types)
  79. def toPythonType(value, attr):
  80. if isinstance(value, (bool, int, float)):
  81. return value
  82. if isinstance(value, bytes):
  83. return charPtrToString(value)
  84. # pylint: disable=consider-merging-isinstance
  85. if isinstance(value, c_intp_types) or isinstance(value, c_floatp_types):
  86. return numPtrToList(value)
  87. # pylint: enable=consider-merging-isinstance
  88. if isinstance(value, POINTER(c_char_p)):
  89. return charPtrPtrToStringList(value)
  90. print("..............", attr, ".....................", value, ":", type(value))
  91. return value
  92. # ---------------------------------------------------------------------------------------------------------------------
  93. # Convert a ctypes struct into a python dict
  94. def structToDict(struct):
  95. # pylint: disable=protected-access
  96. return dict((attr, toPythonType(getattr(struct, attr), attr)) for attr, value in struct._fields_)
  97. # pylint: enable=protected-access
  98. # ---------------------------------------------------------------------------------------------------------------------
  99. # Carla Backend API (base definitions)
  100. # Maximum default number of loadable plugins.
  101. MAX_DEFAULT_PLUGINS = 512
  102. # Maximum number of loadable plugins in rack mode.
  103. MAX_RACK_PLUGINS = 64
  104. # Maximum number of loadable plugins in patchbay mode.
  105. MAX_PATCHBAY_PLUGINS = 255
  106. # Maximum default number of parameters allowed.
  107. # @see ENGINE_OPTION_MAX_PARAMETERS
  108. MAX_DEFAULT_PARAMETERS = 200
  109. # The "plugin Id" for the global Carla instance.
  110. # Currently only used for audio peaks.
  111. MAIN_CARLA_PLUGIN_ID = 0xFFFF
  112. # ---------------------------------------------------------------------------------------------------------------------
  113. # Engine Driver Device Hints
  114. # Various engine driver device hints.
  115. # @see carla_get_engine_driver_device_info()
  116. # Engine driver device has custom control-panel.
  117. ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL = 0x1
  118. # Engine driver device can use a triple-buffer (3 number of periods instead of the usual 2).
  119. # @see ENGINE_OPTION_AUDIO_NUM_PERIODS
  120. ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER = 0x2
  121. # Engine driver device can change buffer-size on the fly.
  122. # @see ENGINE_OPTION_AUDIO_BUFFER_SIZE
  123. ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE = 0x4
  124. # Engine driver device can change sample-rate on the fly.
  125. # @see ENGINE_OPTION_AUDIO_SAMPLE_RATE
  126. ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x8
  127. # ---------------------------------------------------------------------------------------------------------------------
  128. # Plugin Hints
  129. # Various plugin hints.
  130. # @see carla_get_plugin_info()
  131. # Plugin is a bridge.
  132. # This hint is required because "bridge" itself is not a plugin type.
  133. PLUGIN_IS_BRIDGE = 0x001
  134. # Plugin is hard real-time safe.
  135. PLUGIN_IS_RTSAFE = 0x002
  136. # Plugin is a synth (produces sound).
  137. PLUGIN_IS_SYNTH = 0x004
  138. # Plugin has its own custom UI.
  139. # @see carla_show_custom_ui()
  140. PLUGIN_HAS_CUSTOM_UI = 0x008
  141. # Plugin can use internal Dry/Wet control.
  142. PLUGIN_CAN_DRYWET = 0x010
  143. # Plugin can use internal Volume control.
  144. PLUGIN_CAN_VOLUME = 0x020
  145. # Plugin can use internal (Stereo) Balance controls.
  146. PLUGIN_CAN_BALANCE = 0x040
  147. # Plugin can use internal (Mono) Panning control.
  148. PLUGIN_CAN_PANNING = 0x080
  149. # Plugin needs a constant, fixed-size audio buffer.
  150. PLUGIN_NEEDS_FIXED_BUFFERS = 0x100
  151. # Plugin needs to receive all UI events in the main thread.
  152. PLUGIN_NEEDS_UI_MAIN_THREAD = 0x200
  153. # Plugin uses 1 program per MIDI channel.
  154. # @note: Only used in some internal plugins and sf2 files.
  155. PLUGIN_USES_MULTI_PROGS = 0x400
  156. # Plugin can make use of inline display API.
  157. PLUGIN_HAS_INLINE_DISPLAY = 0x800
  158. # Plugin has its own custom UI which can be embed into another Window.
  159. # @see carla_embed_custom_ui()
  160. # @note This is very experimental and subject to change at this point
  161. PLUGIN_HAS_CUSTOM_EMBED_UI = 0x1000
  162. # Plugin custom UI is a fake one that simply invokes an open file browser dialog.
  163. PLUGIN_HAS_CUSTOM_UI_USING_FILE_OPEN = 0x2000
  164. # Plugin needs all idle events in the main thread.
  165. # @note Not possible on all engine implementations.
  166. PLUGIN_NEEDS_MAIN_THREAD_IDLE = 0x4000
  167. # Plugin has its own custom UI which is user resizable.
  168. PLUGIN_HAS_CUSTOM_RESIZABLE_UI = 0x8000
  169. # ---------------------------------------------------------------------------------------------------------------------
  170. # Plugin Options
  171. # Various plugin options.
  172. # @see carla_get_plugin_info() and carla_set_option()
  173. # Use constant/fixed-size audio buffers.
  174. PLUGIN_OPTION_FIXED_BUFFERS = 0x001
  175. # Force mono plugin as stereo.
  176. PLUGIN_OPTION_FORCE_STEREO = 0x002
  177. # Map MIDI programs to plugin programs.
  178. PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004
  179. # Use chunks to save and restore data instead of parameter values.
  180. PLUGIN_OPTION_USE_CHUNKS = 0x008
  181. # Send MIDI control change events.
  182. PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010
  183. # Send MIDI channel pressure events.
  184. PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020
  185. # Send MIDI note after-touch events.
  186. PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040
  187. # Send MIDI pitch-bend events.
  188. PLUGIN_OPTION_SEND_PITCHBEND = 0x080
  189. # Send MIDI all-sounds/notes-off events, single note-offs otherwise.
  190. PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100
  191. # Send MIDI bank/program changes.
  192. # @note: This option conflicts with PLUGIN_OPTION_MAP_PROGRAM_CHANGES and cannot be used at the same time.
  193. PLUGIN_OPTION_SEND_PROGRAM_CHANGES = 0x200
  194. # SSkip sending MIDI note events.
  195. # This if off-by-default as a way to keep backwards compatibility.
  196. # We always want notes enabled by default, not the contrary.
  197. PLUGIN_OPTION_SKIP_SENDING_NOTES = 0x400
  198. # Special flag to indicate that plugin options are not yet set.
  199. # This flag exists because 0x0 as an option value is a valid one, so we need something else to indicate "null-ness".
  200. PLUGIN_OPTIONS_NULL = 0x10000
  201. # ---------------------------------------------------------------------------------------------------------------------
  202. # Parameter Hints
  203. # Various parameter hints.
  204. # @see CarlaPlugin::getParameterData() and carla_get_parameter_data()
  205. # Parameter value is boolean.
  206. PARAMETER_IS_BOOLEAN = 0x001
  207. # Parameter value is integer.
  208. PARAMETER_IS_INTEGER = 0x002
  209. # Parameter value is logarithmic.
  210. PARAMETER_IS_LOGARITHMIC = 0x004
  211. # Parameter is enabled.
  212. # It can be viewed, changed and stored.
  213. PARAMETER_IS_ENABLED = 0x010
  214. # Parameter is automatable (real-time safe).
  215. PARAMETER_IS_AUTOMATABLE = 0x020
  216. # Parameter is read-only.
  217. # It cannot be changed.
  218. PARAMETER_IS_READ_ONLY = 0x040
  219. # Parameter needs sample rate to work.
  220. # Value and ranges are multiplied by sample rate on usage and divided by sample rate on save.
  221. PARAMETER_USES_SAMPLERATE = 0x100
  222. # Parameter uses scale points to define internal values in a meaningful way.
  223. PARAMETER_USES_SCALEPOINTS = 0x200
  224. # Parameter uses custom text for displaying its value.
  225. # @see carla_get_parameter_text()
  226. PARAMETER_USES_CUSTOM_TEXT = 0x400
  227. # Parameter can be turned into a CV control.
  228. PARAMETER_CAN_BE_CV_CONTROLLED = 0x800
  229. # Parameter should not be saved as part of the project/session.
  230. # @note only valid for parameter inputs.
  231. PARAMETER_IS_NOT_SAVED = 0x1000
  232. # ---------------------------------------------------------------------------------------------------------------------
  233. # Mapped Parameter Flags
  234. # Various flags for parameter mappings.
  235. # @see ParameterData::mappedFlags
  236. PARAMETER_MAPPING_MIDI_DELTA = 0x001
  237. # ---------------------------------------------------------------------------------------------------------------------
  238. # Patchbay Port Hints
  239. # Various patchbay port hints.
  240. # Patchbay port is input.
  241. # When this hint is not set, port is assumed to be output.
  242. PATCHBAY_PORT_IS_INPUT = 0x01
  243. # Patchbay port is of Audio type.
  244. PATCHBAY_PORT_TYPE_AUDIO = 0x02
  245. # Patchbay port is of CV type (Control Voltage).
  246. PATCHBAY_PORT_TYPE_CV = 0x04
  247. # Patchbay port is of MIDI type.
  248. PATCHBAY_PORT_TYPE_MIDI = 0x08
  249. # Patchbay port is of OSC type.
  250. PATCHBAY_PORT_TYPE_OSC = 0x10
  251. # ---------------------------------------------------------------------------------------------------------------------
  252. # Patchbay Port Group Hints
  253. # Various patchbay port group hints.
  254. # Indicates that this group should be considered the "main" input.
  255. PATCHBAY_PORT_GROUP_MAIN_INPUT = 0x01
  256. # Indicates that this group should be considered the "main" output.
  257. PATCHBAY_PORT_GROUP_MAIN_OUTPUT = 0x02
  258. # A stereo port group, where the 1st port is left and the 2nd is right.
  259. PATCHBAY_PORT_GROUP_STEREO = 0x04
  260. # A mid-side stereo group, where the 1st port is center and the 2nd is side.
  261. PATCHBAY_PORT_GROUP_MID_SIDE = 0x08
  262. # ---------------------------------------------------------------------------------------------------------------------
  263. # Custom Data Types
  264. # These types define how the value in the CustomData struct is stored.
  265. # @see CustomData.type
  266. # Boolean string type URI.
  267. # Only "true" and "false" are valid values.
  268. CUSTOM_DATA_TYPE_BOOLEAN = "http://kxstudio.sf.net/ns/carla/boolean"
  269. # Chunk type URI.
  270. CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"
  271. # Property type URI.
  272. CUSTOM_DATA_TYPE_PROPERTY = "http://kxstudio.sf.net/ns/carla/property"
  273. # String type URI.
  274. CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string"
  275. # ---------------------------------------------------------------------------------------------------------------------
  276. # Custom Data Keys
  277. # Pre-defined keys used internally in Carla.
  278. # @see CustomData.key
  279. # Plugin options key.
  280. CUSTOM_DATA_KEY_PLUGIN_OPTIONS = "CarlaPluginOptions"
  281. # UI position key.
  282. CUSTOM_DATA_KEY_UI_POSITION = "CarlaUiPosition"
  283. # UI size key.
  284. CUSTOM_DATA_KEY_UI_SIZE = "CarlaUiSize"
  285. # UI visible key.
  286. CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUiVisible"
  287. # ---------------------------------------------------------------------------------------------------------------------
  288. # Binary Type
  289. # The binary type of a plugin.
  290. # Null binary type.
  291. BINARY_NONE = 0
  292. # POSIX 32bit binary.
  293. BINARY_POSIX32 = 1
  294. # POSIX 64bit binary.
  295. BINARY_POSIX64 = 2
  296. # Windows 32bit binary.
  297. BINARY_WIN32 = 3
  298. # Windows 64bit binary.
  299. BINARY_WIN64 = 4
  300. # Other binary type.
  301. BINARY_OTHER = 5
  302. # ---------------------------------------------------------------------------------------------------------------------
  303. # File Type
  304. # File type.
  305. # Null file type.
  306. FILE_NONE = 0
  307. # Audio file.
  308. FILE_AUDIO = 1
  309. # MIDI file.
  310. FILE_MIDI = 2
  311. # ---------------------------------------------------------------------------------------------------------------------
  312. # Plugin Type
  313. # Plugin type.
  314. # Some files are handled as if they were plugins.
  315. # Null plugin type.
  316. PLUGIN_NONE = 0
  317. # Internal plugin.
  318. PLUGIN_INTERNAL = 1
  319. # LADSPA plugin.
  320. PLUGIN_LADSPA = 2
  321. # DSSI plugin.
  322. PLUGIN_DSSI = 3
  323. # LV2 plugin.
  324. PLUGIN_LV2 = 4
  325. # VST2 plugin.
  326. PLUGIN_VST2 = 5
  327. # VST3 plugin.
  328. # @note Windows and MacOS only
  329. PLUGIN_VST3 = 6
  330. # AU plugin.
  331. # @note MacOS only
  332. PLUGIN_AU = 7
  333. # DLS file.
  334. PLUGIN_DLS = 8
  335. # GIG file.
  336. PLUGIN_GIG = 9
  337. # SF2/3 file (SoundFont).
  338. PLUGIN_SF2 = 10
  339. # SFZ file.
  340. PLUGIN_SFZ = 11
  341. # JACK application.
  342. PLUGIN_JACK = 12
  343. # JSFX plugin.
  344. PLUGIN_JSFX = 13
  345. # CLAP plugin.
  346. PLUGIN_CLAP = 14
  347. # ---------------------------------------------------------------------------------------------------------------------
  348. # Plugin Category
  349. # Plugin category, which describes the functionality of a plugin.
  350. # Null plugin category.
  351. PLUGIN_CATEGORY_NONE = 0
  352. # A synthesizer or generator.
  353. PLUGIN_CATEGORY_SYNTH = 1
  354. # A delay or reverb.
  355. PLUGIN_CATEGORY_DELAY = 2
  356. # An equalizer.
  357. PLUGIN_CATEGORY_EQ = 3
  358. # A filter.
  359. PLUGIN_CATEGORY_FILTER = 4
  360. # A distortion plugin.
  361. PLUGIN_CATEGORY_DISTORTION = 5
  362. # A 'dynamic' plugin (amplifier, compressor, gate, etc).
  363. PLUGIN_CATEGORY_DYNAMICS = 6
  364. # A 'modulator' plugin (chorus, flanger, phaser, etc).
  365. PLUGIN_CATEGORY_MODULATOR = 7
  366. # An 'utility' plugin (analyzer, converter, mixer, etc).
  367. PLUGIN_CATEGORY_UTILITY = 8
  368. # Miscellaneous plugin (used to check if the plugin has a category).
  369. PLUGIN_CATEGORY_OTHER = 9
  370. # ---------------------------------------------------------------------------------------------------------------------
  371. # Parameter Type
  372. # Plugin parameter type.
  373. # Null parameter type.
  374. PARAMETER_UNKNOWN = 0
  375. # Input parameter.
  376. PARAMETER_INPUT = 1
  377. # Output parameter.
  378. PARAMETER_OUTPUT = 2
  379. # ---------------------------------------------------------------------------------------------------------------------
  380. # Internal Parameter Index
  381. # Special parameters used internally in Carla.
  382. # Plugins do not know about their existence.
  383. # Null parameter.
  384. PARAMETER_NULL = -1
  385. # Active parameter, boolean type.
  386. # Default is 'false'.
  387. PARAMETER_ACTIVE = -2
  388. # Dry/Wet parameter.
  389. # Range 0.0...1.0; default is 1.0.
  390. PARAMETER_DRYWET = -3
  391. # Volume parameter.
  392. # Range 0.0...1.27; default is 1.0.
  393. PARAMETER_VOLUME = -4
  394. # Stereo Balance-Left parameter.
  395. # Range -1.0...1.0; default is -1.0.
  396. PARAMETER_BALANCE_LEFT = -5
  397. # Stereo Balance-Right parameter.
  398. # Range -1.0...1.0; default is 1.0.
  399. PARAMETER_BALANCE_RIGHT = -6
  400. # Mono Panning parameter.
  401. # Range -1.0...1.0; default is 0.0.
  402. PARAMETER_PANNING = -7
  403. # MIDI Control channel, integer type.
  404. # Range -1...15 (-1 = off).
  405. PARAMETER_CTRL_CHANNEL = -8
  406. # Max value, defined only for convenience.
  407. PARAMETER_MAX = -9
  408. # ---------------------------------------------------------------------------------------------------------------------
  409. # Special Mapped Control Index
  410. # Specially designated mapped control indexes.
  411. # Values between 0 and 119 (0x77) are reserved for MIDI CC, which uses direct values.
  412. # @see ParameterData::mappedControlIndex
  413. # Unused control index, meaning no mapping is enabled.
  414. CONTROL_INDEX_NONE = -1
  415. # CV control index, meaning the parameter is exposed as CV port.
  416. CONTROL_INDEX_CV = 130
  417. # Special value to indicate MIDI pitchbend.
  418. CONTROL_INDEX_MIDI_PITCHBEND = 131
  419. # Special value to indicate MIDI learn.
  420. CONTROL_INDEX_MIDI_LEARN = 132
  421. # Special value to indicate MIDI pitchbend.
  422. CONTROL_INDEX_MAX_ALLOWED = CONTROL_INDEX_MIDI_LEARN
  423. # ---------------------------------------------------------------------------------------------------------------------
  424. # Engine Callback Opcode
  425. # Engine callback opcodes.
  426. # Front-ends must never block indefinitely during a callback.
  427. # @see EngineCallbackFunc and carla_set_engine_callback()
  428. # Debug.
  429. # This opcode is undefined and used only for testing purposes.
  430. ENGINE_CALLBACK_DEBUG = 0
  431. # A plugin has been added.
  432. # @a pluginId Plugin Id
  433. # @a value1 Plugin type
  434. # @a valueStr Plugin name
  435. ENGINE_CALLBACK_PLUGIN_ADDED = 1
  436. # A plugin has been removed.
  437. # @a pluginId Plugin Id
  438. ENGINE_CALLBACK_PLUGIN_REMOVED = 2
  439. # A plugin has been renamed.
  440. # @a pluginId Plugin Id
  441. # @a valueStr New plugin name
  442. ENGINE_CALLBACK_PLUGIN_RENAMED = 3
  443. # A plugin has become unavailable.
  444. # @a pluginId Plugin Id
  445. # @a valueStr Related error string
  446. ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4
  447. # A parameter value has changed.
  448. # @a pluginId Plugin Id
  449. # @a value1 Parameter index
  450. # @a valuef New parameter value
  451. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5
  452. # A parameter default has changed.
  453. # @a pluginId Plugin Id
  454. # @a value1 Parameter index
  455. # @a valuef New default value
  456. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6
  457. # A parameter's mapped control index has changed.
  458. # @a pluginId Plugin Id
  459. # @a value1 Parameter index
  460. # @a value2 New control index
  461. ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED = 7
  462. # A parameter's MIDI channel has changed.
  463. # @a pluginId Plugin Id
  464. # @a value1 Parameter index
  465. # @a value2 New MIDI channel
  466. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8
  467. # A plugin option has changed.
  468. # @a pluginId Plugin Id
  469. # @a value1 Option
  470. # @a value2 New on/off state (1 for on, 0 for off)
  471. # @see PluginOptions
  472. ENGINE_CALLBACK_OPTION_CHANGED = 9
  473. # The current program of a plugin has changed.
  474. # @a pluginId Plugin Id
  475. # @a value1 New program index
  476. ENGINE_CALLBACK_PROGRAM_CHANGED = 10
  477. # The current MIDI program of a plugin has changed.
  478. # @a pluginId Plugin Id
  479. # @a value1 New MIDI program index
  480. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 11
  481. # A plugin's custom UI state has changed.
  482. # @a pluginId Plugin Id
  483. # @a value1 New state, as follows:
  484. # 0: UI is now hidden
  485. # 1: UI is now visible
  486. # -1: UI has crashed and should not be shown again
  487. ENGINE_CALLBACK_UI_STATE_CHANGED = 12
  488. # A note has been pressed.
  489. # @a pluginId Plugin Id
  490. # @a value1 Channel
  491. # @a value2 Note
  492. # @a value3 Velocity
  493. ENGINE_CALLBACK_NOTE_ON = 13
  494. # A note has been released.
  495. # @a pluginId Plugin Id
  496. # @a value1 Channel
  497. # @a value2 Note
  498. ENGINE_CALLBACK_NOTE_OFF = 14
  499. # A plugin needs update.
  500. # @a pluginId Plugin Id
  501. ENGINE_CALLBACK_UPDATE = 15
  502. # A plugin's data/information has changed.
  503. # @a pluginId Plugin Id
  504. ENGINE_CALLBACK_RELOAD_INFO = 16
  505. # A plugin's parameters have changed.
  506. # @a pluginId Plugin Id
  507. ENGINE_CALLBACK_RELOAD_PARAMETERS = 17
  508. # A plugin's programs have changed.
  509. # @a pluginId Plugin Id
  510. ENGINE_CALLBACK_RELOAD_PROGRAMS = 18
  511. # A plugin state has changed.
  512. # @a pluginId Plugin Id
  513. ENGINE_CALLBACK_RELOAD_ALL = 19
  514. # A patchbay client has been added.
  515. # @a pluginId Client Id
  516. # @a value1 Client icon
  517. # @a value2 Plugin Id (-1 if not a plugin)
  518. # @a valueStr Client name
  519. # @see PatchbayIcon
  520. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 20
  521. # A patchbay client has been removed.
  522. # @a pluginId Client Id
  523. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 21
  524. # A patchbay client has been renamed.
  525. # @a pluginId Client Id
  526. # @a valueStr New client name
  527. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 22
  528. # A patchbay client data has changed.
  529. # @a pluginId Client Id
  530. # @a value1 New icon
  531. # @a value2 New plugin Id (-1 if not a plugin)
  532. # @see PatchbayIcon
  533. ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 23
  534. # A patchbay port has been added.
  535. # @a pluginId Client Id
  536. # @a value1 Port Id
  537. # @a value2 Port hints
  538. # @a value3 Port group Id (0 for none)
  539. # @a valueStr Port name
  540. # @see PatchbayPortHints
  541. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 24
  542. # A patchbay port has been removed.
  543. # @a pluginId Client Id
  544. # @a value1 Port Id
  545. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 25
  546. # A patchbay port has changed (like the name or group Id).
  547. # @a pluginId Client Id
  548. # @a value1 Port Id
  549. # @a value2 Port hints
  550. # @a value3 Port group Id (0 for none)
  551. # @a valueStr New port name
  552. ENGINE_CALLBACK_PATCHBAY_PORT_CHANGED = 26
  553. # A patchbay connection has been added.
  554. # @a pluginId Connection Id
  555. # @a valueStr Out group, port plus in group and port, in "og:op:ig:ip" syntax.
  556. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27
  557. # A patchbay connection has been removed.
  558. # @a pluginId Connection Id
  559. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28
  560. # Engine started.
  561. # @a pluginId How many plugins are known to be running
  562. # @a value1 Process mode
  563. # @a value2 Transport mode
  564. # @a value3 Buffer size
  565. # @a valuef Sample rate
  566. # @a valuestr Engine driver
  567. # @see EngineProcessMode
  568. # @see EngineTransportMode
  569. ENGINE_CALLBACK_ENGINE_STARTED = 29
  570. # Engine stopped.
  571. ENGINE_CALLBACK_ENGINE_STOPPED = 30
  572. # Engine process mode has changed.
  573. # @a value1 New process mode
  574. # @see EngineProcessMode
  575. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31
  576. # Engine transport mode has changed.
  577. # @a value1 New transport mode
  578. # @a valueStr New transport features enabled
  579. # @see EngineTransportMode
  580. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32
  581. # Engine buffer-size changed.
  582. # @a value1 New buffer size
  583. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33
  584. # Engine sample-rate changed.
  585. # @a valuef New sample rate
  586. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34
  587. # A cancelable action has been started or stopped.
  588. # @a pluginId Plugin Id the action relates to, -1 for none
  589. # @a value1 1 for action started, 0 for stopped
  590. # @a valueStr Action name
  591. ENGINE_CALLBACK_CANCELABLE_ACTION = 35
  592. # Project has finished loading.
  593. ENGINE_CALLBACK_PROJECT_LOAD_FINISHED = 36
  594. # NSM callback.
  595. # Frontend must call carla_nsm_ready() with opcode as parameter as a response
  596. # @a value1 NSM opcode
  597. # @a value2 Integer value
  598. # @a valueStr String value
  599. # @see NsmCallbackOpcode
  600. ENGINE_CALLBACK_NSM = 37
  601. # Idle frontend.
  602. # This is used by the engine during long operations that might block the frontend,
  603. # giving it the possibility to idle while the operation is still in place.
  604. ENGINE_CALLBACK_IDLE = 38
  605. # Show a message as information.
  606. # @a valueStr The message
  607. ENGINE_CALLBACK_INFO = 39
  608. # Show a message as an error.
  609. # @a valueStr The message
  610. ENGINE_CALLBACK_ERROR = 40
  611. # The engine has crashed or malfunctioned and will no longer work.
  612. ENGINE_CALLBACK_QUIT = 41
  613. # A plugin requested for its inline display to be redrawn.
  614. # @a pluginId Plugin Id to redraw
  615. ENGINE_CALLBACK_INLINE_DISPLAY_REDRAW = 42
  616. # A patchbay port group has been added.
  617. # @a pluginId Client Id
  618. # @a value1 Group Id (unique within this client)
  619. # @a value2 Group hints
  620. # @a valueStr Group name
  621. # @see PatchbayPortGroupHints
  622. ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_ADDED = 43
  623. # A patchbay port group has been removed.
  624. # @a pluginId Client Id
  625. # @a value1 Group Id (unique within this client)
  626. ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_REMOVED = 44
  627. # A patchbay port group has changed.
  628. # @a pluginId Client Id
  629. # @a value1 Group Id (unique within this client)
  630. # @a value2 Group hints
  631. # @a valueStr Group name
  632. # @see PatchbayPortGroupHints
  633. ENGINE_CALLBACK_PATCHBAY_PORT_GROUP_CHANGED = 45
  634. # A parameter's mapped range has changed.
  635. # @a pluginId Plugin Id
  636. # @a value1 Parameter index
  637. # @a valueStr New mapped range as "%f:%f" syntax
  638. ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED = 46
  639. # A patchbay client position has changed.
  640. # @a pluginId Client Id
  641. # @a value1 X position 1
  642. # @a value2 Y position 1
  643. # @a value3 X position 2
  644. # @a valuef Y position 2
  645. ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED = 47
  646. # ---------------------------------------------------------------------------------------------------------------------
  647. # NSM Callback Opcode
  648. # NSM callback opcodes.
  649. # @see ENGINE_CALLBACK_NSM
  650. # NSM is available and initialized.
  651. NSM_CALLBACK_INIT = 0
  652. # Error from NSM side.
  653. # @a valueInt Error code
  654. # @a valueStr Error string
  655. NSM_CALLBACK_ERROR = 1
  656. # Announce message.
  657. # @a valueInt SM Flags (WIP, to be defined)
  658. # @a valueStr SM Name
  659. NSM_CALLBACK_ANNOUNCE = 2
  660. # Open message.
  661. # @a valueStr Project filename
  662. NSM_CALLBACK_OPEN = 3
  663. # Save message.
  664. NSM_CALLBACK_SAVE = 4
  665. # Session-is-loaded message.
  666. NSM_CALLBACK_SESSION_IS_LOADED = 5
  667. # Show-optional-gui message.
  668. NSM_CALLBACK_SHOW_OPTIONAL_GUI = 6
  669. # Hide-optional-gui message.
  670. NSM_CALLBACK_HIDE_OPTIONAL_GUI = 7
  671. # Set client name id message.
  672. NSM_CALLBACK_SET_CLIENT_NAME_ID = 8
  673. # ---------------------------------------------------------------------------------------------------------------------
  674. # Engine Option
  675. # Engine options.
  676. # @see carla_set_engine_option()
  677. # Debug.
  678. # This option is undefined and used only for testing purposes.
  679. ENGINE_OPTION_DEBUG = 0
  680. # Set the engine processing mode.
  681. # Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_CONTINUOUS_RACK for all other OSes.
  682. # @see EngineProcessMode
  683. ENGINE_OPTION_PROCESS_MODE = 1
  684. # Set the engine transport mode.
  685. # Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  686. # @see EngineTransportMode
  687. ENGINE_OPTION_TRANSPORT_MODE = 2
  688. # Force mono plugins as stereo, by running 2 instances at the same time.
  689. # Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  690. # @note Not supported by all plugins
  691. # @see PLUGIN_OPTION_FORCE_STEREO
  692. ENGINE_OPTION_FORCE_STEREO = 3
  693. # Use plugin bridges whenever possible.
  694. # Default is no, EXPERIMENTAL.
  695. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4
  696. # Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  697. # Default is yes.
  698. ENGINE_OPTION_PREFER_UI_BRIDGES = 5
  699. # Make custom plugin UIs always-on-top.
  700. # Default is yes.
  701. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6
  702. # Maximum number of parameters allowed.
  703. # Default is MAX_DEFAULT_PARAMETERS.
  704. ENGINE_OPTION_MAX_PARAMETERS = 7
  705. # Reset Xrun counter after project load.
  706. ENGINE_OPTION_RESET_XRUNS = 8
  707. # Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  708. # Default is 4000 (4 seconds).
  709. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 9
  710. # Audio buffer size.
  711. # Default is 512.
  712. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10
  713. # Audio sample rate.
  714. # Default is 44100.
  715. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11
  716. # Wherever to use 3 audio periods instead of the default 2.
  717. # Default is false.
  718. ENGINE_OPTION_AUDIO_TRIPLE_BUFFER = 12
  719. # Audio driver.
  720. # Default dppends on platform.
  721. ENGINE_OPTION_AUDIO_DRIVER = 13
  722. # Audio device (within a driver).
  723. # Default unset.
  724. ENGINE_OPTION_AUDIO_DEVICE = 14
  725. # Wherever to enable OSC support in the engine.
  726. ENGINE_OPTION_OSC_ENABLED = 15
  727. # The network TCP port to use for OSC.
  728. # A value of 0 means use a random port.
  729. # A value of < 0 means to not enable the TCP port for OSC.
  730. # @note Valid ports begin at 1024 and end at 32767 (inclusive)
  731. ENGINE_OPTION_OSC_PORT_TCP = 16
  732. # The network UDP port to use for OSC.
  733. # A value of 0 means use a random port.
  734. # A value of < 0 means to not enable the UDP port for OSC.
  735. # @note Disabling this option prevents DSSI UIs from working!
  736. # @note Valid ports begin at 1024 and end at 32767 (inclusive)
  737. ENGINE_OPTION_OSC_PORT_UDP = 17
  738. # Set path used for a specific file type.
  739. # Uses value as the file format, valueStr as actual path.
  740. ENGINE_OPTION_FILE_PATH = 18
  741. # Set path used for a specific plugin type.
  742. # Uses value as the plugin format, valueStr as actual path.
  743. # @see PluginType
  744. ENGINE_OPTION_PLUGIN_PATH = 19
  745. # Set path to the binary files.
  746. # Default unset.
  747. # @note Must be set for plugin and UI bridges to work
  748. ENGINE_OPTION_PATH_BINARIES = 20
  749. # Set path to the resource files.
  750. # Default unset.
  751. # @note Must be set for some internal plugins to work
  752. ENGINE_OPTION_PATH_RESOURCES = 21
  753. # Prevent bad plugin and UI behaviour.
  754. # @note: Linux only
  755. ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 22
  756. # Set background color used in the frontend, so backend can do the same for plugin UIs.
  757. ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR = 23
  758. # Set foreground color used in the frontend, so backend can do the same for plugin UIs.
  759. ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR = 24
  760. # Set UI scaling used in the frontend, so backend can do the same for plugin UIs.
  761. ENGINE_OPTION_FRONTEND_UI_SCALE = 25
  762. # Set frontend winId, used to define as parent window for plugin UIs.
  763. ENGINE_OPTION_FRONTEND_WIN_ID = 26
  764. # Set path to wine executable.
  765. ENGINE_OPTION_WINE_EXECUTABLE = 27
  766. # Enable automatic wineprefix detection.
  767. ENGINE_OPTION_WINE_AUTO_PREFIX = 28
  768. # Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set.
  769. ENGINE_OPTION_WINE_FALLBACK_PREFIX = 29
  770. # Enable realtime priority for Wine application and server threads.
  771. ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 30
  772. # Base realtime priority for Wine threads.
  773. ENGINE_OPTION_WINE_BASE_RT_PRIO = 31
  774. # Wine server realtime priority.
  775. ENGINE_OPTION_WINE_SERVER_RT_PRIO = 32
  776. # Capture console output into debug callbacks
  777. ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 33
  778. # A prefix to give to all plugin clients created by Carla.
  779. # Mostly useful for JACK multi-client mode.
  780. # @note MUST include at least one "." (dot).
  781. ENGINE_OPTION_CLIENT_NAME_PREFIX = 34
  782. # Treat loaded plugins as standalone (that is, there is no host UI to manage them)
  783. ENGINE_OPTION_PLUGINS_ARE_STANDALONE = 35
  784. # ---------------------------------------------------------------------------------------------------------------------
  785. # Engine Process Mode
  786. # Engine process mode.
  787. # @see ENGINE_OPTION_PROCESS_MODE
  788. # Single client mode.
  789. # Inputs and outputs are added dynamically as needed by plugins.
  790. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0
  791. # Multiple client mode.
  792. # It has 1 master client + 1 client per plugin.
  793. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1
  794. # Single client, 'rack' mode.
  795. # Processes plugins in order of Id, with forced stereo always on.
  796. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2
  797. # Single client, 'patchbay' mode.
  798. ENGINE_PROCESS_MODE_PATCHBAY = 3
  799. # Special mode, used in plugin-bridges only.
  800. ENGINE_PROCESS_MODE_BRIDGE = 4
  801. # ---------------------------------------------------------------------------------------------------------------------
  802. # Engine Transport Mode
  803. # Engine transport mode.
  804. # @see ENGINE_OPTION_TRANSPORT_MODE
  805. # No transport.
  806. ENGINE_TRANSPORT_MODE_DISABLED = 0
  807. # Internal transport mode.
  808. ENGINE_TRANSPORT_MODE_INTERNAL = 1
  809. # Transport from JACK.
  810. # Only available if driver name is "JACK".
  811. ENGINE_TRANSPORT_MODE_JACK = 2
  812. # Transport from host, used when Carla is a plugin.
  813. ENGINE_TRANSPORT_MODE_PLUGIN = 3
  814. # Special mode, used in plugin-bridges only.
  815. ENGINE_TRANSPORT_MODE_BRIDGE = 4
  816. # ---------------------------------------------------------------------------------------------------------------------
  817. # File Callback Opcode
  818. # File callback opcodes.
  819. # Front-ends must always block-wait for user input.
  820. # @see FileCallbackFunc and carla_set_file_callback()
  821. # Debug.
  822. # This opcode is undefined and used only for testing purposes.
  823. FILE_CALLBACK_DEBUG = 0
  824. # Open file or folder.
  825. FILE_CALLBACK_OPEN = 1
  826. # Save file or folder.
  827. FILE_CALLBACK_SAVE = 2
  828. # ---------------------------------------------------------------------------------------------------------------------
  829. # Patchbay Icon
  830. # The icon of a patchbay client/group.
  831. # Generic application icon.
  832. # Used for all non-plugin clients that don't have a specific icon.
  833. PATCHBAY_ICON_APPLICATION = 0
  834. # Plugin icon.
  835. # Used for all plugin clients that don't have a specific icon.
  836. PATCHBAY_ICON_PLUGIN = 1
  837. # Hardware icon.
  838. # Used for hardware (audio or MIDI) clients.
  839. PATCHBAY_ICON_HARDWARE = 2
  840. # Carla icon.
  841. # Used for the main app.
  842. PATCHBAY_ICON_CARLA = 3
  843. # DISTRHO icon.
  844. # Used for DISTRHO based plugins.
  845. PATCHBAY_ICON_DISTRHO = 4
  846. # File icon.
  847. # Used for file type plugins (like SF2 and SFZ).
  848. PATCHBAY_ICON_FILE = 5
  849. # ---------------------------------------------------------------------------------------------------------------------
  850. # Carla Backend API (C stuff)
  851. # Engine callback function.
  852. # Front-ends must never block indefinitely during a callback.
  853. # @see EngineCallbackOpcode and carla_set_engine_callback()
  854. EngineCallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_int, c_float, c_char_p)
  855. # File callback function.
  856. # @see FileCallbackOpcode
  857. FileCallbackFunc = CFUNCTYPE(c_char_p, c_void_p, c_enum, c_bool, c_char_p, c_char_p)
  858. # Parameter data.
  859. class ParameterData(Structure):
  860. _fields_ = [
  861. # This parameter type.
  862. ("type", c_enum),
  863. # This parameter hints.
  864. # @see ParameterHints
  865. ("hints", c_uint),
  866. # Index as seen by Carla.
  867. ("index", c_int32),
  868. # Real index as seen by plugins.
  869. ("rindex", c_int32),
  870. # Currently mapped MIDI channel.
  871. # Counts from 0 to 15.
  872. ("midiChannel", c_uint8),
  873. # Currently mapped index.
  874. # @see SpecialMappedControlIndex
  875. ("mappedControlIndex", c_int16),
  876. # Minimum value that this parameter maps to.
  877. ("mappedMinimum", c_float),
  878. # Maximum value that this parameter maps to.
  879. ("mappedMaximum", c_float),
  880. # Flags related to the current mapping of this parameter.
  881. # @see MappedParameterFlags
  882. ("mappedFlags", c_uint)
  883. ]
  884. # Parameter ranges.
  885. class ParameterRanges(Structure):
  886. _fields_ = [
  887. # Default value.
  888. ("def", c_float),
  889. # Minimum value.
  890. ("min", c_float),
  891. # Maximum value.
  892. ("max", c_float),
  893. # Regular, single step value.
  894. ("step", c_float),
  895. # Small step value.
  896. ("stepSmall", c_float),
  897. # Large step value.
  898. ("stepLarge", c_float)
  899. ]
  900. # MIDI Program data.
  901. class MidiProgramData(Structure):
  902. _fields_ = [
  903. # MIDI bank.
  904. ("bank", c_uint32),
  905. # MIDI program.
  906. ("program", c_uint32),
  907. # MIDI program name.
  908. ("name", c_char_p)
  909. ]
  910. # Custom data, used for saving key:value 'dictionaries'.
  911. class CustomData(Structure):
  912. _fields_ = [
  913. # Value type, in URI form.
  914. # @see CustomDataTypes
  915. ("type", c_char_p),
  916. # Key.
  917. # @see CustomDataKeys
  918. ("key", c_char_p),
  919. # Value.
  920. ("value", c_char_p)
  921. ]
  922. # Engine driver device information.
  923. class EngineDriverDeviceInfo(Structure):
  924. _fields_ = [
  925. # This driver device hints.
  926. # @see EngineDriverHints
  927. ("hints", c_uint),
  928. # Available buffer sizes.
  929. # Terminated with 0.
  930. ("bufferSizes", POINTER(c_uint32)),
  931. # Available sample rates.
  932. # Terminated with 0.0.
  933. ("sampleRates", POINTER(c_double))
  934. ]
  935. # ---------------------------------------------------------------------------------------------------------------------
  936. # Carla Backend API (Python compatible stuff)
  937. # @see ParameterData
  938. PyParameterData = {
  939. 'type': PARAMETER_UNKNOWN,
  940. 'hints': 0x0,
  941. 'index': PARAMETER_NULL,
  942. 'rindex': -1,
  943. 'midiChannel': 0,
  944. 'mappedControlIndex': CONTROL_INDEX_NONE,
  945. 'mappedMinimum': 0.0,
  946. 'mappedMaximum': 0.0,
  947. 'mappedFlags': 0x0,
  948. }
  949. # @see ParameterRanges
  950. PyParameterRanges = {
  951. 'def': 0.0,
  952. 'min': 0.0,
  953. 'max': 1.0,
  954. 'step': 0.01,
  955. 'stepSmall': 0.0001,
  956. 'stepLarge': 0.1
  957. }
  958. # @see MidiProgramData
  959. PyMidiProgramData = {
  960. 'bank': 0,
  961. 'program': 0,
  962. 'name': None
  963. }
  964. # @see CustomData
  965. PyCustomData = {
  966. 'type': None,
  967. 'key': None,
  968. 'value': None
  969. }
  970. # @see EngineDriverDeviceInfo
  971. PyEngineDriverDeviceInfo = {
  972. 'hints': 0x0,
  973. 'bufferSizes': [],
  974. 'sampleRates': []
  975. }
  976. # ---------------------------------------------------------------------------------------------------------------------
  977. # Carla Host API (C stuff)
  978. # Information about a loaded plugin.
  979. # @see carla_get_plugin_info()
  980. class CarlaPluginInfo(Structure):
  981. _fields_ = [
  982. # Plugin type.
  983. ("type", c_enum),
  984. # Plugin category.
  985. ("category", c_enum),
  986. # Plugin hints.
  987. # @see PluginHints
  988. ("hints", c_uint),
  989. # Plugin options available for the user to change.
  990. # @see PluginOptions
  991. ("optionsAvailable", c_uint),
  992. # Plugin options currently enabled.
  993. # Some options are enabled but not available, which means they will always be on.
  994. # @see PluginOptions
  995. ("optionsEnabled", c_uint),
  996. # Plugin filename.
  997. # This can be the plugin binary or resource file.
  998. ("filename", c_char_p),
  999. # Plugin name.
  1000. # This name is unique within a Carla instance.
  1001. # @see carla_get_real_plugin_name()
  1002. ("name", c_char_p),
  1003. # Plugin label or URI.
  1004. ("label", c_char_p),
  1005. # Plugin author/maker.
  1006. ("maker", c_char_p),
  1007. # Plugin copyright/license.
  1008. ("copyright", c_char_p),
  1009. # Icon name for this plugin, in lowercase.
  1010. # Default is "plugin".
  1011. ("iconName", c_char_p),
  1012. # Plugin unique Id.
  1013. # This Id is dependent on the plugin type and may sometimes be 0.
  1014. ("uniqueId", c_int64)
  1015. ]
  1016. # Port count information, used for Audio and MIDI ports and parameters.
  1017. # @see carla_get_audio_port_count_info()
  1018. # @see carla_get_midi_port_count_info()
  1019. # @see carla_get_parameter_count_info()
  1020. class CarlaPortCountInfo(Structure):
  1021. _fields_ = [
  1022. # Number of inputs.
  1023. ("ins", c_uint32),
  1024. # Number of outputs.
  1025. ("outs", c_uint32)
  1026. ]
  1027. # Parameter information.
  1028. # @see carla_get_parameter_info()
  1029. class CarlaParameterInfo(Structure):
  1030. _fields_ = [
  1031. # Parameter name.
  1032. ("name", c_char_p),
  1033. # Parameter symbol.
  1034. ("symbol", c_char_p),
  1035. # Parameter unit.
  1036. ("unit", c_char_p),
  1037. # Parameter comment / documentation.
  1038. ("comment", c_char_p),
  1039. # Parameter group name.
  1040. ("groupName", c_char_p),
  1041. # Number of scale points.
  1042. # @see CarlaScalePointInfo
  1043. ("scalePointCount", c_uint32)
  1044. ]
  1045. # Parameter scale point information.
  1046. # @see carla_get_parameter_scalepoint_info()
  1047. class CarlaScalePointInfo(Structure):
  1048. _fields_ = [
  1049. # Scale point value.
  1050. ("value", c_float),
  1051. # Scale point label.
  1052. ("label", c_char_p)
  1053. ]
  1054. # Transport information.
  1055. # @see carla_get_transport_info()
  1056. class CarlaTransportInfo(Structure):
  1057. _fields_ = [
  1058. # Wherever transport is playing.
  1059. ("playing", c_bool),
  1060. # Current transport frame.
  1061. ("frame", c_uint64),
  1062. # Bar
  1063. ("bar", c_int32),
  1064. # Beat
  1065. ("beat", c_int32),
  1066. # Tick
  1067. ("tick", c_int32),
  1068. # Beats per minute.
  1069. ("bpm", c_double)
  1070. ]
  1071. # Runtime engine information.
  1072. class CarlaRuntimeEngineInfo(Structure):
  1073. _fields_ = [
  1074. # DSP load.
  1075. ("load", c_float),
  1076. # Number of xruns.
  1077. ("xruns", c_uint32)
  1078. ]
  1079. # Runtime engine driver device information.
  1080. class CarlaRuntimeEngineDriverDeviceInfo(Structure):
  1081. _fields_ = [
  1082. # Name of the driver device.
  1083. ("name", c_char_p),
  1084. # This driver device hints.
  1085. # @see EngineDriverHints
  1086. ("hints", c_uint),
  1087. # Current buffer size.
  1088. ("bufferSize", c_uint32),
  1089. # Available buffer sizes.
  1090. # Terminated with 0.
  1091. ("bufferSizes", POINTER(c_uint32)),
  1092. # Current sample rate.
  1093. ("sampleRate", c_double),
  1094. # Available sample rates.
  1095. # Terminated with 0.0.
  1096. ("sampleRates", POINTER(c_double))
  1097. ]
  1098. # Image data for LV2 inline display API.
  1099. # raw image pixmap format is ARGB32,
  1100. class CarlaInlineDisplayImageSurface(Structure):
  1101. _fields_ = [
  1102. ("data", POINTER(c_ubyte)),
  1103. ("width", c_int),
  1104. ("height", c_int),
  1105. ("stride", c_int)
  1106. ]
  1107. # ---------------------------------------------------------------------------------------------------------------------
  1108. # Carla Host API (Python compatible stuff)
  1109. # @see CarlaPluginInfo
  1110. PyCarlaPluginInfo = {
  1111. 'type': PLUGIN_NONE,
  1112. 'category': PLUGIN_CATEGORY_NONE,
  1113. 'hints': 0x0,
  1114. 'optionsAvailable': 0x0,
  1115. 'optionsEnabled': 0x0,
  1116. 'filename': "",
  1117. 'name': "",
  1118. 'label': "",
  1119. 'maker': "",
  1120. 'copyright': "",
  1121. 'iconName': "",
  1122. 'uniqueId': 0
  1123. }
  1124. # @see CarlaPortCountInfo
  1125. PyCarlaPortCountInfo = {
  1126. 'ins': 0,
  1127. 'outs': 0
  1128. }
  1129. # @see CarlaParameterInfo
  1130. PyCarlaParameterInfo = {
  1131. 'name': "",
  1132. 'symbol': "",
  1133. 'unit': "",
  1134. 'comment': "",
  1135. 'groupName': "",
  1136. 'scalePointCount': 0,
  1137. }
  1138. # @see CarlaScalePointInfo
  1139. PyCarlaScalePointInfo = {
  1140. 'value': 0.0,
  1141. 'label': ""
  1142. }
  1143. # @see CarlaTransportInfo
  1144. PyCarlaTransportInfo = {
  1145. 'playing': False,
  1146. 'frame': 0,
  1147. 'bar': 0,
  1148. 'beat': 0,
  1149. 'tick': 0,
  1150. 'bpm': 0.0
  1151. }
  1152. # @see CarlaRuntimeEngineInfo
  1153. PyCarlaRuntimeEngineInfo = {
  1154. 'load': 0.0,
  1155. 'xruns': 0
  1156. }
  1157. # @see CarlaRuntimeEngineDriverDeviceInfo
  1158. PyCarlaRuntimeEngineDriverDeviceInfo = {
  1159. 'name': "",
  1160. 'hints': 0x0,
  1161. 'bufferSize': 0,
  1162. 'bufferSizes': [],
  1163. 'sampleRate': 0.0,
  1164. 'sampleRates': []
  1165. }
  1166. # ---------------------------------------------------------------------------------------------------------------------
  1167. # Set BINARY_NATIVE
  1168. if CARLA_OS_WIN64:
  1169. BINARY_NATIVE = BINARY_WIN64
  1170. elif CARLA_OS_WIN32:
  1171. BINARY_NATIVE = BINARY_WIN32
  1172. elif CARLA_OS_64BIT:
  1173. BINARY_NATIVE = BINARY_POSIX64
  1174. else:
  1175. BINARY_NATIVE = BINARY_POSIX32
  1176. # ---------------------------------------------------------------------------------------------------------------------
  1177. # Carla Host object (Meta)
  1178. class CarlaHostMeta():
  1179. def __init__(self):
  1180. # info about this host object
  1181. self.isControl = False
  1182. self.isPlugin = False
  1183. self.isRemote = False
  1184. self.nsmOK = False
  1185. self.handle = None
  1186. # settings
  1187. self.processMode = ENGINE_PROCESS_MODE_PATCHBAY
  1188. self.transportMode = ENGINE_TRANSPORT_MODE_INTERNAL
  1189. self.transportExtra = ""
  1190. self.nextProcessMode = self.processMode
  1191. self.processModeForced = False
  1192. self.audioDriverForced = None
  1193. # settings
  1194. self.experimental = False
  1195. self.exportLV2 = False
  1196. self.forceStereo = False
  1197. self.manageUIs = False
  1198. self.maxParameters = 0
  1199. self.resetXruns = False
  1200. self.preferPluginBridges = False
  1201. self.preferUIBridges = False
  1202. self.preventBadBehaviour = False
  1203. self.showLogs = False
  1204. self.showPluginBridges = False
  1205. self.showWineBridges = False
  1206. self.uiBridgesTimeout = 0
  1207. self.uisAlwaysOnTop = False
  1208. # settings
  1209. self.pathBinaries = ""
  1210. self.pathResources = ""
  1211. # Get how many engine drivers are available.
  1212. @abstractmethod
  1213. def get_engine_driver_count(self):
  1214. raise NotImplementedError
  1215. # Get an engine driver name.
  1216. # @param index Driver index
  1217. @abstractmethod
  1218. def get_engine_driver_name(self, index):
  1219. raise NotImplementedError
  1220. # Get the device names of an engine driver.
  1221. # @param index Driver index
  1222. @abstractmethod
  1223. def get_engine_driver_device_names(self, index):
  1224. raise NotImplementedError
  1225. # Get information about a device driver.
  1226. # @param index Driver index
  1227. # @param name Device name
  1228. @abstractmethod
  1229. def get_engine_driver_device_info(self, index, name):
  1230. raise NotImplementedError
  1231. # Show a device custom control panel.
  1232. # @see ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL
  1233. # @param index Driver index
  1234. # @param name Device name
  1235. @abstractmethod
  1236. def show_engine_driver_device_control_panel(self, index, name):
  1237. raise NotImplementedError
  1238. # Initialize the engine.
  1239. # Make sure to call carla_engine_idle() at regular intervals afterwards.
  1240. # @param driverName Driver to use
  1241. # @param clientName Engine master client name
  1242. @abstractmethod
  1243. def engine_init(self, driverName, clientName):
  1244. raise NotImplementedError
  1245. # Close the engine.
  1246. # This function always closes the engine even if it returns false.
  1247. # In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
  1248. @abstractmethod
  1249. def engine_close(self):
  1250. raise NotImplementedError
  1251. # Idle the engine.
  1252. # Do not call this if the engine is not running.
  1253. @abstractmethod
  1254. def engine_idle(self):
  1255. raise NotImplementedError
  1256. # Check if the engine is running.
  1257. @abstractmethod
  1258. def is_engine_running(self):
  1259. raise NotImplementedError
  1260. # Get information about the currently running engine.
  1261. @abstractmethod
  1262. def get_runtime_engine_info(self):
  1263. raise NotImplementedError
  1264. # Get information about the currently running engine driver device.
  1265. @abstractmethod
  1266. def get_runtime_engine_driver_device_info(self):
  1267. raise NotImplementedError
  1268. # Dynamically change buffer size and/or sample rate while engine is running.
  1269. # @see ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE
  1270. # @see ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE
  1271. def set_engine_buffer_size_and_sample_rate(self, bufferSize, sampleRate):
  1272. raise NotImplementedError
  1273. # Show the custom control panel for the current engine device.
  1274. # @see ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL
  1275. def show_engine_device_control_panel(self):
  1276. raise NotImplementedError
  1277. # Clear the xrun count on the engine, so that the next time carla_get_runtime_engine_info() is called, it returns 0.
  1278. @abstractmethod
  1279. def clear_engine_xruns(self):
  1280. raise NotImplementedError
  1281. # Tell the engine to stop the current cancelable action.
  1282. # @see ENGINE_CALLBACK_CANCELABLE_ACTION
  1283. @abstractmethod
  1284. def cancel_engine_action(self):
  1285. raise NotImplementedError
  1286. # Tell the engine it's about to close.
  1287. # This is used to prevent the engine thread(s) from reactivating.
  1288. @abstractmethod
  1289. def set_engine_about_to_close(self):
  1290. raise NotImplementedError
  1291. # Set the engine callback function.
  1292. # @param func Callback function
  1293. @abstractmethod
  1294. def set_engine_callback(self, func):
  1295. raise NotImplementedError
  1296. # Set an engine option.
  1297. # @param option Option
  1298. # @param value Value as number
  1299. # @param valueStr Value as string
  1300. @abstractmethod
  1301. def set_engine_option(self, option, value, valueStr):
  1302. raise NotImplementedError
  1303. # Set the file callback function.
  1304. # @param func Callback function
  1305. # @param ptr Callback pointer
  1306. @abstractmethod
  1307. def set_file_callback(self, func):
  1308. raise NotImplementedError
  1309. # Load a file of any type.
  1310. # This will try to load a generic file as a plugin,
  1311. # either by direct handling (SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
  1312. # @see carla_get_supported_file_extensions()
  1313. @abstractmethod
  1314. def load_file(self, filename):
  1315. raise NotImplementedError
  1316. # Load a Carla project file.
  1317. # @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
  1318. @abstractmethod
  1319. def load_project(self, filename):
  1320. raise NotImplementedError
  1321. # Save current project to a file.
  1322. @abstractmethod
  1323. def save_project(self, filename):
  1324. raise NotImplementedError
  1325. # Clear the currently set project filename.
  1326. @abstractmethod
  1327. def clear_project_filename(self):
  1328. raise NotImplementedError
  1329. # Connect two patchbay ports.
  1330. # @param groupIdA Output group
  1331. # @param portIdA Output port
  1332. # @param groupIdB Input group
  1333. # @param portIdB Input port
  1334. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
  1335. @abstractmethod
  1336. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  1337. raise NotImplementedError
  1338. # Disconnect two patchbay ports.
  1339. # @param connectionId Connection Id
  1340. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
  1341. @abstractmethod
  1342. def patchbay_disconnect(self, external, connectionId):
  1343. raise NotImplementedError
  1344. # Set the position of a group.
  1345. # This is purely cached and saved in the project file, Carla backend does nothing with the value.
  1346. # When loading a project, callbacks are used to inform of the previously saved positions.
  1347. # @see ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED
  1348. @abstractmethod
  1349. def patchbay_set_group_pos(self, external, groupId, x1, y1, x2, y2):
  1350. raise NotImplementedError
  1351. # Force the engine to resend all patchbay clients, ports and connections again.
  1352. # @param external Wherever to show external/hardware ports instead of internal ones.
  1353. # Only valid in patchbay engine mode, other modes will ignore this.
  1354. @abstractmethod
  1355. def patchbay_refresh(self, external):
  1356. raise NotImplementedError
  1357. # Start playback of the engine transport.
  1358. @abstractmethod
  1359. def transport_play(self):
  1360. raise NotImplementedError
  1361. # Pause the engine transport.
  1362. @abstractmethod
  1363. def transport_pause(self):
  1364. raise NotImplementedError
  1365. # Pause the engine transport.
  1366. @abstractmethod
  1367. def transport_bpm(self, bpm):
  1368. raise NotImplementedError
  1369. # Relocate the engine transport to a specific frame.
  1370. @abstractmethod
  1371. def transport_relocate(self, frame):
  1372. raise NotImplementedError
  1373. # Get the current transport frame.
  1374. @abstractmethod
  1375. def get_current_transport_frame(self):
  1376. raise NotImplementedError
  1377. # Get the engine transport information.
  1378. @abstractmethod
  1379. def get_transport_info(self):
  1380. raise NotImplementedError
  1381. # Current number of plugins loaded.
  1382. @abstractmethod
  1383. def get_current_plugin_count(self):
  1384. raise NotImplementedError
  1385. # Maximum number of loadable plugins allowed.
  1386. # Returns 0 if engine is not started.
  1387. @abstractmethod
  1388. def get_max_plugin_number(self):
  1389. raise NotImplementedError
  1390. # Add a new plugin.
  1391. # If you don't know the binary type use the BINARY_NATIVE macro.
  1392. # @param btype Binary type
  1393. # @param ptype Plugin type
  1394. # @param filename Filename, if applicable
  1395. # @param name Name of the plugin, can be NULL
  1396. # @param label Plugin label, if applicable
  1397. # @param uniqueId Plugin unique Id, if applicable
  1398. # @param extraPtr Extra pointer, defined per plugin type
  1399. # @param options Initial plugin options
  1400. @abstractmethod
  1401. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  1402. raise NotImplementedError
  1403. # Remove a plugin.
  1404. # @param pluginId Plugin to remove.
  1405. @abstractmethod
  1406. def remove_plugin(self, pluginId):
  1407. raise NotImplementedError
  1408. # Remove all plugins.
  1409. @abstractmethod
  1410. def remove_all_plugins(self):
  1411. raise NotImplementedError
  1412. # Rename a plugin.
  1413. # Returns the new name, or NULL if the operation failed.
  1414. # @param pluginId Plugin to rename
  1415. # @param newName New plugin name
  1416. @abstractmethod
  1417. def rename_plugin(self, pluginId, newName):
  1418. raise NotImplementedError
  1419. # Clone a plugin.
  1420. # @param pluginId Plugin to clone
  1421. @abstractmethod
  1422. def clone_plugin(self, pluginId):
  1423. raise NotImplementedError
  1424. # Prepare replace of a plugin.
  1425. # The next call to carla_add_plugin() will use this id, replacing the current plugin.
  1426. # @param pluginId Plugin to replace
  1427. # @note This function requires carla_add_plugin() to be called afterwards *as soon as possible*.
  1428. @abstractmethod
  1429. def replace_plugin(self, pluginId):
  1430. raise NotImplementedError
  1431. # Switch two plugins positions.
  1432. # @param pluginIdA Plugin A
  1433. # @param pluginIdB Plugin B
  1434. @abstractmethod
  1435. def switch_plugins(self, pluginIdA, pluginIdB):
  1436. raise NotImplementedError
  1437. # Load a plugin state.
  1438. # @param pluginId Plugin
  1439. # @param filename Path to plugin state
  1440. # @see carla_save_plugin_state()
  1441. @abstractmethod
  1442. def load_plugin_state(self, pluginId, filename):
  1443. raise NotImplementedError
  1444. # Save a plugin state.
  1445. # @param pluginId Plugin
  1446. # @param filename Path to plugin state
  1447. # @see carla_load_plugin_state()
  1448. @abstractmethod
  1449. def save_plugin_state(self, pluginId, filename):
  1450. raise NotImplementedError
  1451. # Export plugin as LV2.
  1452. # @param pluginId Plugin
  1453. # @param lv2path Path to lv2 plugin folder
  1454. def export_plugin_lv2(self, pluginId, lv2path):
  1455. raise NotImplementedError
  1456. # Get information from a plugin.
  1457. # @param pluginId Plugin
  1458. @abstractmethod
  1459. def get_plugin_info(self, pluginId):
  1460. raise NotImplementedError
  1461. # Get audio port count information from a plugin.
  1462. # @param pluginId Plugin
  1463. @abstractmethod
  1464. def get_audio_port_count_info(self, pluginId):
  1465. raise NotImplementedError
  1466. # Get MIDI port count information from a plugin.
  1467. # @param pluginId Plugin
  1468. @abstractmethod
  1469. def get_midi_port_count_info(self, pluginId):
  1470. raise NotImplementedError
  1471. # Get parameter count information from a plugin.
  1472. # @param pluginId Plugin
  1473. @abstractmethod
  1474. def get_parameter_count_info(self, pluginId):
  1475. raise NotImplementedError
  1476. # Get parameter information from a plugin.
  1477. # @param pluginId Plugin
  1478. # @param parameterId Parameter index
  1479. # @see carla_get_parameter_count()
  1480. @abstractmethod
  1481. def get_parameter_info(self, pluginId, parameterId):
  1482. raise NotImplementedError
  1483. # Get parameter scale point information from a plugin.
  1484. # @param pluginId Plugin
  1485. # @param parameterId Parameter index
  1486. # @param scalePointId Parameter scale-point index
  1487. # @see CarlaParameterInfo::scalePointCount
  1488. @abstractmethod
  1489. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  1490. raise NotImplementedError
  1491. # Get a plugin's parameter data.
  1492. # @param pluginId Plugin
  1493. # @param parameterId Parameter index
  1494. # @see carla_get_parameter_count()
  1495. @abstractmethod
  1496. def get_parameter_data(self, pluginId, parameterId):
  1497. raise NotImplementedError
  1498. # Get a plugin's parameter ranges.
  1499. # @param pluginId Plugin
  1500. # @param parameterId Parameter index
  1501. # @see carla_get_parameter_count()
  1502. @abstractmethod
  1503. def get_parameter_ranges(self, pluginId, parameterId):
  1504. raise NotImplementedError
  1505. # Get a plugin's MIDI program data.
  1506. # @param pluginId Plugin
  1507. # @param midiProgramId MIDI Program index
  1508. # @see carla_get_midi_program_count()
  1509. @abstractmethod
  1510. def get_midi_program_data(self, pluginId, midiProgramId):
  1511. raise NotImplementedError
  1512. # Get a plugin's custom data, using index.
  1513. # @param pluginId Plugin
  1514. # @param customDataId Custom data index
  1515. # @see carla_get_custom_data_count()
  1516. @abstractmethod
  1517. def get_custom_data(self, pluginId, customDataId):
  1518. raise NotImplementedError
  1519. # Get a plugin's custom data value, using type and key.
  1520. # @param pluginId Plugin
  1521. # @param type Custom data type
  1522. # @param key Custom data key
  1523. # @see carla_get_custom_data_count()
  1524. @abstractmethod
  1525. def get_custom_data_value(self, pluginId, type_, key):
  1526. raise NotImplementedError
  1527. # Get a plugin's chunk data.
  1528. # @param pluginId Plugin
  1529. # @see PLUGIN_OPTION_USE_CHUNKS
  1530. @abstractmethod
  1531. def get_chunk_data(self, pluginId):
  1532. raise NotImplementedError
  1533. # Get how many parameters a plugin has.
  1534. # @param pluginId Plugin
  1535. @abstractmethod
  1536. def get_parameter_count(self, pluginId):
  1537. raise NotImplementedError
  1538. # Get how many programs a plugin has.
  1539. # @param pluginId Plugin
  1540. # @see carla_get_program_name()
  1541. @abstractmethod
  1542. def get_program_count(self, pluginId):
  1543. raise NotImplementedError
  1544. # Get how many MIDI programs a plugin has.
  1545. # @param pluginId Plugin
  1546. # @see carla_get_midi_program_name() and carla_get_midi_program_data()
  1547. @abstractmethod
  1548. def get_midi_program_count(self, pluginId):
  1549. raise NotImplementedError
  1550. # Get how many custom data sets a plugin has.
  1551. # @param pluginId Plugin
  1552. # @see carla_get_custom_data()
  1553. @abstractmethod
  1554. def get_custom_data_count(self, pluginId):
  1555. raise NotImplementedError
  1556. # Get a plugin's parameter text (custom display of internal values).
  1557. # @param pluginId Plugin
  1558. # @param parameterId Parameter index
  1559. # @see PARAMETER_USES_CUSTOM_TEXT
  1560. @abstractmethod
  1561. def get_parameter_text(self, pluginId, parameterId):
  1562. raise NotImplementedError
  1563. # Get a plugin's program name.
  1564. # @param pluginId Plugin
  1565. # @param programId Program index
  1566. # @see carla_get_program_count()
  1567. @abstractmethod
  1568. def get_program_name(self, pluginId, programId):
  1569. raise NotImplementedError
  1570. # Get a plugin's MIDI program name.
  1571. # @param pluginId Plugin
  1572. # @param midiProgramId MIDI Program index
  1573. # @see carla_get_midi_program_count()
  1574. @abstractmethod
  1575. def get_midi_program_name(self, pluginId, midiProgramId):
  1576. raise NotImplementedError
  1577. # Get a plugin's real name.
  1578. # This is the name the plugin uses to identify itself; may not be unique.
  1579. # @param pluginId Plugin
  1580. @abstractmethod
  1581. def get_real_plugin_name(self, pluginId):
  1582. raise NotImplementedError
  1583. # Get a plugin's program index.
  1584. # @param pluginId Plugin
  1585. @abstractmethod
  1586. def get_current_program_index(self, pluginId):
  1587. raise NotImplementedError
  1588. # Get a plugin's midi program index.
  1589. # @param pluginId Plugin
  1590. @abstractmethod
  1591. def get_current_midi_program_index(self, pluginId):
  1592. raise NotImplementedError
  1593. # Get a plugin's default parameter value.
  1594. # @param pluginId Plugin
  1595. # @param parameterId Parameter index
  1596. @abstractmethod
  1597. def get_default_parameter_value(self, pluginId, parameterId):
  1598. raise NotImplementedError
  1599. # Get a plugin's current parameter value.
  1600. # @param pluginId Plugin
  1601. # @param parameterId Parameter index
  1602. @abstractmethod
  1603. def get_current_parameter_value(self, pluginId, parameterId):
  1604. raise NotImplementedError
  1605. # Get a plugin's internal parameter value.
  1606. # @param pluginId Plugin
  1607. # @param parameterId Parameter index, maybe be negative
  1608. # @see InternalParameterIndex
  1609. @abstractmethod
  1610. def get_internal_parameter_value(self, pluginId, parameterId):
  1611. raise NotImplementedError
  1612. # Get a plugin's input peak value.
  1613. # @param pluginId Plugin
  1614. # @param isLeft Wherever to get the left/mono value, otherwise right.
  1615. @abstractmethod
  1616. def get_input_peak_value(self, pluginId, isLeft):
  1617. raise NotImplementedError
  1618. # Get a plugin's output peak value.
  1619. # @param pluginId Plugin
  1620. # @param isLeft Wherever to get the left/mono value, otherwise right.
  1621. @abstractmethod
  1622. def get_output_peak_value(self, pluginId, isLeft):
  1623. raise NotImplementedError
  1624. # Render a plugin's inline display.
  1625. # @param pluginId Plugin
  1626. @abstractmethod
  1627. def render_inline_display(self, pluginId, width, height):
  1628. raise NotImplementedError
  1629. # Enable a plugin's option.
  1630. # @param pluginId Plugin
  1631. # @param option An option from PluginOptions
  1632. # @param yesNo New enabled state
  1633. @abstractmethod
  1634. def set_option(self, pluginId, option, yesNo):
  1635. raise NotImplementedError
  1636. # Enable or disable a plugin.
  1637. # @param pluginId Plugin
  1638. # @param onOff New active state
  1639. @abstractmethod
  1640. def set_active(self, pluginId, onOff):
  1641. raise NotImplementedError
  1642. # Change a plugin's internal dry/wet.
  1643. # @param pluginId Plugin
  1644. # @param value New dry/wet value
  1645. @abstractmethod
  1646. def set_drywet(self, pluginId, value):
  1647. raise NotImplementedError
  1648. # Change a plugin's internal volume.
  1649. # @param pluginId Plugin
  1650. # @param value New volume
  1651. @abstractmethod
  1652. def set_volume(self, pluginId, value):
  1653. raise NotImplementedError
  1654. # Change a plugin's internal stereo balance, left channel.
  1655. # @param pluginId Plugin
  1656. # @param value New value
  1657. @abstractmethod
  1658. def set_balance_left(self, pluginId, value):
  1659. raise NotImplementedError
  1660. # Change a plugin's internal stereo balance, right channel.
  1661. # @param pluginId Plugin
  1662. # @param value New value
  1663. @abstractmethod
  1664. def set_balance_right(self, pluginId, value):
  1665. raise NotImplementedError
  1666. # Change a plugin's internal mono panning value.
  1667. # @param pluginId Plugin
  1668. # @param value New value
  1669. @abstractmethod
  1670. def set_panning(self, pluginId, value):
  1671. raise NotImplementedError
  1672. # Change a plugin's internal control channel.
  1673. # @param pluginId Plugin
  1674. # @param channel New channel
  1675. @abstractmethod
  1676. def set_ctrl_channel(self, pluginId, channel):
  1677. raise NotImplementedError
  1678. # Change a plugin's parameter value.
  1679. # @param pluginId Plugin
  1680. # @param parameterId Parameter index
  1681. # @param value New value
  1682. @abstractmethod
  1683. def set_parameter_value(self, pluginId, parameterId, value):
  1684. raise NotImplementedError
  1685. # Change a plugin's parameter mapped control index.
  1686. # @param pluginId Plugin
  1687. # @param parameterId Parameter index
  1688. # @param cc New MIDI cc
  1689. @abstractmethod
  1690. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  1691. raise NotImplementedError
  1692. # Change a plugin's parameter MIDI channel.
  1693. # @param pluginId Plugin
  1694. # @param parameterId Parameter index
  1695. # @param channel New control index
  1696. @abstractmethod
  1697. def set_parameter_mapped_control_index(self, pluginId, parameterId, index):
  1698. raise NotImplementedError
  1699. # Change a plugin's parameter mapped range.
  1700. # @param pluginId Plugin
  1701. # @param parameterId Parameter index
  1702. # @param minimum New mapped minimum
  1703. # @param maximum New mapped maximum
  1704. @abstractmethod
  1705. def set_parameter_mapped_range(self, pluginId, parameterId, minimum, maximum):
  1706. raise NotImplementedError
  1707. # Change a plugin's parameter in drag/touch mode state.
  1708. # Usually happens from a UI when the user is moving a parameter with a mouse or similar input.
  1709. # @param pluginId Plugin
  1710. # @param parameterId Parameter index
  1711. # @param touch New state
  1712. @abstractmethod
  1713. def set_parameter_touch(self, pluginId, parameterId, touch):
  1714. raise NotImplementedError
  1715. # Change a plugin's current program.
  1716. # @param pluginId Plugin
  1717. # @param programId New program
  1718. @abstractmethod
  1719. def set_program(self, pluginId, programId):
  1720. raise NotImplementedError
  1721. # Change a plugin's current MIDI program.
  1722. # @param pluginId Plugin
  1723. # @param midiProgramId New value
  1724. @abstractmethod
  1725. def set_midi_program(self, pluginId, midiProgramId):
  1726. raise NotImplementedError
  1727. # Set a plugin's custom data set.
  1728. # @param pluginId Plugin
  1729. # @param type Type
  1730. # @param key Key
  1731. # @param value New value
  1732. # @see CustomDataTypes and CustomDataKeys
  1733. @abstractmethod
  1734. def set_custom_data(self, pluginId, type_, key, value):
  1735. raise NotImplementedError
  1736. # Set a plugin's chunk data.
  1737. # @param pluginId Plugin
  1738. # @param chunkData New chunk data
  1739. # @see PLUGIN_OPTION_USE_CHUNKS and carla_get_chunk_data()
  1740. @abstractmethod
  1741. def set_chunk_data(self, pluginId, chunkData):
  1742. raise NotImplementedError
  1743. # Tell a plugin to prepare for save.
  1744. # This should be called before saving custom data sets.
  1745. # @param pluginId Plugin
  1746. @abstractmethod
  1747. def prepare_for_save(self, pluginId):
  1748. raise NotImplementedError
  1749. # Reset all plugin's parameters.
  1750. # @param pluginId Plugin
  1751. @abstractmethod
  1752. def reset_parameters(self, pluginId):
  1753. raise NotImplementedError
  1754. # Randomize all plugin's parameters.
  1755. # @param pluginId Plugin
  1756. @abstractmethod
  1757. def randomize_parameters(self, pluginId):
  1758. raise NotImplementedError
  1759. # Send a single note of a plugin.
  1760. # If velocity is 0, note-off is sent; note-on otherwise.
  1761. # @param pluginId Plugin
  1762. # @param channel Note channel
  1763. # @param note Note pitch
  1764. # @param velocity Note velocity
  1765. @abstractmethod
  1766. def send_midi_note(self, pluginId, channel, note, velocity):
  1767. raise NotImplementedError
  1768. # Tell a plugin to show its own custom UI.
  1769. # @param pluginId Plugin
  1770. # @param yesNo New UI state, visible or not
  1771. # @see PLUGIN_HAS_CUSTOM_UI
  1772. @abstractmethod
  1773. def show_custom_ui(self, pluginId, yesNo):
  1774. raise NotImplementedError
  1775. # Get the current engine buffer size.
  1776. @abstractmethod
  1777. def get_buffer_size(self):
  1778. raise NotImplementedError
  1779. # Get the current engine sample rate.
  1780. @abstractmethod
  1781. def get_sample_rate(self):
  1782. raise NotImplementedError
  1783. # Get the last error.
  1784. @abstractmethod
  1785. def get_last_error(self):
  1786. raise NotImplementedError
  1787. # Get the current engine OSC URL (TCP).
  1788. @abstractmethod
  1789. def get_host_osc_url_tcp(self):
  1790. raise NotImplementedError
  1791. # Get the current engine OSC URL (UDP).
  1792. @abstractmethod
  1793. def get_host_osc_url_udp(self):
  1794. raise NotImplementedError
  1795. # Initialize NSM (that is, announce ourselves to it).
  1796. # Must be called as early as possible in the program's lifecycle.
  1797. # Returns true if NSM is available and initialized correctly.
  1798. @abstractmethod
  1799. def nsm_init(self, pid, executableName):
  1800. raise NotImplementedError
  1801. # Respond to an NSM callback.
  1802. @abstractmethod
  1803. def nsm_ready(self, opcode):
  1804. raise NotImplementedError
  1805. # ---------------------------------------------------------------------------------------------------------------------
  1806. # Carla Host object (dummy/null, does nothing)
  1807. class CarlaHostNull(CarlaHostMeta):
  1808. def __init__(self):
  1809. CarlaHostMeta.__init__(self)
  1810. self.fEngineCallback = None
  1811. self.fFileCallback = None
  1812. self.fEngineRunning = False
  1813. def get_engine_driver_count(self):
  1814. return 0
  1815. def get_engine_driver_name(self, index):
  1816. return ""
  1817. def get_engine_driver_device_names(self, index):
  1818. return []
  1819. def get_engine_driver_device_info(self, index, name):
  1820. return PyEngineDriverDeviceInfo
  1821. def show_engine_driver_device_control_panel(self, index, name):
  1822. return False
  1823. def engine_init(self, driverName, clientName):
  1824. self.fEngineRunning = True
  1825. if self.fEngineCallback is not None:
  1826. self.fEngineCallback(None,
  1827. ENGINE_CALLBACK_ENGINE_STARTED,
  1828. 0,
  1829. self.processMode,
  1830. self.transportMode,
  1831. 0, 0.0,
  1832. driverName)
  1833. return True
  1834. def engine_close(self):
  1835. self.fEngineRunning = False
  1836. if self.fEngineCallback is not None:
  1837. self.fEngineCallback(None, ENGINE_CALLBACK_ENGINE_STOPPED, 0, 0, 0, 0, 0.0, "")
  1838. return True
  1839. def engine_idle(self):
  1840. return
  1841. def is_engine_running(self):
  1842. return self.fEngineRunning
  1843. def get_runtime_engine_info(self):
  1844. return PyCarlaRuntimeEngineInfo
  1845. def get_runtime_engine_driver_device_info(self):
  1846. return PyCarlaRuntimeEngineDriverDeviceInfo
  1847. def set_engine_buffer_size_and_sample_rate(self, bufferSize, sampleRate):
  1848. return False
  1849. def show_engine_device_control_panel(self):
  1850. return False
  1851. def clear_engine_xruns(self):
  1852. return
  1853. def cancel_engine_action(self):
  1854. return
  1855. def set_engine_about_to_close(self):
  1856. return True
  1857. def set_engine_callback(self, func):
  1858. self.fEngineCallback = func
  1859. def set_engine_option(self, option, value, valueStr):
  1860. return
  1861. def set_file_callback(self, func):
  1862. self.fFileCallback = func
  1863. def load_file(self, filename):
  1864. return False
  1865. def load_project(self, filename):
  1866. return False
  1867. def save_project(self, filename):
  1868. return False
  1869. def clear_project_filename(self):
  1870. return
  1871. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  1872. return False
  1873. def patchbay_disconnect(self, external, connectionId):
  1874. return False
  1875. def patchbay_set_group_pos(self, external, groupId, x1, y1, x2, y2):
  1876. return False
  1877. def patchbay_refresh(self, external):
  1878. return False
  1879. def transport_play(self):
  1880. return
  1881. def transport_pause(self):
  1882. return
  1883. def transport_bpm(self, bpm):
  1884. return
  1885. def transport_relocate(self, frame):
  1886. return
  1887. def get_current_transport_frame(self):
  1888. return 0
  1889. def get_transport_info(self):
  1890. return PyCarlaTransportInfo
  1891. def get_current_plugin_count(self):
  1892. return 0
  1893. def get_max_plugin_number(self):
  1894. return 0
  1895. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  1896. return False
  1897. def remove_plugin(self, pluginId):
  1898. return False
  1899. def remove_all_plugins(self):
  1900. return False
  1901. def rename_plugin(self, pluginId, newName):
  1902. return False
  1903. def clone_plugin(self, pluginId):
  1904. return False
  1905. def replace_plugin(self, pluginId):
  1906. return False
  1907. def switch_plugins(self, pluginIdA, pluginIdB):
  1908. return False
  1909. def load_plugin_state(self, pluginId, filename):
  1910. return False
  1911. def save_plugin_state(self, pluginId, filename):
  1912. return False
  1913. def export_plugin_lv2(self, pluginId, lv2path):
  1914. return False
  1915. def get_plugin_info(self, pluginId):
  1916. return PyCarlaPluginInfo
  1917. def get_audio_port_count_info(self, pluginId):
  1918. return PyCarlaPortCountInfo
  1919. def get_midi_port_count_info(self, pluginId):
  1920. return PyCarlaPortCountInfo
  1921. def get_parameter_count_info(self, pluginId):
  1922. return PyCarlaPortCountInfo
  1923. def get_parameter_info(self, pluginId, parameterId):
  1924. return PyCarlaParameterInfo
  1925. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  1926. return PyCarlaScalePointInfo
  1927. def get_parameter_data(self, pluginId, parameterId):
  1928. return PyParameterData
  1929. def get_parameter_ranges(self, pluginId, parameterId):
  1930. return PyParameterRanges
  1931. def get_midi_program_data(self, pluginId, midiProgramId):
  1932. return PyMidiProgramData
  1933. def get_custom_data(self, pluginId, customDataId):
  1934. return PyCustomData
  1935. def get_custom_data_value(self, pluginId, type_, key):
  1936. return ""
  1937. def get_chunk_data(self, pluginId):
  1938. return ""
  1939. def get_parameter_count(self, pluginId):
  1940. return 0
  1941. def get_program_count(self, pluginId):
  1942. return 0
  1943. def get_midi_program_count(self, pluginId):
  1944. return 0
  1945. def get_custom_data_count(self, pluginId):
  1946. return 0
  1947. def get_parameter_text(self, pluginId, parameterId):
  1948. return ""
  1949. def get_program_name(self, pluginId, programId):
  1950. return ""
  1951. def get_midi_program_name(self, pluginId, midiProgramId):
  1952. return ""
  1953. def get_real_plugin_name(self, pluginId):
  1954. return ""
  1955. def get_current_program_index(self, pluginId):
  1956. return 0
  1957. def get_current_midi_program_index(self, pluginId):
  1958. return 0
  1959. def get_default_parameter_value(self, pluginId, parameterId):
  1960. return 0.0
  1961. def get_current_parameter_value(self, pluginId, parameterId):
  1962. return 0.0
  1963. def get_internal_parameter_value(self, pluginId, parameterId):
  1964. return 0.0
  1965. def get_input_peak_value(self, pluginId, isLeft):
  1966. return 0.0
  1967. def get_output_peak_value(self, pluginId, isLeft):
  1968. return 0.0
  1969. def render_inline_display(self, pluginId, width, height):
  1970. return None
  1971. def set_option(self, pluginId, option, yesNo):
  1972. return
  1973. def set_active(self, pluginId, onOff):
  1974. return
  1975. def set_drywet(self, pluginId, value):
  1976. return
  1977. def set_volume(self, pluginId, value):
  1978. return
  1979. def set_balance_left(self, pluginId, value):
  1980. return
  1981. def set_balance_right(self, pluginId, value):
  1982. return
  1983. def set_panning(self, pluginId, value):
  1984. return
  1985. def set_ctrl_channel(self, pluginId, channel):
  1986. return
  1987. def set_parameter_value(self, pluginId, parameterId, value):
  1988. return
  1989. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  1990. return
  1991. def set_parameter_mapped_control_index(self, pluginId, parameterId, index):
  1992. return
  1993. def set_parameter_mapped_range(self, pluginId, parameterId, minimum, maximum):
  1994. return
  1995. def set_parameter_touch(self, pluginId, parameterId, touch):
  1996. return
  1997. def set_program(self, pluginId, programId):
  1998. return
  1999. def set_midi_program(self, pluginId, midiProgramId):
  2000. return
  2001. def set_custom_data(self, pluginId, type_, key, value):
  2002. return
  2003. def set_chunk_data(self, pluginId, chunkData):
  2004. return
  2005. def prepare_for_save(self, pluginId):
  2006. return
  2007. def reset_parameters(self, pluginId):
  2008. return
  2009. def randomize_parameters(self, pluginId):
  2010. return
  2011. def send_midi_note(self, pluginId, channel, note, velocity):
  2012. return
  2013. def show_custom_ui(self, pluginId, yesNo):
  2014. return
  2015. def get_buffer_size(self):
  2016. return 0
  2017. def get_sample_rate(self):
  2018. return 0.0
  2019. def get_last_error(self):
  2020. return ""
  2021. def get_host_osc_url_tcp(self):
  2022. return ""
  2023. def get_host_osc_url_udp(self):
  2024. return ""
  2025. def nsm_init(self, pid, executableName):
  2026. return False
  2027. def nsm_ready(self, opcode):
  2028. return
  2029. # ---------------------------------------------------------------------------------------------------------------------
  2030. # Carla Host object using a DLL
  2031. class CarlaHostDLL(CarlaHostMeta):
  2032. def __init__(self, libName, loadGlobal):
  2033. CarlaHostMeta.__init__(self)
  2034. # info about this host object
  2035. self.isPlugin = False
  2036. self.lib = CDLL(libName, RTLD_GLOBAL if loadGlobal else RTLD_LOCAL)
  2037. self.lib.carla_get_engine_driver_count.argtypes = None
  2038. self.lib.carla_get_engine_driver_count.restype = c_uint
  2039. self.lib.carla_get_engine_driver_name.argtypes = (c_uint,)
  2040. self.lib.carla_get_engine_driver_name.restype = c_char_p
  2041. self.lib.carla_get_engine_driver_device_names.argtypes = (c_uint,)
  2042. self.lib.carla_get_engine_driver_device_names.restype = POINTER(c_char_p)
  2043. self.lib.carla_get_engine_driver_device_info.argtypes = (c_uint, c_char_p)
  2044. self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo)
  2045. self.lib.carla_show_engine_driver_device_control_panel.argtypes = (c_uint, c_char_p)
  2046. self.lib.carla_show_engine_driver_device_control_panel.restype = c_bool
  2047. self.lib.carla_standalone_host_init.argtypes = None
  2048. self.lib.carla_standalone_host_init.restype = c_void_p
  2049. self.lib.carla_engine_init.argtypes = (c_void_p, c_char_p, c_char_p)
  2050. self.lib.carla_engine_init.restype = c_bool
  2051. self.lib.carla_engine_close.argtypes = (c_void_p,)
  2052. self.lib.carla_engine_close.restype = c_bool
  2053. self.lib.carla_engine_idle.argtypes = (c_void_p,)
  2054. self.lib.carla_engine_idle.restype = None
  2055. self.lib.carla_is_engine_running.argtypes = (c_void_p,)
  2056. self.lib.carla_is_engine_running.restype = c_bool
  2057. self.lib.carla_get_runtime_engine_info.argtypes = (c_void_p,)
  2058. self.lib.carla_get_runtime_engine_info.restype = POINTER(CarlaRuntimeEngineInfo)
  2059. self.lib.carla_get_runtime_engine_driver_device_info.argtypes = (c_void_p,)
  2060. self.lib.carla_get_runtime_engine_driver_device_info.restype = POINTER(CarlaRuntimeEngineDriverDeviceInfo)
  2061. self.lib.carla_set_engine_buffer_size_and_sample_rate.argtypes = (c_void_p, c_uint, c_double)
  2062. self.lib.carla_set_engine_buffer_size_and_sample_rate.restype = c_bool
  2063. self.lib.carla_show_engine_device_control_panel.argtypes = (c_void_p,)
  2064. self.lib.carla_show_engine_device_control_panel.restype = c_bool
  2065. self.lib.carla_clear_engine_xruns.argtypes = (c_void_p,)
  2066. self.lib.carla_clear_engine_xruns.restype = None
  2067. self.lib.carla_cancel_engine_action.argtypes = (c_void_p,)
  2068. self.lib.carla_cancel_engine_action.restype = None
  2069. self.lib.carla_set_engine_about_to_close.argtypes = (c_void_p,)
  2070. self.lib.carla_set_engine_about_to_close.restype = c_bool
  2071. self.lib.carla_set_engine_callback.argtypes = (c_void_p, EngineCallbackFunc, c_void_p)
  2072. self.lib.carla_set_engine_callback.restype = None
  2073. self.lib.carla_set_engine_option.argtypes = (c_void_p, c_enum, c_int, c_char_p)
  2074. self.lib.carla_set_engine_option.restype = None
  2075. self.lib.carla_set_file_callback.argtypes = (c_void_p, FileCallbackFunc, c_void_p)
  2076. self.lib.carla_set_file_callback.restype = None
  2077. self.lib.carla_load_file.argtypes = (c_void_p, c_char_p)
  2078. self.lib.carla_load_file.restype = c_bool
  2079. self.lib.carla_load_project.argtypes = (c_void_p, c_char_p)
  2080. self.lib.carla_load_project.restype = c_bool
  2081. self.lib.carla_save_project.argtypes = (c_void_p, c_char_p)
  2082. self.lib.carla_save_project.restype = c_bool
  2083. self.lib.carla_clear_project_filename.argtypes = (c_void_p,)
  2084. self.lib.carla_clear_project_filename.restype = None
  2085. self.lib.carla_patchbay_connect.argtypes = (c_void_p, c_bool, c_uint, c_uint, c_uint, c_uint)
  2086. self.lib.carla_patchbay_connect.restype = c_bool
  2087. self.lib.carla_patchbay_disconnect.argtypes = (c_void_p, c_bool, c_uint)
  2088. self.lib.carla_patchbay_disconnect.restype = c_bool
  2089. self.lib.carla_patchbay_set_group_pos.argtypes = (c_void_p, c_bool, c_uint, c_int, c_int, c_int, c_int)
  2090. self.lib.carla_patchbay_set_group_pos.restype = c_bool
  2091. self.lib.carla_patchbay_refresh.argtypes = (c_void_p, c_bool)
  2092. self.lib.carla_patchbay_refresh.restype = c_bool
  2093. self.lib.carla_transport_play.argtypes = (c_void_p,)
  2094. self.lib.carla_transport_play.restype = None
  2095. self.lib.carla_transport_pause.argtypes = (c_void_p,)
  2096. self.lib.carla_transport_pause.restype = None
  2097. self.lib.carla_transport_bpm.argtypes = (c_void_p, c_double)
  2098. self.lib.carla_transport_bpm.restype = None
  2099. self.lib.carla_transport_relocate.argtypes = (c_void_p, c_uint64)
  2100. self.lib.carla_transport_relocate.restype = None
  2101. self.lib.carla_get_current_transport_frame.argtypes = (c_void_p,)
  2102. self.lib.carla_get_current_transport_frame.restype = c_uint64
  2103. self.lib.carla_get_transport_info.argtypes = (c_void_p,)
  2104. self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)
  2105. self.lib.carla_get_current_plugin_count.argtypes = (c_void_p,)
  2106. self.lib.carla_get_current_plugin_count.restype = c_uint32
  2107. self.lib.carla_get_max_plugin_number.argtypes = (c_void_p,)
  2108. self.lib.carla_get_max_plugin_number.restype = c_uint32
  2109. self.lib.carla_add_plugin.argtypes = (c_void_p, c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_int64,
  2110. c_void_p, c_uint)
  2111. self.lib.carla_add_plugin.restype = c_bool
  2112. self.lib.carla_remove_plugin.argtypes = (c_void_p, c_uint)
  2113. self.lib.carla_remove_plugin.restype = c_bool
  2114. self.lib.carla_remove_all_plugins.argtypes = (c_void_p,)
  2115. self.lib.carla_remove_all_plugins.restype = c_bool
  2116. self.lib.carla_rename_plugin.argtypes = (c_void_p, c_uint, c_char_p)
  2117. self.lib.carla_rename_plugin.restype = c_bool
  2118. self.lib.carla_clone_plugin.argtypes = (c_void_p, c_uint)
  2119. self.lib.carla_clone_plugin.restype = c_bool
  2120. self.lib.carla_replace_plugin.argtypes = (c_void_p, c_uint)
  2121. self.lib.carla_replace_plugin.restype = c_bool
  2122. self.lib.carla_switch_plugins.argtypes = (c_void_p, c_uint, c_uint)
  2123. self.lib.carla_switch_plugins.restype = c_bool
  2124. self.lib.carla_load_plugin_state.argtypes = (c_void_p, c_uint, c_char_p)
  2125. self.lib.carla_load_plugin_state.restype = c_bool
  2126. self.lib.carla_save_plugin_state.argtypes = (c_void_p, c_uint, c_char_p)
  2127. self.lib.carla_save_plugin_state.restype = c_bool
  2128. self.lib.carla_export_plugin_lv2.argtypes = (c_void_p, c_uint, c_char_p)
  2129. self.lib.carla_export_plugin_lv2.restype = c_bool
  2130. self.lib.carla_get_plugin_info.argtypes = (c_void_p, c_uint)
  2131. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  2132. self.lib.carla_get_audio_port_count_info.argtypes = (c_void_p, c_uint)
  2133. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  2134. self.lib.carla_get_midi_port_count_info.argtypes = (c_void_p, c_uint)
  2135. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  2136. self.lib.carla_get_parameter_count_info.argtypes = (c_void_p, c_uint)
  2137. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  2138. self.lib.carla_get_parameter_info.argtypes = (c_void_p, c_uint, c_uint32)
  2139. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  2140. self.lib.carla_get_parameter_scalepoint_info.argtypes = (c_void_p, c_uint, c_uint32, c_uint32)
  2141. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  2142. self.lib.carla_get_parameter_data.argtypes = (c_void_p, c_uint, c_uint32)
  2143. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  2144. self.lib.carla_get_parameter_ranges.argtypes = (c_void_p, c_uint, c_uint32)
  2145. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  2146. self.lib.carla_get_midi_program_data.argtypes = (c_void_p, c_uint, c_uint32)
  2147. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  2148. self.lib.carla_get_custom_data.argtypes = (c_void_p, c_uint, c_uint32)
  2149. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  2150. self.lib.carla_get_custom_data_value.argtypes = (c_void_p, c_uint, c_char_p, c_char_p)
  2151. self.lib.carla_get_custom_data_value.restype = c_char_p
  2152. self.lib.carla_get_chunk_data.argtypes = (c_void_p, c_uint)
  2153. self.lib.carla_get_chunk_data.restype = c_char_p
  2154. self.lib.carla_get_parameter_count.argtypes = (c_void_p, c_uint)
  2155. self.lib.carla_get_parameter_count.restype = c_uint32
  2156. self.lib.carla_get_program_count.argtypes = (c_void_p, c_uint)
  2157. self.lib.carla_get_program_count.restype = c_uint32
  2158. self.lib.carla_get_midi_program_count.argtypes = (c_void_p, c_uint)
  2159. self.lib.carla_get_midi_program_count.restype = c_uint32
  2160. self.lib.carla_get_custom_data_count.argtypes = (c_void_p, c_uint)
  2161. self.lib.carla_get_custom_data_count.restype = c_uint32
  2162. self.lib.carla_get_parameter_text.argtypes = (c_void_p, c_uint, c_uint32)
  2163. self.lib.carla_get_parameter_text.restype = c_char_p
  2164. self.lib.carla_get_program_name.argtypes = (c_void_p, c_uint, c_uint32)
  2165. self.lib.carla_get_program_name.restype = c_char_p
  2166. self.lib.carla_get_midi_program_name.argtypes = (c_void_p, c_uint, c_uint32)
  2167. self.lib.carla_get_midi_program_name.restype = c_char_p
  2168. self.lib.carla_get_real_plugin_name.argtypes = (c_void_p, c_uint)
  2169. self.lib.carla_get_real_plugin_name.restype = c_char_p
  2170. self.lib.carla_get_current_program_index.argtypes = (c_void_p, c_uint)
  2171. self.lib.carla_get_current_program_index.restype = c_int32
  2172. self.lib.carla_get_current_midi_program_index.argtypes = (c_void_p, c_uint)
  2173. self.lib.carla_get_current_midi_program_index.restype = c_int32
  2174. self.lib.carla_get_default_parameter_value.argtypes = (c_void_p, c_uint, c_uint32)
  2175. self.lib.carla_get_default_parameter_value.restype = c_float
  2176. self.lib.carla_get_current_parameter_value.argtypes = (c_void_p, c_uint, c_uint32)
  2177. self.lib.carla_get_current_parameter_value.restype = c_float
  2178. self.lib.carla_get_internal_parameter_value.argtypes = (c_void_p, c_uint, c_int32)
  2179. self.lib.carla_get_internal_parameter_value.restype = c_float
  2180. self.lib.carla_get_input_peak_value.argtypes = (c_void_p, c_uint, c_bool)
  2181. self.lib.carla_get_input_peak_value.restype = c_float
  2182. self.lib.carla_get_output_peak_value.argtypes = (c_void_p, c_uint, c_bool)
  2183. self.lib.carla_get_output_peak_value.restype = c_float
  2184. self.lib.carla_render_inline_display.argtypes = (c_void_p, c_uint, c_uint, c_uint)
  2185. self.lib.carla_render_inline_display.restype = POINTER(CarlaInlineDisplayImageSurface)
  2186. self.lib.carla_set_option.argtypes = (c_void_p, c_uint, c_uint, c_bool)
  2187. self.lib.carla_set_option.restype = None
  2188. self.lib.carla_set_active.argtypes = (c_void_p, c_uint, c_bool)
  2189. self.lib.carla_set_active.restype = None
  2190. self.lib.carla_set_drywet.argtypes = (c_void_p, c_uint, c_float)
  2191. self.lib.carla_set_drywet.restype = None
  2192. self.lib.carla_set_volume.argtypes = (c_void_p, c_uint, c_float)
  2193. self.lib.carla_set_volume.restype = None
  2194. self.lib.carla_set_balance_left.argtypes = (c_void_p, c_uint, c_float)
  2195. self.lib.carla_set_balance_left.restype = None
  2196. self.lib.carla_set_balance_right.argtypes = (c_void_p, c_uint, c_float)
  2197. self.lib.carla_set_balance_right.restype = None
  2198. self.lib.carla_set_panning.argtypes = (c_void_p, c_uint, c_float)
  2199. self.lib.carla_set_panning.restype = None
  2200. self.lib.carla_set_ctrl_channel.argtypes = (c_void_p, c_uint, c_int8)
  2201. self.lib.carla_set_ctrl_channel.restype = None
  2202. self.lib.carla_set_parameter_value.argtypes = (c_void_p, c_uint, c_uint32, c_float)
  2203. self.lib.carla_set_parameter_value.restype = None
  2204. self.lib.carla_set_parameter_midi_channel.argtypes = (c_void_p, c_uint, c_uint32, c_uint8)
  2205. self.lib.carla_set_parameter_midi_channel.restype = None
  2206. self.lib.carla_set_parameter_mapped_control_index.argtypes = (c_void_p, c_uint, c_uint32, c_int16)
  2207. self.lib.carla_set_parameter_mapped_control_index.restype = None
  2208. self.lib.carla_set_parameter_mapped_range.argtypes = (c_void_p, c_uint, c_uint32, c_float, c_float)
  2209. self.lib.carla_set_parameter_mapped_range.restype = None
  2210. self.lib.carla_set_parameter_touch.argtypes = (c_void_p, c_uint, c_uint32, c_bool)
  2211. self.lib.carla_set_parameter_touch.restype = None
  2212. self.lib.carla_set_program.argtypes = (c_void_p, c_uint, c_uint32)
  2213. self.lib.carla_set_program.restype = None
  2214. self.lib.carla_set_midi_program.argtypes = (c_void_p, c_uint, c_uint32)
  2215. self.lib.carla_set_midi_program.restype = None
  2216. self.lib.carla_set_custom_data.argtypes = (c_void_p, c_uint, c_char_p, c_char_p, c_char_p)
  2217. self.lib.carla_set_custom_data.restype = None
  2218. self.lib.carla_set_chunk_data.argtypes = (c_void_p, c_uint, c_char_p)
  2219. self.lib.carla_set_chunk_data.restype = None
  2220. self.lib.carla_prepare_for_save.argtypes = (c_void_p, c_uint)
  2221. self.lib.carla_prepare_for_save.restype = None
  2222. self.lib.carla_reset_parameters.argtypes = (c_void_p, c_uint)
  2223. self.lib.carla_reset_parameters.restype = None
  2224. self.lib.carla_randomize_parameters.argtypes = (c_void_p, c_uint)
  2225. self.lib.carla_randomize_parameters.restype = None
  2226. self.lib.carla_send_midi_note.argtypes = (c_void_p, c_uint, c_uint8, c_uint8, c_uint8)
  2227. self.lib.carla_send_midi_note.restype = None
  2228. self.lib.carla_show_custom_ui.argtypes = (c_void_p, c_uint, c_bool)
  2229. self.lib.carla_show_custom_ui.restype = None
  2230. self.lib.carla_get_buffer_size.argtypes = (c_void_p,)
  2231. self.lib.carla_get_buffer_size.restype = c_uint32
  2232. self.lib.carla_get_sample_rate.argtypes = (c_void_p,)
  2233. self.lib.carla_get_sample_rate.restype = c_double
  2234. self.lib.carla_get_last_error.argtypes = (c_void_p,)
  2235. self.lib.carla_get_last_error.restype = c_char_p
  2236. self.lib.carla_get_host_osc_url_tcp.argtypes = (c_void_p,)
  2237. self.lib.carla_get_host_osc_url_tcp.restype = c_char_p
  2238. self.lib.carla_get_host_osc_url_udp.argtypes = (c_void_p,)
  2239. self.lib.carla_get_host_osc_url_udp.restype = c_char_p
  2240. self.lib.carla_nsm_init.argtypes = (c_void_p, c_uint64, c_char_p)
  2241. self.lib.carla_nsm_init.restype = c_bool
  2242. self.lib.carla_nsm_ready.argtypes = (c_void_p, c_int)
  2243. self.lib.carla_nsm_ready.restype = None
  2244. self.handle = self.lib.carla_standalone_host_init()
  2245. self._engineCallback = None
  2246. self._fileCallback = None
  2247. # --------------------------------------------------------------------------------------------------------
  2248. def get_engine_driver_count(self):
  2249. return int(self.lib.carla_get_engine_driver_count())
  2250. def get_engine_driver_name(self, index):
  2251. return charPtrToString(self.lib.carla_get_engine_driver_name(index))
  2252. def get_engine_driver_device_names(self, index):
  2253. return charPtrPtrToStringList(self.lib.carla_get_engine_driver_device_names(index))
  2254. def get_engine_driver_device_info(self, index, name):
  2255. return structToDict(self.lib.carla_get_engine_driver_device_info(index, name.encode("utf-8")).contents)
  2256. def show_engine_driver_device_control_panel(self, index, name):
  2257. return bool(self.lib.carla_show_engine_driver_device_control_panel(index, name.encode("utf-8")))
  2258. def engine_init(self, driverName, clientName):
  2259. return bool(self.lib.carla_engine_init(self.handle, driverName.encode("utf-8"), clientName.encode("utf-8")))
  2260. def engine_close(self):
  2261. return bool(self.lib.carla_engine_close(self.handle))
  2262. def engine_idle(self):
  2263. self.lib.carla_engine_idle(self.handle)
  2264. def is_engine_running(self):
  2265. return bool(self.lib.carla_is_engine_running(self.handle))
  2266. def get_runtime_engine_info(self):
  2267. return structToDict(self.lib.carla_get_runtime_engine_info(self.handle).contents)
  2268. def get_runtime_engine_driver_device_info(self):
  2269. return structToDict(self.lib.carla_get_runtime_engine_driver_device_info(self.handle).contents)
  2270. def set_engine_buffer_size_and_sample_rate(self, bufferSize, sampleRate):
  2271. return bool(self.lib.carla_set_engine_buffer_size_and_sample_rate(self.handle, bufferSize, sampleRate))
  2272. def show_engine_device_control_panel(self):
  2273. return bool(self.lib.carla_show_engine_device_control_panel(self.handle))
  2274. def clear_engine_xruns(self):
  2275. self.lib.carla_clear_engine_xruns(self.handle)
  2276. def cancel_engine_action(self):
  2277. self.lib.carla_cancel_engine_action(self.handle)
  2278. def set_engine_about_to_close(self):
  2279. return bool(self.lib.carla_set_engine_about_to_close(self.handle))
  2280. def set_engine_callback(self, func):
  2281. self._engineCallback = EngineCallbackFunc(func)
  2282. self.lib.carla_set_engine_callback(self.handle, self._engineCallback, None)
  2283. def set_engine_option(self, option, value, valueStr):
  2284. self.lib.carla_set_engine_option(self.handle, option, value, valueStr.encode("utf-8"))
  2285. def set_file_callback(self, func):
  2286. self._fileCallback = FileCallbackFunc(func)
  2287. self.lib.carla_set_file_callback(self.handle, self._fileCallback, None)
  2288. def load_file(self, filename):
  2289. return bool(self.lib.carla_load_file(self.handle, filename.encode("utf-8")))
  2290. def load_project(self, filename):
  2291. return bool(self.lib.carla_load_project(self.handle, filename.encode("utf-8")))
  2292. def save_project(self, filename):
  2293. return bool(self.lib.carla_save_project(self.handle, filename.encode("utf-8")))
  2294. def clear_project_filename(self):
  2295. self.lib.carla_clear_project_filename(self.handle)
  2296. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  2297. return bool(self.lib.carla_patchbay_connect(self.handle, external, groupIdA, portIdA, groupIdB, portIdB))
  2298. def patchbay_disconnect(self, external, connectionId):
  2299. return bool(self.lib.carla_patchbay_disconnect(self.handle, external, connectionId))
  2300. def patchbay_set_group_pos(self, external, groupId, x1, y1, x2, y2):
  2301. return bool(self.lib.carla_patchbay_set_group_pos(self.handle, external, groupId, x1, y1, x2, y2))
  2302. def patchbay_refresh(self, external):
  2303. return bool(self.lib.carla_patchbay_refresh(self.handle, external))
  2304. def transport_play(self):
  2305. self.lib.carla_transport_play(self.handle)
  2306. def transport_pause(self):
  2307. self.lib.carla_transport_pause(self.handle)
  2308. def transport_bpm(self, bpm):
  2309. self.lib.carla_transport_bpm(self.handle, bpm)
  2310. def transport_relocate(self, frame):
  2311. self.lib.carla_transport_relocate(self.handle, frame)
  2312. def get_current_transport_frame(self):
  2313. return int(self.lib.carla_get_current_transport_frame(self.handle))
  2314. def get_transport_info(self):
  2315. return structToDict(self.lib.carla_get_transport_info(self.handle).contents)
  2316. def get_current_plugin_count(self):
  2317. return int(self.lib.carla_get_current_plugin_count(self.handle))
  2318. def get_max_plugin_number(self):
  2319. return int(self.lib.carla_get_max_plugin_number(self.handle))
  2320. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  2321. cfilename = filename.encode("utf-8") if filename else None
  2322. cname = name.encode("utf-8") if name else None
  2323. if ptype == PLUGIN_JACK:
  2324. clabel = bytes(ord(b) for b in label)
  2325. else:
  2326. clabel = label.encode("utf-8") if label else None
  2327. return bool(self.lib.carla_add_plugin(self.handle,
  2328. btype, ptype,
  2329. cfilename, cname, clabel, uniqueId, cast(extraPtr, c_void_p), options))
  2330. def remove_plugin(self, pluginId):
  2331. return bool(self.lib.carla_remove_plugin(self.handle, pluginId))
  2332. def remove_all_plugins(self):
  2333. return bool(self.lib.carla_remove_all_plugins(self.handle))
  2334. def rename_plugin(self, pluginId, newName):
  2335. return bool(self.lib.carla_rename_plugin(self.handle, pluginId, newName.encode("utf-8")))
  2336. def clone_plugin(self, pluginId):
  2337. return bool(self.lib.carla_clone_plugin(self.handle, pluginId))
  2338. def replace_plugin(self, pluginId):
  2339. return bool(self.lib.carla_replace_plugin(self.handle, pluginId))
  2340. def switch_plugins(self, pluginIdA, pluginIdB):
  2341. return bool(self.lib.carla_switch_plugins(self.handle, pluginIdA, pluginIdB))
  2342. def load_plugin_state(self, pluginId, filename):
  2343. return bool(self.lib.carla_load_plugin_state(self.handle, pluginId, filename.encode("utf-8")))
  2344. def save_plugin_state(self, pluginId, filename):
  2345. return bool(self.lib.carla_save_plugin_state(self.handle, pluginId, filename.encode("utf-8")))
  2346. def export_plugin_lv2(self, pluginId, lv2path):
  2347. return bool(self.lib.carla_export_plugin_lv2(self.handle, pluginId, lv2path.encode("utf-8")))
  2348. def get_plugin_info(self, pluginId):
  2349. return structToDict(self.lib.carla_get_plugin_info(self.handle, pluginId).contents)
  2350. def get_audio_port_count_info(self, pluginId):
  2351. return structToDict(self.lib.carla_get_audio_port_count_info(self.handle, pluginId).contents)
  2352. def get_midi_port_count_info(self, pluginId):
  2353. return structToDict(self.lib.carla_get_midi_port_count_info(self.handle, pluginId).contents)
  2354. def get_parameter_count_info(self, pluginId):
  2355. return structToDict(self.lib.carla_get_parameter_count_info(self.handle, pluginId).contents)
  2356. def get_parameter_info(self, pluginId, parameterId):
  2357. return structToDict(self.lib.carla_get_parameter_info(self.handle, pluginId, parameterId).contents)
  2358. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  2359. return structToDict(self.lib.carla_get_parameter_scalepoint_info(self.handle,
  2360. pluginId,
  2361. parameterId,
  2362. scalePointId).contents)
  2363. def get_parameter_data(self, pluginId, parameterId):
  2364. return structToDict(self.lib.carla_get_parameter_data(self.handle, pluginId, parameterId).contents)
  2365. def get_parameter_ranges(self, pluginId, parameterId):
  2366. return structToDict(self.lib.carla_get_parameter_ranges(self.handle, pluginId, parameterId).contents)
  2367. def get_midi_program_data(self, pluginId, midiProgramId):
  2368. return structToDict(self.lib.carla_get_midi_program_data(self.handle, pluginId, midiProgramId).contents)
  2369. def get_custom_data(self, pluginId, customDataId):
  2370. return structToDict(self.lib.carla_get_custom_data(self.handle, pluginId, customDataId).contents)
  2371. def get_custom_data_value(self, pluginId, type_, key):
  2372. return charPtrToString(self.lib.carla_get_custom_data_value(self.handle,
  2373. pluginId,
  2374. type_.encode("utf-8"),
  2375. key.encode("utf-8")))
  2376. def get_chunk_data(self, pluginId):
  2377. return charPtrToString(self.lib.carla_get_chunk_data(self.handle, pluginId))
  2378. def get_parameter_count(self, pluginId):
  2379. return int(self.lib.carla_get_parameter_count(self.handle, pluginId))
  2380. def get_program_count(self, pluginId):
  2381. return int(self.lib.carla_get_program_count(self.handle, pluginId))
  2382. def get_midi_program_count(self, pluginId):
  2383. return int(self.lib.carla_get_midi_program_count(self.handle, pluginId))
  2384. def get_custom_data_count(self, pluginId):
  2385. return int(self.lib.carla_get_custom_data_count(self.handle, pluginId))
  2386. def get_parameter_text(self, pluginId, parameterId):
  2387. return charPtrToString(self.lib.carla_get_parameter_text(self.handle, pluginId, parameterId))
  2388. def get_program_name(self, pluginId, programId):
  2389. return charPtrToString(self.lib.carla_get_program_name(self.handle, pluginId, programId))
  2390. def get_midi_program_name(self, pluginId, midiProgramId):
  2391. return charPtrToString(self.lib.carla_get_midi_program_name(self.handle, pluginId, midiProgramId))
  2392. def get_real_plugin_name(self, pluginId):
  2393. return charPtrToString(self.lib.carla_get_real_plugin_name(self.handle, pluginId))
  2394. def get_current_program_index(self, pluginId):
  2395. return int(self.lib.carla_get_current_program_index(self.handle, pluginId))
  2396. def get_current_midi_program_index(self, pluginId):
  2397. return int(self.lib.carla_get_current_midi_program_index(self.handle, pluginId))
  2398. def get_default_parameter_value(self, pluginId, parameterId):
  2399. return float(self.lib.carla_get_default_parameter_value(self.handle, pluginId, parameterId))
  2400. def get_current_parameter_value(self, pluginId, parameterId):
  2401. return float(self.lib.carla_get_current_parameter_value(self.handle, pluginId, parameterId))
  2402. def get_internal_parameter_value(self, pluginId, parameterId):
  2403. return float(self.lib.carla_get_internal_parameter_value(self.handle, pluginId, parameterId))
  2404. def get_input_peak_value(self, pluginId, isLeft):
  2405. return float(self.lib.carla_get_input_peak_value(self.handle, pluginId, isLeft))
  2406. def get_output_peak_value(self, pluginId, isLeft):
  2407. return float(self.lib.carla_get_output_peak_value(self.handle, pluginId, isLeft))
  2408. def render_inline_display(self, pluginId, width, height):
  2409. ptr = self.lib.carla_render_inline_display(self.handle, pluginId, width, height)
  2410. if not ptr or not ptr.contents:
  2411. return None
  2412. contents = ptr.contents
  2413. datalen = contents.height * contents.stride
  2414. databuf = pack("%iB" % datalen, *contents.data[:datalen])
  2415. data = {
  2416. 'data': databuf,
  2417. 'width': contents.width,
  2418. 'height': contents.height,
  2419. 'stride': contents.stride,
  2420. }
  2421. return data
  2422. def set_option(self, pluginId, option, yesNo):
  2423. self.lib.carla_set_option(self.handle, pluginId, option, yesNo)
  2424. def set_active(self, pluginId, onOff):
  2425. self.lib.carla_set_active(self.handle, pluginId, onOff)
  2426. def set_drywet(self, pluginId, value):
  2427. self.lib.carla_set_drywet(self.handle, pluginId, value)
  2428. def set_volume(self, pluginId, value):
  2429. self.lib.carla_set_volume(self.handle, pluginId, value)
  2430. def set_balance_left(self, pluginId, value):
  2431. self.lib.carla_set_balance_left(self.handle, pluginId, value)
  2432. def set_balance_right(self, pluginId, value):
  2433. self.lib.carla_set_balance_right(self.handle, pluginId, value)
  2434. def set_panning(self, pluginId, value):
  2435. self.lib.carla_set_panning(self.handle, pluginId, value)
  2436. def set_ctrl_channel(self, pluginId, channel):
  2437. self.lib.carla_set_ctrl_channel(self.handle, pluginId, channel)
  2438. def set_parameter_value(self, pluginId, parameterId, value):
  2439. self.lib.carla_set_parameter_value(self.handle, pluginId, parameterId, value)
  2440. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  2441. self.lib.carla_set_parameter_midi_channel(self.handle, pluginId, parameterId, channel)
  2442. def set_parameter_mapped_control_index(self, pluginId, parameterId, index):
  2443. self.lib.carla_set_parameter_mapped_control_index(self.handle, pluginId, parameterId, index)
  2444. def set_parameter_mapped_range(self, pluginId, parameterId, minimum, maximum):
  2445. self.lib.carla_set_parameter_mapped_range(self.handle, pluginId, parameterId, minimum, maximum)
  2446. def set_parameter_touch(self, pluginId, parameterId, touch):
  2447. self.lib.carla_set_parameter_touch(self.handle, pluginId, parameterId, touch)
  2448. def set_program(self, pluginId, programId):
  2449. self.lib.carla_set_program(self.handle, pluginId, programId)
  2450. def set_midi_program(self, pluginId, midiProgramId):
  2451. self.lib.carla_set_midi_program(self.handle, pluginId, midiProgramId)
  2452. def set_custom_data(self, pluginId, type_, key, value):
  2453. self.lib.carla_set_custom_data(self.handle,
  2454. pluginId,
  2455. type_.encode("utf-8"),
  2456. key.encode("utf-8"),
  2457. value.encode("utf-8"))
  2458. def set_chunk_data(self, pluginId, chunkData):
  2459. self.lib.carla_set_chunk_data(self.handle, pluginId, chunkData.encode("utf-8"))
  2460. def prepare_for_save(self, pluginId):
  2461. self.lib.carla_prepare_for_save(self.handle, pluginId)
  2462. def reset_parameters(self, pluginId):
  2463. self.lib.carla_reset_parameters(self.handle, pluginId)
  2464. def randomize_parameters(self, pluginId):
  2465. self.lib.carla_randomize_parameters(self.handle, pluginId)
  2466. def send_midi_note(self, pluginId, channel, note, velocity):
  2467. self.lib.carla_send_midi_note(self.handle, pluginId, channel, note, velocity)
  2468. def show_custom_ui(self, pluginId, yesNo):
  2469. self.lib.carla_show_custom_ui(self.handle, pluginId, yesNo)
  2470. def get_buffer_size(self):
  2471. return int(self.lib.carla_get_buffer_size(self.handle))
  2472. def get_sample_rate(self):
  2473. return float(self.lib.carla_get_sample_rate(self.handle))
  2474. def get_last_error(self):
  2475. return charPtrToString(self.lib.carla_get_last_error(self.handle))
  2476. def get_host_osc_url_tcp(self):
  2477. return charPtrToString(self.lib.carla_get_host_osc_url_tcp(self.handle))
  2478. def get_host_osc_url_udp(self):
  2479. return charPtrToString(self.lib.carla_get_host_osc_url_udp(self.handle))
  2480. def nsm_init(self, pid, executableName):
  2481. return bool(self.lib.carla_nsm_init(self.handle, pid, executableName.encode("utf-8")))
  2482. def nsm_ready(self, opcode):
  2483. self.lib.carla_nsm_ready(self.handle, opcode)
  2484. # ---------------------------------------------------------------------------------------------------------------------
  2485. # Helper object for CarlaHostPlugin
  2486. class PluginStoreInfo():
  2487. def __init__(self):
  2488. self.clear()
  2489. def clear(self):
  2490. self.pluginInfo = PyCarlaPluginInfo.copy()
  2491. self.pluginRealName = ""
  2492. self.internalValues = [0.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0]
  2493. self.audioCountInfo = PyCarlaPortCountInfo.copy()
  2494. self.midiCountInfo = PyCarlaPortCountInfo.copy()
  2495. self.parameterCount = 0
  2496. self.parameterCountInfo = PyCarlaPortCountInfo.copy()
  2497. self.parameterInfo = []
  2498. self.parameterData = []
  2499. self.parameterRanges = []
  2500. self.parameterValues = []
  2501. self.programCount = 0
  2502. self.programCurrent = -1
  2503. self.programNames = []
  2504. self.midiProgramCount = 0
  2505. self.midiProgramCurrent = -1
  2506. self.midiProgramData = []
  2507. self.customDataCount = 0
  2508. self.customData = []
  2509. self.peaks = [0.0, 0.0, 0.0, 0.0]
  2510. # ---------------------------------------------------------------------------------------------------------------------
  2511. # Carla Host object for plugins (using pipes)
  2512. class CarlaHostPlugin(CarlaHostMeta):
  2513. def __init__(self):
  2514. CarlaHostMeta.__init__(self)
  2515. # info about this host object
  2516. self.isPlugin = True
  2517. self.processModeForced = True
  2518. # text data to return when requested
  2519. self.fMaxPluginNumber = 0
  2520. self.fLastError = ""
  2521. # plugin info
  2522. self.fPluginsInfo = {}
  2523. self.fFallbackPluginInfo = PluginStoreInfo()
  2524. # runtime engine info
  2525. self.fRuntimeEngineInfo = {
  2526. "load": 0.0,
  2527. "xruns": 0
  2528. }
  2529. # transport info
  2530. self.fTransportInfo = {
  2531. "playing": False,
  2532. "frame": 0,
  2533. "bar": 0,
  2534. "beat": 0,
  2535. "tick": 0,
  2536. "bpm": 0.0
  2537. }
  2538. # some other vars
  2539. self.fBufferSize = 0
  2540. self.fSampleRate = 0.0
  2541. self.fOscTCP = ""
  2542. self.fOscUDP = ""
  2543. # --------------------------------------------------------------------------------------------------------
  2544. # Needs to be reimplemented
  2545. @abstractmethod
  2546. def sendMsg(self, lines):
  2547. raise NotImplementedError
  2548. # internal, sets error if sendMsg failed
  2549. def sendMsgAndSetError(self, lines):
  2550. if self.sendMsg(lines):
  2551. return True
  2552. self.fLastError = "Communication error with backend"
  2553. return False
  2554. # --------------------------------------------------------------------------------------------------------
  2555. def get_engine_driver_count(self):
  2556. return 1
  2557. def get_engine_driver_name(self, index):
  2558. return "Plugin"
  2559. def get_engine_driver_device_names(self, index):
  2560. return []
  2561. def get_engine_driver_device_info(self, index, name):
  2562. return PyEngineDriverDeviceInfo
  2563. def show_engine_driver_device_control_panel(self, index, name):
  2564. return False
  2565. def get_runtime_engine_info(self):
  2566. return self.fRuntimeEngineInfo
  2567. def get_runtime_engine_driver_device_info(self):
  2568. return PyCarlaRuntimeEngineDriverDeviceInfo
  2569. def set_engine_buffer_size_and_sample_rate(self, bufferSize, sampleRate):
  2570. return False
  2571. def show_engine_device_control_panel(self):
  2572. return False
  2573. def clear_engine_xruns(self):
  2574. self.sendMsg(["clear_engine_xruns"])
  2575. def cancel_engine_action(self):
  2576. self.sendMsg(["cancel_engine_action"])
  2577. def set_engine_callback(self, func):
  2578. return # TODO
  2579. def set_engine_option(self, option, value, valueStr):
  2580. self.sendMsg(["set_engine_option", option, int(value), valueStr])
  2581. def set_file_callback(self, func):
  2582. return # TODO
  2583. def load_file(self, filename):
  2584. return self.sendMsgAndSetError(["load_file", filename])
  2585. def load_project(self, filename):
  2586. return self.sendMsgAndSetError(["load_project", filename])
  2587. def save_project(self, filename):
  2588. return self.sendMsgAndSetError(["save_project", filename])
  2589. def clear_project_filename(self):
  2590. return self.sendMsgAndSetError(["clear_project_filename"])
  2591. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  2592. return self.sendMsgAndSetError(["patchbay_connect", external, groupIdA, portIdA, groupIdB, portIdB])
  2593. def patchbay_disconnect(self, external, connectionId):
  2594. return self.sendMsgAndSetError(["patchbay_disconnect", external, connectionId])
  2595. def patchbay_set_group_pos(self, external, groupId, x1, y1, x2, y2):
  2596. return self.sendMsgAndSetError(["patchbay_set_group_pos", external, groupId, x1, y1, x2, y2])
  2597. def patchbay_refresh(self, external):
  2598. return self.sendMsgAndSetError(["patchbay_refresh", external])
  2599. def transport_play(self):
  2600. self.sendMsg(["transport_play"])
  2601. def transport_pause(self):
  2602. self.sendMsg(["transport_pause"])
  2603. def transport_bpm(self, bpm):
  2604. self.sendMsg(["transport_bpm", bpm])
  2605. def transport_relocate(self, frame):
  2606. self.sendMsg(["transport_relocate", frame])
  2607. def get_current_transport_frame(self):
  2608. return self.fTransportInfo['frame']
  2609. def get_transport_info(self):
  2610. return self.fTransportInfo
  2611. def get_current_plugin_count(self):
  2612. return len(self.fPluginsInfo)
  2613. def get_max_plugin_number(self):
  2614. return self.fMaxPluginNumber
  2615. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  2616. return self.sendMsgAndSetError(["add_plugin",
  2617. btype, ptype,
  2618. filename or "(null)",
  2619. name or "(null)",
  2620. label, uniqueId, options])
  2621. def remove_plugin(self, pluginId):
  2622. return self.sendMsgAndSetError(["remove_plugin", pluginId])
  2623. def remove_all_plugins(self):
  2624. return self.sendMsgAndSetError(["remove_all_plugins"])
  2625. def rename_plugin(self, pluginId, newName):
  2626. return self.sendMsgAndSetError(["rename_plugin", pluginId, newName])
  2627. def clone_plugin(self, pluginId):
  2628. return self.sendMsgAndSetError(["clone_plugin", pluginId])
  2629. def replace_plugin(self, pluginId):
  2630. return self.sendMsgAndSetError(["replace_plugin", pluginId])
  2631. def switch_plugins(self, pluginIdA, pluginIdB):
  2632. ret = self.sendMsgAndSetError(["switch_plugins", pluginIdA, pluginIdB])
  2633. if ret:
  2634. self._switchPlugins(pluginIdA, pluginIdB)
  2635. return ret
  2636. def load_plugin_state(self, pluginId, filename):
  2637. return self.sendMsgAndSetError(["load_plugin_state", pluginId, filename])
  2638. def save_plugin_state(self, pluginId, filename):
  2639. return self.sendMsgAndSetError(["save_plugin_state", pluginId, filename])
  2640. def export_plugin_lv2(self, pluginId, lv2path):
  2641. self.fLastError = "Operation unavailable in plugin version"
  2642. return False
  2643. def get_plugin_info(self, pluginId):
  2644. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).pluginInfo
  2645. def get_audio_port_count_info(self, pluginId):
  2646. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).audioCountInfo
  2647. def get_midi_port_count_info(self, pluginId):
  2648. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).midiCountInfo
  2649. def get_parameter_count_info(self, pluginId):
  2650. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterCountInfo
  2651. def get_parameter_info(self, pluginId, parameterId):
  2652. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterInfo[parameterId]
  2653. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  2654. return PyCarlaScalePointInfo
  2655. def get_parameter_data(self, pluginId, parameterId):
  2656. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterData[parameterId]
  2657. def get_parameter_ranges(self, pluginId, parameterId):
  2658. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterRanges[parameterId]
  2659. def get_midi_program_data(self, pluginId, midiProgramId):
  2660. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).midiProgramData[midiProgramId]
  2661. def get_custom_data(self, pluginId, customDataId):
  2662. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).customData[customDataId]
  2663. def get_custom_data_value(self, pluginId, type_, key):
  2664. plugin = self.fPluginsInfo.get(pluginId, None)
  2665. if plugin is None:
  2666. return ""
  2667. for customData in plugin.customData:
  2668. if customData['type'] == type_ and customData['key'] == key:
  2669. return customData['value']
  2670. return ""
  2671. def get_chunk_data(self, pluginId):
  2672. return ""
  2673. def get_parameter_count(self, pluginId):
  2674. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterCount
  2675. def get_program_count(self, pluginId):
  2676. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).programCount
  2677. def get_midi_program_count(self, pluginId):
  2678. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).midiProgramCount
  2679. def get_custom_data_count(self, pluginId):
  2680. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).customDataCount
  2681. def get_parameter_text(self, pluginId, parameterId):
  2682. return ""
  2683. def get_program_name(self, pluginId, programId):
  2684. return self.fPluginsInfo[pluginId].programNames[programId]
  2685. def get_midi_program_name(self, pluginId, midiProgramId):
  2686. return self.fPluginsInfo[pluginId].midiProgramData[midiProgramId]['label']
  2687. def get_real_plugin_name(self, pluginId):
  2688. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).pluginRealName
  2689. def get_current_program_index(self, pluginId):
  2690. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).programCurrent
  2691. def get_current_midi_program_index(self, pluginId):
  2692. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).midiProgramCurrent
  2693. def get_default_parameter_value(self, pluginId, parameterId):
  2694. return self.fPluginsInfo[pluginId].parameterRanges[parameterId]['def']
  2695. def get_current_parameter_value(self, pluginId, parameterId):
  2696. return self.fPluginsInfo[pluginId].parameterValues[parameterId]
  2697. def get_internal_parameter_value(self, pluginId, parameterId):
  2698. if parameterId == PARAMETER_NULL or parameterId <= PARAMETER_MAX:
  2699. return 0.0
  2700. if parameterId < 0:
  2701. return self.fPluginsInfo[pluginId].internalValues[abs(parameterId)-2]
  2702. return self.fPluginsInfo[pluginId].parameterValues[parameterId]
  2703. def get_input_peak_value(self, pluginId, isLeft):
  2704. return self.fPluginsInfo[pluginId].peaks[0 if isLeft else 1]
  2705. def get_output_peak_value(self, pluginId, isLeft):
  2706. return self.fPluginsInfo[pluginId].peaks[2 if isLeft else 3]
  2707. def render_inline_display(self, pluginId, width, height):
  2708. return None
  2709. def set_option(self, pluginId, option, yesNo):
  2710. self.sendMsg(["set_option", pluginId, option, yesNo])
  2711. def set_active(self, pluginId, onOff):
  2712. self.sendMsg(["set_active", pluginId, onOff])
  2713. self.fPluginsInfo[pluginId].internalValues[0] = 1.0 if onOff else 0.0
  2714. def set_drywet(self, pluginId, value):
  2715. self.sendMsg(["set_drywet", pluginId, value])
  2716. self.fPluginsInfo[pluginId].internalValues[1] = value
  2717. def set_volume(self, pluginId, value):
  2718. self.sendMsg(["set_volume", pluginId, value])
  2719. self.fPluginsInfo[pluginId].internalValues[2] = value
  2720. def set_balance_left(self, pluginId, value):
  2721. self.sendMsg(["set_balance_left", pluginId, value])
  2722. self.fPluginsInfo[pluginId].internalValues[3] = value
  2723. def set_balance_right(self, pluginId, value):
  2724. self.sendMsg(["set_balance_right", pluginId, value])
  2725. self.fPluginsInfo[pluginId].internalValues[4] = value
  2726. def set_panning(self, pluginId, value):
  2727. self.sendMsg(["set_panning", pluginId, value])
  2728. self.fPluginsInfo[pluginId].internalValues[5] = value
  2729. def set_ctrl_channel(self, pluginId, channel):
  2730. self.sendMsg(["set_ctrl_channel", pluginId, channel])
  2731. self.fPluginsInfo[pluginId].internalValues[6] = float(channel)
  2732. def set_parameter_value(self, pluginId, parameterId, value):
  2733. self.sendMsg(["set_parameter_value", pluginId, parameterId, value])
  2734. self.fPluginsInfo[pluginId].parameterValues[parameterId] = value
  2735. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  2736. self.sendMsg(["set_parameter_midi_channel", pluginId, parameterId, channel])
  2737. self.fPluginsInfo[pluginId].parameterData[parameterId]['midiChannel'] = channel
  2738. def set_parameter_mapped_control_index(self, pluginId, parameterId, index):
  2739. self.sendMsg(["set_parameter_mapped_control_index", pluginId, parameterId, index])
  2740. self.fPluginsInfo[pluginId].parameterData[parameterId]['mappedControlIndex'] = index
  2741. def set_parameter_mapped_range(self, pluginId, parameterId, minimum, maximum):
  2742. self.sendMsg(["set_parameter_mapped_range", pluginId, parameterId, minimum, maximum])
  2743. self.fPluginsInfo[pluginId].parameterData[parameterId]['mappedMinimum'] = minimum
  2744. self.fPluginsInfo[pluginId].parameterData[parameterId]['mappedMaximum'] = maximum
  2745. def set_parameter_touch(self, pluginId, parameterId, touch):
  2746. self.sendMsg(["set_parameter_touch", pluginId, parameterId, touch])
  2747. def set_program(self, pluginId, programId):
  2748. self.sendMsg(["set_program", pluginId, programId])
  2749. self.fPluginsInfo[pluginId].programCurrent = programId
  2750. def set_midi_program(self, pluginId, midiProgramId):
  2751. self.sendMsg(["set_midi_program", pluginId, midiProgramId])
  2752. self.fPluginsInfo[pluginId].midiProgramCurrent = midiProgramId
  2753. def set_custom_data(self, pluginId, type_, key, value):
  2754. self.sendMsg(["set_custom_data", pluginId, type_, key, value])
  2755. for cdata in self.fPluginsInfo[pluginId].customData:
  2756. if cdata['type'] != type_:
  2757. continue
  2758. if cdata['key'] != key:
  2759. continue
  2760. cdata['value'] = value
  2761. break
  2762. def set_chunk_data(self, pluginId, chunkData):
  2763. self.sendMsg(["set_chunk_data", pluginId, chunkData])
  2764. def prepare_for_save(self, pluginId):
  2765. self.sendMsg(["prepare_for_save", pluginId])
  2766. def reset_parameters(self, pluginId):
  2767. self.sendMsg(["reset_parameters", pluginId])
  2768. def randomize_parameters(self, pluginId):
  2769. self.sendMsg(["randomize_parameters", pluginId])
  2770. def send_midi_note(self, pluginId, channel, note, velocity):
  2771. self.sendMsg(["send_midi_note", pluginId, channel, note, velocity])
  2772. def show_custom_ui(self, pluginId, yesNo):
  2773. self.sendMsg(["show_custom_ui", pluginId, yesNo])
  2774. def get_buffer_size(self):
  2775. return self.fBufferSize
  2776. def get_sample_rate(self):
  2777. return self.fSampleRate
  2778. def get_last_error(self):
  2779. return self.fLastError
  2780. def get_host_osc_url_tcp(self):
  2781. return self.fOscTCP
  2782. def get_host_osc_url_udp(self):
  2783. return self.fOscUDP
  2784. # --------------------------------------------------------------------------------------------------------
  2785. def _set_runtime_info(self, load, xruns):
  2786. self.fRuntimeEngineInfo = {
  2787. "load": load,
  2788. "xruns": xruns
  2789. }
  2790. def _set_transport(self, playing, frame, bar, beat, tick, bpm):
  2791. self.fTransportInfo = {
  2792. "playing": playing,
  2793. "frame": frame,
  2794. "bar": bar,
  2795. "beat": beat,
  2796. "tick": tick,
  2797. "bpm": bpm
  2798. }
  2799. def _add(self, pluginId):
  2800. self.fPluginsInfo[pluginId] = PluginStoreInfo()
  2801. def _reset(self, maxPluginId):
  2802. self.fPluginsInfo = {}
  2803. for i in range(maxPluginId):
  2804. self.fPluginsInfo[i] = PluginStoreInfo()
  2805. def _allocateAsNeeded(self, pluginId):
  2806. if pluginId < len(self.fPluginsInfo):
  2807. return
  2808. for pid in range(len(self.fPluginsInfo), pluginId+1):
  2809. self.fPluginsInfo[pid] = PluginStoreInfo()
  2810. def _set_pluginInfo(self, pluginId, info):
  2811. plugin = self.fPluginsInfo.get(pluginId, None)
  2812. if plugin is None:
  2813. print("_set_pluginInfo failed for", pluginId)
  2814. return
  2815. plugin.pluginInfo = info
  2816. def _set_pluginInfoUpdate(self, pluginId, info):
  2817. plugin = self.fPluginsInfo.get(pluginId, None)
  2818. if plugin is None:
  2819. print("_set_pluginInfoUpdate failed for", pluginId)
  2820. return
  2821. plugin.pluginInfo.update(info)
  2822. def _set_pluginName(self, pluginId, name):
  2823. plugin = self.fPluginsInfo.get(pluginId, None)
  2824. if plugin is None:
  2825. print("_set_pluginName failed for", pluginId)
  2826. return
  2827. plugin.pluginInfo['name'] = name
  2828. def _set_pluginRealName(self, pluginId, realName):
  2829. plugin = self.fPluginsInfo.get(pluginId, None)
  2830. if plugin is None:
  2831. print("_set_pluginRealName failed for", pluginId)
  2832. return
  2833. plugin.pluginRealName = realName
  2834. def _set_internalValue(self, pluginId, paramIndex, value):
  2835. pluginInfo = self.fPluginsInfo.get(pluginId, None)
  2836. if pluginInfo is None:
  2837. print("_set_internalValue failed for", pluginId)
  2838. return
  2839. if PARAMETER_NULL > paramIndex > PARAMETER_MAX:
  2840. pluginInfo.internalValues[abs(paramIndex)-2] = float(value)
  2841. else:
  2842. print("_set_internalValue failed for", pluginId, "with param", paramIndex)
  2843. def _set_audioCountInfo(self, pluginId, info):
  2844. plugin = self.fPluginsInfo.get(pluginId, None)
  2845. if plugin is None:
  2846. print("_set_audioCountInfo failed for", pluginId)
  2847. return
  2848. plugin.audioCountInfo = info
  2849. def _set_midiCountInfo(self, pluginId, info):
  2850. plugin = self.fPluginsInfo.get(pluginId, None)
  2851. if plugin is None:
  2852. print("_set_midiCountInfo failed for", pluginId)
  2853. return
  2854. plugin.midiCountInfo = info
  2855. def _set_parameterCountInfo(self, pluginId, count, info):
  2856. plugin = self.fPluginsInfo.get(pluginId, None)
  2857. if plugin is None:
  2858. print("_set_parameterCountInfo failed for", pluginId)
  2859. return
  2860. plugin.parameterCount = count
  2861. plugin.parameterCountInfo = info
  2862. # clear
  2863. plugin.parameterInfo = []
  2864. plugin.parameterData = []
  2865. plugin.parameterRanges = []
  2866. plugin.parameterValues = []
  2867. # add placeholders
  2868. for _ in range(count):
  2869. plugin.parameterInfo.append(PyCarlaParameterInfo.copy())
  2870. plugin.parameterData.append(PyParameterData.copy())
  2871. plugin.parameterRanges.append(PyParameterRanges.copy())
  2872. plugin.parameterValues.append(0.0)
  2873. def _set_programCount(self, pluginId, count):
  2874. plugin = self.fPluginsInfo.get(pluginId, None)
  2875. if plugin is None:
  2876. print("_set_internalValue failed for", pluginId)
  2877. return
  2878. plugin.programCount = count
  2879. plugin.programNames = ["" for _ in range(count)]
  2880. def _set_midiProgramCount(self, pluginId, count):
  2881. plugin = self.fPluginsInfo.get(pluginId, None)
  2882. if plugin is None:
  2883. print("_set_internalValue failed for", pluginId)
  2884. return
  2885. plugin.midiProgramCount = count
  2886. plugin.midiProgramData = [PyMidiProgramData.copy() for _ in range(count)]
  2887. def _set_customDataCount(self, pluginId, count):
  2888. plugin = self.fPluginsInfo.get(pluginId, None)
  2889. if plugin is None:
  2890. print("_set_internalValue failed for", pluginId)
  2891. return
  2892. plugin.customDataCount = count
  2893. plugin.customData = [PyCustomData.copy() for _ in range(count)]
  2894. def _set_parameterInfo(self, pluginId, paramIndex, info):
  2895. plugin = self.fPluginsInfo.get(pluginId, None)
  2896. if plugin is None:
  2897. print("_set_parameterInfo failed for", pluginId)
  2898. return
  2899. if paramIndex < plugin.parameterCount:
  2900. plugin.parameterInfo[paramIndex] = info
  2901. else:
  2902. print("_set_parameterInfo failed for", pluginId, "and index", paramIndex)
  2903. def _set_parameterData(self, pluginId, paramIndex, data):
  2904. plugin = self.fPluginsInfo.get(pluginId, None)
  2905. if plugin is None:
  2906. print("_set_parameterData failed for", pluginId)
  2907. return
  2908. if paramIndex < plugin.parameterCount:
  2909. plugin.parameterData[paramIndex] = data
  2910. else:
  2911. print("_set_parameterData failed for", pluginId, "and index", paramIndex)
  2912. def _set_parameterRanges(self, pluginId, paramIndex, ranges):
  2913. plugin = self.fPluginsInfo.get(pluginId, None)
  2914. if plugin is None:
  2915. print("_set_parameterRanges failed for", pluginId)
  2916. return
  2917. if paramIndex < plugin.parameterCount:
  2918. plugin.parameterRanges[paramIndex] = ranges
  2919. else:
  2920. print("_set_parameterRanges failed for", pluginId, "and index", paramIndex)
  2921. def _set_parameterRangesUpdate(self, pluginId, paramIndex, ranges):
  2922. plugin = self.fPluginsInfo.get(pluginId, None)
  2923. if plugin is None:
  2924. print("_set_parameterRangesUpdate failed for", pluginId)
  2925. return
  2926. if paramIndex < plugin.parameterCount:
  2927. plugin.parameterRanges[paramIndex].update(ranges)
  2928. else:
  2929. print("_set_parameterRangesUpdate failed for", pluginId, "and index", paramIndex)
  2930. def _set_parameterValue(self, pluginId, paramIndex, value):
  2931. plugin = self.fPluginsInfo.get(pluginId, None)
  2932. if plugin is None:
  2933. print("_set_parameterValue failed for", pluginId)
  2934. return
  2935. if paramIndex < plugin.parameterCount:
  2936. plugin.parameterValues[paramIndex] = value
  2937. else:
  2938. print("_set_parameterValue failed for", pluginId, "and index", paramIndex)
  2939. def _set_parameterDefault(self, pluginId, paramIndex, value):
  2940. plugin = self.fPluginsInfo.get(pluginId, None)
  2941. if plugin is None:
  2942. print("_set_parameterDefault failed for", pluginId)
  2943. return
  2944. if paramIndex < plugin.parameterCount:
  2945. plugin.parameterRanges[paramIndex]['def'] = value
  2946. else:
  2947. print("_set_parameterDefault failed for", pluginId, "and index", paramIndex)
  2948. def _set_parameterMappedControlIndex(self, pluginId, paramIndex, index):
  2949. plugin = self.fPluginsInfo.get(pluginId, None)
  2950. if plugin is None:
  2951. print("_set_parameterMappedControlIndex failed for", pluginId)
  2952. return
  2953. if paramIndex < plugin.parameterCount:
  2954. plugin.parameterData[paramIndex]['mappedControlIndex'] = index
  2955. else:
  2956. print("_set_parameterMappedControlIndex failed for", pluginId, "and index", paramIndex)
  2957. def _set_parameterMappedRange(self, pluginId, paramIndex, minimum, maximum):
  2958. plugin = self.fPluginsInfo.get(pluginId, None)
  2959. if plugin is None:
  2960. print("_set_parameterMappedRange failed for", pluginId)
  2961. return
  2962. if paramIndex < plugin.parameterCount:
  2963. plugin.parameterData[paramIndex]['mappedMinimum'] = minimum
  2964. plugin.parameterData[paramIndex]['mappedMaximum'] = maximum
  2965. else:
  2966. print("_set_parameterMappedRange failed for", pluginId, "and index", paramIndex)
  2967. def _set_parameterMidiChannel(self, pluginId, paramIndex, channel):
  2968. plugin = self.fPluginsInfo.get(pluginId, None)
  2969. if plugin is None:
  2970. print("_set_parameterMidiChannel failed for", pluginId)
  2971. return
  2972. if paramIndex < plugin.parameterCount:
  2973. plugin.parameterData[paramIndex]['midiChannel'] = channel
  2974. else:
  2975. print("_set_parameterMidiChannel failed for", pluginId, "and index", paramIndex)
  2976. def _set_currentProgram(self, pluginId, pIndex):
  2977. plugin = self.fPluginsInfo.get(pluginId, None)
  2978. if plugin is None:
  2979. print("_set_currentProgram failed for", pluginId)
  2980. return
  2981. plugin.programCurrent = pIndex
  2982. def _set_currentMidiProgram(self, pluginId, mpIndex):
  2983. plugin = self.fPluginsInfo.get(pluginId, None)
  2984. if plugin is None:
  2985. print("_set_currentMidiProgram failed for", pluginId)
  2986. return
  2987. plugin.midiProgramCurrent = mpIndex
  2988. def _set_programName(self, pluginId, pIndex, name):
  2989. plugin = self.fPluginsInfo.get(pluginId, None)
  2990. if plugin is None:
  2991. print("_set_programName failed for", pluginId)
  2992. return
  2993. if pIndex < plugin.programCount:
  2994. plugin.programNames[pIndex] = name
  2995. else:
  2996. print("_set_programName failed for", pluginId, "and index", pIndex)
  2997. def _set_midiProgramData(self, pluginId, mpIndex, data):
  2998. plugin = self.fPluginsInfo.get(pluginId, None)
  2999. if plugin is None:
  3000. print("_set_midiProgramData failed for", pluginId)
  3001. return
  3002. if mpIndex < plugin.midiProgramCount:
  3003. plugin.midiProgramData[mpIndex] = data
  3004. else:
  3005. print("_set_midiProgramData failed for", pluginId, "and index", mpIndex)
  3006. def _set_customData(self, pluginId, cdIndex, data):
  3007. plugin = self.fPluginsInfo.get(pluginId, None)
  3008. if plugin is None:
  3009. print("_set_customData failed for", pluginId)
  3010. return
  3011. if cdIndex < plugin.customDataCount:
  3012. plugin.customData[cdIndex] = data
  3013. else:
  3014. print("_set_customData failed for", pluginId, "and index", cdIndex)
  3015. def _set_peaks(self, pluginId, in1, in2, out1, out2):
  3016. pluginInfo = self.fPluginsInfo.get(pluginId, None)
  3017. if pluginInfo is not None:
  3018. pluginInfo.peaks = [in1, in2, out1, out2]
  3019. def _removePlugin(self, pluginId):
  3020. pluginCountM1 = len(self.fPluginsInfo)-1
  3021. if pluginId >= pluginCountM1:
  3022. self.fPluginsInfo[pluginId] = PluginStoreInfo()
  3023. return
  3024. # push all plugins 1 slot back starting from the plugin that got removed
  3025. for i in range(pluginId, pluginCountM1):
  3026. self.fPluginsInfo[i] = self.fPluginsInfo[i+1]
  3027. self.fPluginsInfo[pluginCountM1] = PluginStoreInfo()
  3028. def _switchPlugins(self, pluginIdA, pluginIdB):
  3029. tmp = self.fPluginsInfo[pluginIdA]
  3030. self.fPluginsInfo[pluginIdA] = self.fPluginsInfo[pluginIdB]
  3031. self.fPluginsInfo[pluginIdB] = tmp
  3032. def _setViaCallback(self, action, pluginId, value1, value2, value3, valuef, valueStr):
  3033. if action == ENGINE_CALLBACK_ENGINE_STARTED:
  3034. self.fBufferSize = value3
  3035. self.fSampleRate = valuef
  3036. if value1 == ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  3037. maxPluginId = MAX_RACK_PLUGINS
  3038. elif value1 == ENGINE_PROCESS_MODE_PATCHBAY:
  3039. maxPluginId = MAX_PATCHBAY_PLUGINS
  3040. else:
  3041. maxPluginId = MAX_DEFAULT_PLUGINS
  3042. self._reset(maxPluginId)
  3043. elif action == ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  3044. self.fBufferSize = value1
  3045. elif action == ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  3046. self.fSampleRate = valuef
  3047. elif action == ENGINE_CALLBACK_PLUGIN_REMOVED:
  3048. self._removePlugin(pluginId)
  3049. elif action == ENGINE_CALLBACK_PLUGIN_RENAMED:
  3050. self._set_pluginName(pluginId, valueStr)
  3051. elif action == ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  3052. if value1 < 0:
  3053. self._set_internalValue(pluginId, value1, valuef)
  3054. else:
  3055. self._set_parameterValue(pluginId, value1, valuef)
  3056. elif action == ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  3057. self._set_parameterDefault(pluginId, value1, valuef)
  3058. elif action == ENGINE_CALLBACK_PARAMETER_MAPPED_CONTROL_INDEX_CHANGED:
  3059. self._set_parameterMappedControlIndex(pluginId, value1, value2)
  3060. elif action == ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED:
  3061. minimum, maximum = (float(i) for i in valueStr.split(":"))
  3062. self._set_parameterMappedRange(pluginId, value1, minimum, maximum)
  3063. elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  3064. self._set_parameterMidiChannel(pluginId, value1, value2)
  3065. elif action == ENGINE_CALLBACK_PROGRAM_CHANGED:
  3066. self._set_currentProgram(pluginId, value1)
  3067. elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  3068. self._set_currentMidiProgram(pluginId, value1)
  3069. # ---------------------------------------------------------------------------------------------------------------------