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.

4029 lines
132KB

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