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.

4021 lines
132KB

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