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.

3980 lines
130KB

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