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.

3962 lines
129KB

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