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.

4002 lines
131KB

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