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.

4019 lines
132KB

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