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.

3934 lines
128KB

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