Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4007 lines
131KB

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