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.

3975 lines
130KB

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