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.

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