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.

4032 lines
132KB

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