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.

3464 lines
108KB

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