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.

4048 lines
133KB

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