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.

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