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.

3517 lines
111KB

  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 pluginId How many plugins are known to be running
  501. # @a value1 Process mode
  502. # @a value2 Transport mode
  503. # @a value3 Buffer size
  504. # @a valuef Sample rate
  505. # @a valuestr Engine driver
  506. # @see EngineProcessMode
  507. # @see EngineTransportMode
  508. ENGINE_CALLBACK_ENGINE_STARTED = 29
  509. # Engine stopped.
  510. ENGINE_CALLBACK_ENGINE_STOPPED = 30
  511. # Engine process mode has changed.
  512. # @a value1 New process mode
  513. # @see EngineProcessMode
  514. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31
  515. # Engine transport mode has changed.
  516. # @a value1 New transport mode
  517. # @a valueStr New transport features enabled
  518. # @see EngineTransportMode
  519. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32
  520. # Engine buffer-size changed.
  521. # @a value1 New buffer size
  522. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33
  523. # Engine sample-rate changed.
  524. # @a valuef New sample rate
  525. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34
  526. # A cancelable action has been started or stopped.
  527. # @a pluginId Plugin Id the action relates to, -1 for none
  528. # @a value1 1 for action started, 0 for stopped
  529. # @a valueStr Action name
  530. ENGINE_CALLBACK_CANCELABLE_ACTION = 35
  531. # Project has finished loading.
  532. ENGINE_CALLBACK_PROJECT_LOAD_FINISHED = 36
  533. # NSM callback.
  534. # Frontend must call carla_nsm_ready() with opcode as parameter as a response
  535. # @a value1 NSM opcode
  536. # @a value2 Integer value
  537. # @a valueStr String value
  538. # @see NsmCallbackOpcode
  539. ENGINE_CALLBACK_NSM = 37
  540. # Idle frontend.
  541. # This is used by the engine during long operations that might block the frontend,
  542. # giving it the possibility to idle while the operation is still in place.
  543. ENGINE_CALLBACK_IDLE = 38
  544. # Show a message as information.
  545. # @a valueStr The message
  546. ENGINE_CALLBACK_INFO = 39
  547. # Show a message as an error.
  548. # @a valueStr The message
  549. ENGINE_CALLBACK_ERROR = 40
  550. # The engine has crashed or malfunctioned and will no longer work.
  551. ENGINE_CALLBACK_QUIT = 41
  552. # ------------------------------------------------------------------------------------------------------------
  553. # NSM Callback Opcode
  554. # NSM callback opcodes.
  555. # @see ENGINE_CALLBACK_NSM
  556. # NSM is available and initialized.
  557. NSM_CALLBACK_INIT = 0
  558. # Error from NSM side.
  559. # @a valueInt Error code
  560. # @a valueStr Error string
  561. NSM_CALLBACK_ERROR = 1
  562. # Announce message.
  563. # @a valueInt SM Flags (WIP, to be defined)
  564. # @a valueStr SM Name
  565. NSM_CALLBACK_ANNOUNCE = 2
  566. # Open message.
  567. # @a valueStr Project filename
  568. NSM_CALLBACK_OPEN = 3
  569. # Save message.
  570. NSM_CALLBACK_SAVE = 4
  571. # Session-is-loaded message.
  572. NSM_CALLBACK_SESSION_IS_LOADED = 5
  573. # Show-optional-gui message.
  574. NSM_CALLBACK_SHOW_OPTIONAL_GUI = 6
  575. # Hide-optional-gui message.
  576. NSM_CALLBACK_HIDE_OPTIONAL_GUI = 7
  577. # ------------------------------------------------------------------------------------------------------------
  578. # Engine Option
  579. # Engine options.
  580. # @see carla_set_engine_option()
  581. # Debug.
  582. # This option is undefined and used only for testing purposes.
  583. ENGINE_OPTION_DEBUG = 0
  584. # Set the engine processing mode.
  585. # Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_CONTINUOUS_RACK for all other OSes.
  586. # @see EngineProcessMode
  587. ENGINE_OPTION_PROCESS_MODE = 1
  588. # Set the engine transport mode.
  589. # Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  590. # @see EngineTransportMode
  591. ENGINE_OPTION_TRANSPORT_MODE = 2
  592. # Force mono plugins as stereo, by running 2 instances at the same time.
  593. # Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  594. # @note Not supported by all plugins
  595. # @see PLUGIN_OPTION_FORCE_STEREO
  596. ENGINE_OPTION_FORCE_STEREO = 3
  597. # Use plugin bridges whenever possible.
  598. # Default is no, EXPERIMENTAL.
  599. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4
  600. # Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  601. # Default is yes.
  602. ENGINE_OPTION_PREFER_UI_BRIDGES = 5
  603. # Make custom plugin UIs always-on-top.
  604. # Default is yes.
  605. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6
  606. # Maximum number of parameters allowed.
  607. # Default is MAX_DEFAULT_PARAMETERS.
  608. ENGINE_OPTION_MAX_PARAMETERS = 7
  609. # Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  610. # Default is 4000 (4 seconds).
  611. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8
  612. # Audio buffer size.
  613. # Default is 512.
  614. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 9
  615. # Audio sample rate.
  616. # Default is 44100.
  617. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 10
  618. # Wherever to use 3 audio periods instead of the default 2.
  619. # Default is false.
  620. ENGINE_OPTION_AUDIO_TRIPLE_BUFFER = 11
  621. # Audio device (within a driver).
  622. # Default unset.
  623. ENGINE_OPTION_AUDIO_DEVICE = 12
  624. # Wherever to enable OSC support in the engine.
  625. ENGINE_OPTION_OSC_ENABLED = 13
  626. # The network TCP port to use for OSC.
  627. # A value of 0 means use a random port.
  628. # A value of < 0 means to not enable the TCP port for OSC.
  629. # @note Valid ports begin at 1024 and end at 32767 (inclusive)
  630. ENGINE_OPTION_OSC_PORT_TCP = 14
  631. # The network UDP port to use for OSC.
  632. # A value of 0 means use a random port.
  633. # A value of < 0 means to not enable the UDP port for OSC.
  634. # @note Disabling this option prevents DSSI UIs from working!
  635. # @note Valid ports begin at 1024 and end at 32767 (inclusive)
  636. ENGINE_OPTION_OSC_PORT_UDP = 15
  637. # Set path used for a specific plugin type.
  638. # Uses value as the plugin format, valueStr as actual path.
  639. # @see PluginType
  640. ENGINE_OPTION_PLUGIN_PATH = 16
  641. # Set path to the binary files.
  642. # Default unset.
  643. # @note Must be set for plugin and UI bridges to work
  644. ENGINE_OPTION_PATH_BINARIES = 17
  645. # Set path to the resource files.
  646. # Default unset.
  647. # @note Must be set for some internal plugins to work
  648. ENGINE_OPTION_PATH_RESOURCES = 18
  649. # Prevent bad plugin and UI behaviour.
  650. # @note: Linux only
  651. ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 19
  652. # Set frontend winId, used to define as parent window for plugin UIs.
  653. ENGINE_OPTION_FRONTEND_WIN_ID = 20
  654. # Set path to wine executable.
  655. ENGINE_OPTION_WINE_EXECUTABLE = 21
  656. # Enable automatic wineprefix detection.
  657. ENGINE_OPTION_WINE_AUTO_PREFIX = 22
  658. # Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set.
  659. ENGINE_OPTION_WINE_FALLBACK_PREFIX = 23
  660. # Enable realtime priority for Wine application and server threads.
  661. ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 24
  662. # Base realtime priority for Wine threads.
  663. ENGINE_OPTION_WINE_BASE_RT_PRIO = 25
  664. # Wine server realtime priority.
  665. ENGINE_OPTION_WINE_SERVER_RT_PRIO = 26
  666. # Capture console output into debug callbacks
  667. ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 27
  668. # ------------------------------------------------------------------------------------------------------------
  669. # Engine Process Mode
  670. # Engine process mode.
  671. # @see ENGINE_OPTION_PROCESS_MODE
  672. # Single client mode.
  673. # Inputs and outputs are added dynamically as needed by plugins.
  674. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0
  675. # Multiple client mode.
  676. # It has 1 master client + 1 client per plugin.
  677. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1
  678. # Single client, 'rack' mode.
  679. # Processes plugins in order of Id, with forced stereo always on.
  680. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2
  681. # Single client, 'patchbay' mode.
  682. ENGINE_PROCESS_MODE_PATCHBAY = 3
  683. # Special mode, used in plugin-bridges only.
  684. ENGINE_PROCESS_MODE_BRIDGE = 4
  685. # ------------------------------------------------------------------------------------------------------------
  686. # Engine Transport Mode
  687. # Engine transport mode.
  688. # @see ENGINE_OPTION_TRANSPORT_MODE
  689. # No transport.
  690. ENGINE_TRANSPORT_MODE_DISABLED = 0
  691. # Internal transport mode.
  692. ENGINE_TRANSPORT_MODE_INTERNAL = 1
  693. # Transport from JACK.
  694. # Only available if driver name is "JACK".
  695. ENGINE_TRANSPORT_MODE_JACK = 2
  696. # Transport from host, used when Carla is a plugin.
  697. ENGINE_TRANSPORT_MODE_PLUGIN = 3
  698. # Special mode, used in plugin-bridges only.
  699. ENGINE_TRANSPORT_MODE_BRIDGE = 4
  700. # ------------------------------------------------------------------------------------------------------------
  701. # File Callback Opcode
  702. # File callback opcodes.
  703. # Front-ends must always block-wait for user input.
  704. # @see FileCallbackFunc and carla_set_file_callback()
  705. # Debug.
  706. # This opcode is undefined and used only for testing purposes.
  707. FILE_CALLBACK_DEBUG = 0
  708. # Open file or folder.
  709. FILE_CALLBACK_OPEN = 1
  710. # Save file or folder.
  711. FILE_CALLBACK_SAVE = 2
  712. # ------------------------------------------------------------------------------------------------------------
  713. # Patchbay Icon
  714. # The icon of a patchbay client/group.
  715. # Generic application icon.
  716. # Used for all non-plugin clients that don't have a specific icon.
  717. PATCHBAY_ICON_APPLICATION = 0
  718. # Plugin icon.
  719. # Used for all plugin clients that don't have a specific icon.
  720. PATCHBAY_ICON_PLUGIN = 1
  721. # Hardware icon.
  722. # Used for hardware (audio or MIDI) clients.
  723. PATCHBAY_ICON_HARDWARE = 2
  724. # Carla icon.
  725. # Used for the main app.
  726. PATCHBAY_ICON_CARLA = 3
  727. # DISTRHO icon.
  728. # Used for DISTRHO based plugins.
  729. PATCHBAY_ICON_DISTRHO = 4
  730. # File icon.
  731. # Used for file type plugins (like SF2 and SFZ).
  732. PATCHBAY_ICON_FILE = 5
  733. # ------------------------------------------------------------------------------------------------------------
  734. # Carla Backend API (C stuff)
  735. # Engine callback function.
  736. # Front-ends must never block indefinitely during a callback.
  737. # @see EngineCallbackOpcode and carla_set_engine_callback()
  738. EngineCallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_int, c_float, c_char_p)
  739. # File callback function.
  740. # @see FileCallbackOpcode
  741. FileCallbackFunc = CFUNCTYPE(c_char_p, c_void_p, c_enum, c_bool, c_char_p, c_char_p)
  742. # Parameter data.
  743. class ParameterData(Structure):
  744. _fields_ = [
  745. # This parameter type.
  746. ("type", c_enum),
  747. # This parameter hints.
  748. # @see ParameterHints
  749. ("hints", c_uint),
  750. # Index as seen by Carla.
  751. ("index", c_int32),
  752. # Real index as seen by plugins.
  753. ("rindex", c_int32),
  754. # Currently mapped MIDI CC.
  755. # A value lower than 0 means invalid or unused.
  756. # Maximum allowed value is 119 (0x77).
  757. ("midiCC", c_int16),
  758. # Currently mapped MIDI channel.
  759. # Counts from 0 to 15.
  760. ("midiChannel", c_uint8)
  761. ]
  762. # Parameter ranges.
  763. class ParameterRanges(Structure):
  764. _fields_ = [
  765. # Default value.
  766. ("def", c_float),
  767. # Minimum value.
  768. ("min", c_float),
  769. # Maximum value.
  770. ("max", c_float),
  771. # Regular, single step value.
  772. ("step", c_float),
  773. # Small step value.
  774. ("stepSmall", c_float),
  775. # Large step value.
  776. ("stepLarge", c_float)
  777. ]
  778. # MIDI Program data.
  779. class MidiProgramData(Structure):
  780. _fields_ = [
  781. # MIDI bank.
  782. ("bank", c_uint32),
  783. # MIDI program.
  784. ("program", c_uint32),
  785. # MIDI program name.
  786. ("name", c_char_p)
  787. ]
  788. # Custom data, used for saving key:value 'dictionaries'.
  789. class CustomData(Structure):
  790. _fields_ = [
  791. # Value type, in URI form.
  792. # @see CustomDataTypes
  793. ("type", c_char_p),
  794. # Key.
  795. # @see CustomDataKeys
  796. ("key", c_char_p),
  797. # Value.
  798. ("value", c_char_p)
  799. ]
  800. # Engine driver device information.
  801. class EngineDriverDeviceInfo(Structure):
  802. _fields_ = [
  803. # This driver device hints.
  804. # @see EngineDriverHints
  805. ("hints", c_uint),
  806. # Available buffer sizes.
  807. # Terminated with 0.
  808. ("bufferSizes", POINTER(c_uint32)),
  809. # Available sample rates.
  810. # Terminated with 0.0.
  811. ("sampleRates", POINTER(c_double))
  812. ]
  813. # ------------------------------------------------------------------------------------------------------------
  814. # Carla Backend API (Python compatible stuff)
  815. # @see ParameterData
  816. PyParameterData = {
  817. 'type': PARAMETER_UNKNOWN,
  818. 'hints': 0x0,
  819. 'index': PARAMETER_NULL,
  820. 'rindex': -1,
  821. 'midiCC': -1,
  822. 'midiChannel': 0
  823. }
  824. # @see ParameterRanges
  825. PyParameterRanges = {
  826. 'def': 0.0,
  827. 'min': 0.0,
  828. 'max': 1.0,
  829. 'step': 0.01,
  830. 'stepSmall': 0.0001,
  831. 'stepLarge': 0.1
  832. }
  833. # @see MidiProgramData
  834. PyMidiProgramData = {
  835. 'bank': 0,
  836. 'program': 0,
  837. 'name': None
  838. }
  839. # @see CustomData
  840. PyCustomData = {
  841. 'type': None,
  842. 'key': None,
  843. 'value': None
  844. }
  845. # @see EngineDriverDeviceInfo
  846. PyEngineDriverDeviceInfo = {
  847. 'hints': 0x0,
  848. 'bufferSizes': [],
  849. 'sampleRates': []
  850. }
  851. # ------------------------------------------------------------------------------------------------------------
  852. # Carla Host API (C stuff)
  853. # Information about a loaded plugin.
  854. # @see carla_get_plugin_info()
  855. class CarlaPluginInfo(Structure):
  856. _fields_ = [
  857. # Plugin type.
  858. ("type", c_enum),
  859. # Plugin category.
  860. ("category", c_enum),
  861. # Plugin hints.
  862. # @see PluginHints
  863. ("hints", c_uint),
  864. # Plugin options available for the user to change.
  865. # @see PluginOptions
  866. ("optionsAvailable", c_uint),
  867. # Plugin options currently enabled.
  868. # Some options are enabled but not available, which means they will always be on.
  869. # @see PluginOptions
  870. ("optionsEnabled", c_uint),
  871. # Plugin filename.
  872. # This can be the plugin binary or resource file.
  873. ("filename", c_char_p),
  874. # Plugin name.
  875. # This name is unique within a Carla instance.
  876. # @see carla_get_real_plugin_name()
  877. ("name", c_char_p),
  878. # Plugin label or URI.
  879. ("label", c_char_p),
  880. # Plugin author/maker.
  881. ("maker", c_char_p),
  882. # Plugin copyright/license.
  883. ("copyright", c_char_p),
  884. # Icon name for this plugin, in lowercase.
  885. # Default is "plugin".
  886. ("iconName", c_char_p),
  887. # Plugin unique Id.
  888. # This Id is dependant on the plugin type and may sometimes be 0.
  889. ("uniqueId", c_int64)
  890. ]
  891. # Port count information, used for Audio and MIDI ports and parameters.
  892. # @see carla_get_audio_port_count_info()
  893. # @see carla_get_midi_port_count_info()
  894. # @see carla_get_parameter_count_info()
  895. class CarlaPortCountInfo(Structure):
  896. _fields_ = [
  897. # Number of inputs.
  898. ("ins", c_uint32),
  899. # Number of outputs.
  900. ("outs", c_uint32)
  901. ]
  902. # Parameter information.
  903. # @see carla_get_parameter_info()
  904. class CarlaParameterInfo(Structure):
  905. _fields_ = [
  906. # Parameter name.
  907. ("name", c_char_p),
  908. # Parameter symbol.
  909. ("symbol", c_char_p),
  910. # Parameter unit.
  911. ("unit", c_char_p),
  912. # Number of scale points.
  913. # @see CarlaScalePointInfo
  914. ("scalePointCount", c_uint32)
  915. ]
  916. # Parameter scale point information.
  917. # @see carla_get_parameter_scalepoint_info()
  918. class CarlaScalePointInfo(Structure):
  919. _fields_ = [
  920. # Scale point value.
  921. ("value", c_float),
  922. # Scale point label.
  923. ("label", c_char_p)
  924. ]
  925. # Transport information.
  926. # @see carla_get_transport_info()
  927. class CarlaTransportInfo(Structure):
  928. _fields_ = [
  929. # Wherever transport is playing.
  930. ("playing", c_bool),
  931. # Current transport frame.
  932. ("frame", c_uint64),
  933. # Bar
  934. ("bar", c_int32),
  935. # Beat
  936. ("beat", c_int32),
  937. # Tick
  938. ("tick", c_int32),
  939. # Beats per minute.
  940. ("bpm", c_double)
  941. ]
  942. # Runtime engine information.
  943. class CarlaRuntimeEngineInfo(Structure):
  944. _fields_ = [
  945. # DSP load.
  946. ("load", c_float),
  947. # Number of xruns.
  948. ("xruns", c_uint32)
  949. ]
  950. # Image data for LV2 inline display API.
  951. # raw image pixmap format is ARGB32,
  952. class CarlaInlineDisplayImageSurface(Structure):
  953. _fields_ = [
  954. ("data", POINTER(c_ubyte)),
  955. ("width", c_int),
  956. ("height", c_int),
  957. ("stride", c_int)
  958. ]
  959. # ------------------------------------------------------------------------------------------------------------
  960. # Carla Host API (Python compatible stuff)
  961. # @see CarlaPluginInfo
  962. PyCarlaPluginInfo = {
  963. 'type': PLUGIN_NONE,
  964. 'category': PLUGIN_CATEGORY_NONE,
  965. 'hints': 0x0,
  966. 'optionsAvailable': 0x0,
  967. 'optionsEnabled': 0x0,
  968. 'filename': "",
  969. 'name': "",
  970. 'label': "",
  971. 'maker': "",
  972. 'copyright': "",
  973. 'iconName': "",
  974. 'uniqueId': 0
  975. }
  976. # @see CarlaPortCountInfo
  977. PyCarlaPortCountInfo = {
  978. 'ins': 0,
  979. 'outs': 0
  980. }
  981. # @see CarlaParameterInfo
  982. PyCarlaParameterInfo = {
  983. 'name': "",
  984. 'symbol': "",
  985. 'unit': "",
  986. 'scalePointCount': 0,
  987. }
  988. # @see CarlaScalePointInfo
  989. PyCarlaScalePointInfo = {
  990. 'value': 0.0,
  991. 'label': ""
  992. }
  993. # @see CarlaTransportInfo
  994. PyCarlaTransportInfo = {
  995. "playing": False,
  996. "frame": 0,
  997. "bar": 0,
  998. "beat": 0,
  999. "tick": 0,
  1000. "bpm": 0.0
  1001. }
  1002. # @see CarlaRuntimeEngineInfo
  1003. PyCarlaRuntimeEngineInfo = {
  1004. "load": 0.0,
  1005. "xruns": 0
  1006. }
  1007. # ------------------------------------------------------------------------------------------------------------
  1008. # Set BINARY_NATIVE
  1009. if WINDOWS:
  1010. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  1011. else:
  1012. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  1013. # ------------------------------------------------------------------------------------------------------------
  1014. # Carla Host object (Meta)
  1015. class CarlaHostMeta(object):
  1016. #class CarlaHostMeta(object, metaclass=ABCMeta):
  1017. def __init__(self):
  1018. object.__init__(self)
  1019. # info about this host object
  1020. self.isControl = False
  1021. self.isPlugin = False
  1022. self.isRemote = False
  1023. self.nsmOK = False
  1024. # settings
  1025. self.processMode = ENGINE_PROCESS_MODE_PATCHBAY
  1026. self.transportMode = ENGINE_TRANSPORT_MODE_INTERNAL
  1027. self.transportExtra = ""
  1028. self.nextProcessMode = self.processMode
  1029. self.processModeForced = False
  1030. self.audioDriverForced = None
  1031. # settings
  1032. self.experimental = False
  1033. self.exportLV2 = False
  1034. self.forceStereo = False
  1035. self.manageUIs = False
  1036. self.maxParameters = 0
  1037. self.preferPluginBridges = False
  1038. self.preferUIBridges = False
  1039. self.preventBadBehaviour = False
  1040. self.showLogs = False
  1041. self.showPluginBridges = False
  1042. self.showWineBridges = False
  1043. self.uiBridgesTimeout = 0
  1044. self.uisAlwaysOnTop = False
  1045. # settings
  1046. self.pathBinaries = ""
  1047. self.pathResources = ""
  1048. # Get how many engine drivers are available.
  1049. @abstractmethod
  1050. def get_engine_driver_count(self):
  1051. raise NotImplementedError
  1052. # Get an engine driver name.
  1053. # @param index Driver index
  1054. @abstractmethod
  1055. def get_engine_driver_name(self, index):
  1056. raise NotImplementedError
  1057. # Get the device names of an engine driver.
  1058. # @param index Driver index
  1059. @abstractmethod
  1060. def get_engine_driver_device_names(self, index):
  1061. raise NotImplementedError
  1062. # Get information about a device driver.
  1063. # @param index Driver index
  1064. # @param name Device name
  1065. @abstractmethod
  1066. def get_engine_driver_device_info(self, index, name):
  1067. raise NotImplementedError
  1068. # Initialize the engine.
  1069. # Make sure to call carla_engine_idle() at regular intervals afterwards.
  1070. # @param driverName Driver to use
  1071. # @param clientName Engine master client name
  1072. @abstractmethod
  1073. def engine_init(self, driverName, clientName):
  1074. raise NotImplementedError
  1075. # Close the engine.
  1076. # This function always closes the engine even if it returns false.
  1077. # In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
  1078. @abstractmethod
  1079. def engine_close(self):
  1080. raise NotImplementedError
  1081. # Idle the engine.
  1082. # Do not call this if the engine is not running.
  1083. @abstractmethod
  1084. def engine_idle(self):
  1085. raise NotImplementedError
  1086. # Check if the engine is running.
  1087. @abstractmethod
  1088. def is_engine_running(self):
  1089. raise NotImplementedError
  1090. # Get information about the currently running engine.
  1091. @abstractmethod
  1092. def get_runtime_engine_info(self):
  1093. raise NotImplementedError
  1094. # Clear the xrun count on the engine, so that the next time carla_get_runtime_engine_info() is called, it returns 0.
  1095. @abstractmethod
  1096. def clear_engine_xruns(self):
  1097. raise NotImplementedError
  1098. # Tell the engine to stop the current cancelable action.
  1099. # @see ENGINE_CALLBACK_CANCELABLE_ACTION
  1100. @abstractmethod
  1101. def cancel_engine_action(self):
  1102. raise NotImplementedError
  1103. # Tell the engine it's about to close.
  1104. # This is used to prevent the engine thread(s) from reactivating.
  1105. @abstractmethod
  1106. def set_engine_about_to_close(self):
  1107. raise NotImplementedError
  1108. # Set the engine callback function.
  1109. # @param func Callback function
  1110. @abstractmethod
  1111. def set_engine_callback(self, func):
  1112. raise NotImplementedError
  1113. # Set an engine option.
  1114. # @param option Option
  1115. # @param value Value as number
  1116. # @param valueStr Value as string
  1117. @abstractmethod
  1118. def set_engine_option(self, option, value, valueStr):
  1119. raise NotImplementedError
  1120. # Set the file callback function.
  1121. # @param func Callback function
  1122. # @param ptr Callback pointer
  1123. @abstractmethod
  1124. def set_file_callback(self, func):
  1125. raise NotImplementedError
  1126. # Load a file of any type.
  1127. # This will try to load a generic file as a plugin,
  1128. # either by direct handling (SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
  1129. # @see carla_get_supported_file_extensions()
  1130. @abstractmethod
  1131. def load_file(self, filename):
  1132. raise NotImplementedError
  1133. # Load a Carla project file.
  1134. # @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
  1135. @abstractmethod
  1136. def load_project(self, filename):
  1137. raise NotImplementedError
  1138. # Save current project to a file.
  1139. @abstractmethod
  1140. def save_project(self, filename):
  1141. raise NotImplementedError
  1142. # Clear the currently set project filename.
  1143. @abstractmethod
  1144. def clear_project_filename(self):
  1145. raise NotImplementedError
  1146. # Connect two patchbay ports.
  1147. # @param groupIdA Output group
  1148. # @param portIdA Output port
  1149. # @param groupIdB Input group
  1150. # @param portIdB Input port
  1151. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
  1152. @abstractmethod
  1153. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  1154. raise NotImplementedError
  1155. # Disconnect two patchbay ports.
  1156. # @param connectionId Connection Id
  1157. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
  1158. @abstractmethod
  1159. def patchbay_disconnect(self, external, connectionId):
  1160. raise NotImplementedError
  1161. # Force the engine to resend all patchbay clients, ports and connections again.
  1162. # @param external Wherever to show external/hardware ports instead of internal ones.
  1163. # Only valid in patchbay engine mode, other modes will ignore this.
  1164. @abstractmethod
  1165. def patchbay_refresh(self, external):
  1166. raise NotImplementedError
  1167. # Start playback of the engine transport.
  1168. @abstractmethod
  1169. def transport_play(self):
  1170. raise NotImplementedError
  1171. # Pause the engine transport.
  1172. @abstractmethod
  1173. def transport_pause(self):
  1174. raise NotImplementedError
  1175. # Pause the engine transport.
  1176. @abstractmethod
  1177. def transport_bpm(self, bpm):
  1178. raise NotImplementedError
  1179. # Relocate the engine transport to a specific frame.
  1180. @abstractmethod
  1181. def transport_relocate(self, frame):
  1182. raise NotImplementedError
  1183. # Get the current transport frame.
  1184. @abstractmethod
  1185. def get_current_transport_frame(self):
  1186. raise NotImplementedError
  1187. # Get the engine transport information.
  1188. @abstractmethod
  1189. def get_transport_info(self):
  1190. raise NotImplementedError
  1191. # Current number of plugins loaded.
  1192. @abstractmethod
  1193. def get_current_plugin_count(self):
  1194. raise NotImplementedError
  1195. # Maximum number of loadable plugins allowed.
  1196. # Returns 0 if engine is not started.
  1197. @abstractmethod
  1198. def get_max_plugin_number(self):
  1199. raise NotImplementedError
  1200. # Add a new plugin.
  1201. # If you don't know the binary type use the BINARY_NATIVE macro.
  1202. # @param btype Binary type
  1203. # @param ptype Plugin type
  1204. # @param filename Filename, if applicable
  1205. # @param name Name of the plugin, can be NULL
  1206. # @param label Plugin label, if applicable
  1207. # @param uniqueId Plugin unique Id, if applicable
  1208. # @param extraPtr Extra pointer, defined per plugin type
  1209. # @param options Initial plugin options
  1210. @abstractmethod
  1211. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  1212. raise NotImplementedError
  1213. # Remove a plugin.
  1214. # @param pluginId Plugin to remove.
  1215. @abstractmethod
  1216. def remove_plugin(self, pluginId):
  1217. raise NotImplementedError
  1218. # Remove all plugins.
  1219. @abstractmethod
  1220. def remove_all_plugins(self):
  1221. raise NotImplementedError
  1222. # Rename a plugin.
  1223. # Returns the new name, or NULL if the operation failed.
  1224. # @param pluginId Plugin to rename
  1225. # @param newName New plugin name
  1226. @abstractmethod
  1227. def rename_plugin(self, pluginId, newName):
  1228. raise NotImplementedError
  1229. # Clone a plugin.
  1230. # @param pluginId Plugin to clone
  1231. @abstractmethod
  1232. def clone_plugin(self, pluginId):
  1233. raise NotImplementedError
  1234. # Prepare replace of a plugin.
  1235. # The next call to carla_add_plugin() will use this id, replacing the current plugin.
  1236. # @param pluginId Plugin to replace
  1237. # @note This function requires carla_add_plugin() to be called afterwards *as soon as possible*.
  1238. @abstractmethod
  1239. def replace_plugin(self, pluginId):
  1240. raise NotImplementedError
  1241. # Switch two plugins positions.
  1242. # @param pluginIdA Plugin A
  1243. # @param pluginIdB Plugin B
  1244. @abstractmethod
  1245. def switch_plugins(self, pluginIdA, pluginIdB):
  1246. raise NotImplementedError
  1247. # Load a plugin state.
  1248. # @param pluginId Plugin
  1249. # @param filename Path to plugin state
  1250. # @see carla_save_plugin_state()
  1251. @abstractmethod
  1252. def load_plugin_state(self, pluginId, filename):
  1253. raise NotImplementedError
  1254. # Save a plugin state.
  1255. # @param pluginId Plugin
  1256. # @param filename Path to plugin state
  1257. # @see carla_load_plugin_state()
  1258. @abstractmethod
  1259. def save_plugin_state(self, pluginId, filename):
  1260. raise NotImplementedError
  1261. # Export plugin as LV2.
  1262. # @param pluginId Plugin
  1263. # @param lv2path Path to lv2 plugin folder
  1264. def export_plugin_lv2(self, pluginId, lv2path):
  1265. raise NotImplementedError
  1266. # Get information from a plugin.
  1267. # @param pluginId Plugin
  1268. @abstractmethod
  1269. def get_plugin_info(self, pluginId):
  1270. raise NotImplementedError
  1271. # Get audio port count information from a plugin.
  1272. # @param pluginId Plugin
  1273. @abstractmethod
  1274. def get_audio_port_count_info(self, pluginId):
  1275. raise NotImplementedError
  1276. # Get MIDI port count information from a plugin.
  1277. # @param pluginId Plugin
  1278. @abstractmethod
  1279. def get_midi_port_count_info(self, pluginId):
  1280. raise NotImplementedError
  1281. # Get parameter count information from a plugin.
  1282. # @param pluginId Plugin
  1283. @abstractmethod
  1284. def get_parameter_count_info(self, pluginId):
  1285. raise NotImplementedError
  1286. # Get parameter information from a plugin.
  1287. # @param pluginId Plugin
  1288. # @param parameterId Parameter index
  1289. # @see carla_get_parameter_count()
  1290. @abstractmethod
  1291. def get_parameter_info(self, pluginId, parameterId):
  1292. raise NotImplementedError
  1293. # Get parameter scale point information from a plugin.
  1294. # @param pluginId Plugin
  1295. # @param parameterId Parameter index
  1296. # @param scalePointId Parameter scale-point index
  1297. # @see CarlaParameterInfo::scalePointCount
  1298. @abstractmethod
  1299. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  1300. raise NotImplementedError
  1301. # Get a plugin's parameter data.
  1302. # @param pluginId Plugin
  1303. # @param parameterId Parameter index
  1304. # @see carla_get_parameter_count()
  1305. @abstractmethod
  1306. def get_parameter_data(self, pluginId, parameterId):
  1307. raise NotImplementedError
  1308. # Get a plugin's parameter ranges.
  1309. # @param pluginId Plugin
  1310. # @param parameterId Parameter index
  1311. # @see carla_get_parameter_count()
  1312. @abstractmethod
  1313. def get_parameter_ranges(self, pluginId, parameterId):
  1314. raise NotImplementedError
  1315. # Get a plugin's MIDI program data.
  1316. # @param pluginId Plugin
  1317. # @param midiProgramId MIDI Program index
  1318. # @see carla_get_midi_program_count()
  1319. @abstractmethod
  1320. def get_midi_program_data(self, pluginId, midiProgramId):
  1321. raise NotImplementedError
  1322. # Get a plugin's custom data, using index.
  1323. # @param pluginId Plugin
  1324. # @param customDataId Custom data index
  1325. # @see carla_get_custom_data_count()
  1326. @abstractmethod
  1327. def get_custom_data(self, pluginId, customDataId):
  1328. raise NotImplementedError
  1329. # Get a plugin's custom data value, using type and key.
  1330. # @param pluginId Plugin
  1331. # @param type Custom data type
  1332. # @param key Custom data key
  1333. # @see carla_get_custom_data_count()
  1334. @abstractmethod
  1335. def get_custom_data_value(self, pluginId, type_, key):
  1336. raise NotImplementedError
  1337. # Get a plugin's chunk data.
  1338. # @param pluginId Plugin
  1339. # @see PLUGIN_OPTION_USE_CHUNKS
  1340. @abstractmethod
  1341. def get_chunk_data(self, pluginId):
  1342. raise NotImplementedError
  1343. # Get how many parameters a plugin has.
  1344. # @param pluginId Plugin
  1345. @abstractmethod
  1346. def get_parameter_count(self, pluginId):
  1347. raise NotImplementedError
  1348. # Get how many programs a plugin has.
  1349. # @param pluginId Plugin
  1350. # @see carla_get_program_name()
  1351. @abstractmethod
  1352. def get_program_count(self, pluginId):
  1353. raise NotImplementedError
  1354. # Get how many MIDI programs a plugin has.
  1355. # @param pluginId Plugin
  1356. # @see carla_get_midi_program_name() and carla_get_midi_program_data()
  1357. @abstractmethod
  1358. def get_midi_program_count(self, pluginId):
  1359. raise NotImplementedError
  1360. # Get how many custom data sets a plugin has.
  1361. # @param pluginId Plugin
  1362. # @see carla_get_custom_data()
  1363. @abstractmethod
  1364. def get_custom_data_count(self, pluginId):
  1365. raise NotImplementedError
  1366. # Get a plugin's parameter text (custom display of internal values).
  1367. # @param pluginId Plugin
  1368. # @param parameterId Parameter index
  1369. # @see PARAMETER_USES_CUSTOM_TEXT
  1370. @abstractmethod
  1371. def get_parameter_text(self, pluginId, parameterId):
  1372. raise NotImplementedError
  1373. # Get a plugin's program name.
  1374. # @param pluginId Plugin
  1375. # @param programId Program index
  1376. # @see carla_get_program_count()
  1377. @abstractmethod
  1378. def get_program_name(self, pluginId, programId):
  1379. raise NotImplementedError
  1380. # Get a plugin's MIDI program name.
  1381. # @param pluginId Plugin
  1382. # @param midiProgramId MIDI Program index
  1383. # @see carla_get_midi_program_count()
  1384. @abstractmethod
  1385. def get_midi_program_name(self, pluginId, midiProgramId):
  1386. raise NotImplementedError
  1387. # Get a plugin's real name.
  1388. # This is the name the plugin uses to identify itself; may not be unique.
  1389. # @param pluginId Plugin
  1390. @abstractmethod
  1391. def get_real_plugin_name(self, pluginId):
  1392. raise NotImplementedError
  1393. # Get a plugin's program index.
  1394. # @param pluginId Plugin
  1395. @abstractmethod
  1396. def get_current_program_index(self, pluginId):
  1397. raise NotImplementedError
  1398. # Get a plugin's midi program index.
  1399. # @param pluginId Plugin
  1400. @abstractmethod
  1401. def get_current_midi_program_index(self, pluginId):
  1402. raise NotImplementedError
  1403. # Get a plugin's default parameter value.
  1404. # @param pluginId Plugin
  1405. # @param parameterId Parameter index
  1406. @abstractmethod
  1407. def get_default_parameter_value(self, pluginId, parameterId):
  1408. raise NotImplementedError
  1409. # Get a plugin's current parameter value.
  1410. # @param pluginId Plugin
  1411. # @param parameterId Parameter index
  1412. @abstractmethod
  1413. def get_current_parameter_value(self, pluginId, parameterId):
  1414. raise NotImplementedError
  1415. # Get a plugin's internal parameter value.
  1416. # @param pluginId Plugin
  1417. # @param parameterId Parameter index, maybe be negative
  1418. # @see InternalParameterIndex
  1419. @abstractmethod
  1420. def get_internal_parameter_value(self, pluginId, parameterId):
  1421. raise NotImplementedError
  1422. # Get a plugin's input peak value.
  1423. # @param pluginId Plugin
  1424. # @param isLeft Wherever to get the left/mono value, otherwise right.
  1425. @abstractmethod
  1426. def get_input_peak_value(self, pluginId, isLeft):
  1427. raise NotImplementedError
  1428. # Get a plugin's output peak value.
  1429. # @param pluginId Plugin
  1430. # @param isLeft Wherever to get the left/mono value, otherwise right.
  1431. @abstractmethod
  1432. def get_output_peak_value(self, pluginId, isLeft):
  1433. raise NotImplementedError
  1434. # Render a plugin's inline display.
  1435. # @param pluginId Plugin
  1436. @abstractmethod
  1437. def render_inline_display(self, pluginId, width, height):
  1438. raise NotImplementedError
  1439. # Enable a plugin's option.
  1440. # @param pluginId Plugin
  1441. # @param option An option from PluginOptions
  1442. # @param yesNo New enabled state
  1443. @abstractmethod
  1444. def set_option(self, pluginId, option, yesNo):
  1445. raise NotImplementedError
  1446. # Enable or disable a plugin.
  1447. # @param pluginId Plugin
  1448. # @param onOff New active state
  1449. @abstractmethod
  1450. def set_active(self, pluginId, onOff):
  1451. raise NotImplementedError
  1452. # Change a plugin's internal dry/wet.
  1453. # @param pluginId Plugin
  1454. # @param value New dry/wet value
  1455. @abstractmethod
  1456. def set_drywet(self, pluginId, value):
  1457. raise NotImplementedError
  1458. # Change a plugin's internal volume.
  1459. # @param pluginId Plugin
  1460. # @param value New volume
  1461. @abstractmethod
  1462. def set_volume(self, pluginId, value):
  1463. raise NotImplementedError
  1464. # Change a plugin's internal stereo balance, left channel.
  1465. # @param pluginId Plugin
  1466. # @param value New value
  1467. @abstractmethod
  1468. def set_balance_left(self, pluginId, value):
  1469. raise NotImplementedError
  1470. # Change a plugin's internal stereo balance, right channel.
  1471. # @param pluginId Plugin
  1472. # @param value New value
  1473. @abstractmethod
  1474. def set_balance_right(self, pluginId, value):
  1475. raise NotImplementedError
  1476. # Change a plugin's internal mono panning value.
  1477. # @param pluginId Plugin
  1478. # @param value New value
  1479. @abstractmethod
  1480. def set_panning(self, pluginId, value):
  1481. raise NotImplementedError
  1482. # Change a plugin's internal control channel.
  1483. # @param pluginId Plugin
  1484. # @param channel New channel
  1485. @abstractmethod
  1486. def set_ctrl_channel(self, pluginId, channel):
  1487. raise NotImplementedError
  1488. # Change a plugin's parameter value.
  1489. # @param pluginId Plugin
  1490. # @param parameterId Parameter index
  1491. # @param value New value
  1492. @abstractmethod
  1493. def set_parameter_value(self, pluginId, parameterId, value):
  1494. raise NotImplementedError
  1495. # Change a plugin's parameter MIDI cc.
  1496. # @param pluginId Plugin
  1497. # @param parameterId Parameter index
  1498. # @param cc New MIDI cc
  1499. @abstractmethod
  1500. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  1501. raise NotImplementedError
  1502. # Change a plugin's parameter MIDI channel.
  1503. # @param pluginId Plugin
  1504. # @param parameterId Parameter index
  1505. # @param channel New MIDI channel
  1506. @abstractmethod
  1507. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  1508. raise NotImplementedError
  1509. # Change a plugin's current program.
  1510. # @param pluginId Plugin
  1511. # @param programId New program
  1512. @abstractmethod
  1513. def set_program(self, pluginId, programId):
  1514. raise NotImplementedError
  1515. # Change a plugin's current MIDI program.
  1516. # @param pluginId Plugin
  1517. # @param midiProgramId New value
  1518. @abstractmethod
  1519. def set_midi_program(self, pluginId, midiProgramId):
  1520. raise NotImplementedError
  1521. # Set a plugin's custom data set.
  1522. # @param pluginId Plugin
  1523. # @param type Type
  1524. # @param key Key
  1525. # @param value New value
  1526. # @see CustomDataTypes and CustomDataKeys
  1527. @abstractmethod
  1528. def set_custom_data(self, pluginId, type_, key, value):
  1529. raise NotImplementedError
  1530. # Set a plugin's chunk data.
  1531. # @param pluginId Plugin
  1532. # @param chunkData New chunk data
  1533. # @see PLUGIN_OPTION_USE_CHUNKS and carla_get_chunk_data()
  1534. @abstractmethod
  1535. def set_chunk_data(self, pluginId, chunkData):
  1536. raise NotImplementedError
  1537. # Tell a plugin to prepare for save.
  1538. # This should be called before saving custom data sets.
  1539. # @param pluginId Plugin
  1540. @abstractmethod
  1541. def prepare_for_save(self, pluginId):
  1542. raise NotImplementedError
  1543. # Reset all plugin's parameters.
  1544. # @param pluginId Plugin
  1545. @abstractmethod
  1546. def reset_parameters(self, pluginId):
  1547. raise NotImplementedError
  1548. # Randomize all plugin's parameters.
  1549. # @param pluginId Plugin
  1550. @abstractmethod
  1551. def randomize_parameters(self, pluginId):
  1552. raise NotImplementedError
  1553. # Send a single note of a plugin.
  1554. # If velocity is 0, note-off is sent; note-on otherwise.
  1555. # @param pluginId Plugin
  1556. # @param channel Note channel
  1557. # @param note Note pitch
  1558. # @param velocity Note velocity
  1559. @abstractmethod
  1560. def send_midi_note(self, pluginId, channel, note, velocity):
  1561. raise NotImplementedError
  1562. # Tell a plugin to show its own custom UI.
  1563. # @param pluginId Plugin
  1564. # @param yesNo New UI state, visible or not
  1565. # @see PLUGIN_HAS_CUSTOM_UI
  1566. @abstractmethod
  1567. def show_custom_ui(self, pluginId, yesNo):
  1568. raise NotImplementedError
  1569. # Get the current engine buffer size.
  1570. @abstractmethod
  1571. def get_buffer_size(self):
  1572. raise NotImplementedError
  1573. # Get the current engine sample rate.
  1574. @abstractmethod
  1575. def get_sample_rate(self):
  1576. raise NotImplementedError
  1577. # Get the last error.
  1578. @abstractmethod
  1579. def get_last_error(self):
  1580. raise NotImplementedError
  1581. # Get the current engine OSC URL (TCP).
  1582. @abstractmethod
  1583. def get_host_osc_url_tcp(self):
  1584. raise NotImplementedError
  1585. # Get the current engine OSC URL (UDP).
  1586. @abstractmethod
  1587. def get_host_osc_url_udp(self):
  1588. raise NotImplementedError
  1589. # Initialize NSM (that is, announce ourselves to it).
  1590. # Must be called as early as possible in the program's lifecycle.
  1591. # Returns true if NSM is available and initialized correctly.
  1592. @abstractmethod
  1593. def nsm_init(self, pid, executableName):
  1594. raise NotImplementedError
  1595. # Respond to an NSM callback.
  1596. @abstractmethod
  1597. def nsm_ready(self, opcode):
  1598. raise NotImplementedError
  1599. # ------------------------------------------------------------------------------------------------------------
  1600. # Carla Host object (dummy/null, does nothing)
  1601. class CarlaHostNull(CarlaHostMeta):
  1602. def __init__(self):
  1603. CarlaHostMeta.__init__(self)
  1604. self.fEngineCallback = None
  1605. self.fFileCallback = None
  1606. self.fEngineRunning = False
  1607. def get_engine_driver_count(self):
  1608. return 0
  1609. def get_engine_driver_name(self, index):
  1610. return ""
  1611. def get_engine_driver_device_names(self, index):
  1612. return []
  1613. def get_engine_driver_device_info(self, index, name):
  1614. return PyEngineDriverDeviceInfo
  1615. def engine_init(self, driverName, clientName):
  1616. self.fEngineRunning = True
  1617. if self.fEngineCallback is not None:
  1618. self.fEngineCallback(None,
  1619. ENGINE_CALLBACK_ENGINE_STARTED,
  1620. 0,
  1621. self.processMode,
  1622. self.transportMode,
  1623. 0, 0.0,
  1624. driverName)
  1625. return True
  1626. def engine_close(self):
  1627. self.fEngineRunning = False
  1628. if self.fEngineCallback is not None:
  1629. self.fEngineCallback(None, ENGINE_CALLBACK_ENGINE_STOPPED, 0, 0, 0, 0, 0.0, "")
  1630. return True
  1631. def engine_idle(self):
  1632. return
  1633. def is_engine_running(self):
  1634. return self.fEngineRunning
  1635. def get_runtime_engine_info(self):
  1636. return PyCarlaRuntimeEngineInfo
  1637. def clear_engine_xruns(self):
  1638. return
  1639. def cancel_engine_action(self):
  1640. return
  1641. def set_engine_about_to_close(self):
  1642. return True
  1643. def set_engine_callback(self, func):
  1644. self.fEngineCallback = func
  1645. def set_engine_option(self, option, value, valueStr):
  1646. return
  1647. def set_file_callback(self, func):
  1648. self.fFileCallback = func
  1649. def load_file(self, filename):
  1650. return False
  1651. def load_project(self, filename):
  1652. return False
  1653. def save_project(self, filename):
  1654. return False
  1655. def clear_project_filename(self):
  1656. return
  1657. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  1658. return False
  1659. def patchbay_disconnect(self, external, connectionId):
  1660. return False
  1661. def patchbay_refresh(self, external):
  1662. return False
  1663. def transport_play(self):
  1664. return
  1665. def transport_pause(self):
  1666. return
  1667. def transport_bpm(self, bpm):
  1668. return
  1669. def transport_relocate(self, frame):
  1670. return
  1671. def get_current_transport_frame(self):
  1672. return 0
  1673. def get_transport_info(self):
  1674. return PyCarlaTransportInfo
  1675. def get_current_plugin_count(self):
  1676. return 0
  1677. def get_max_plugin_number(self):
  1678. return 0
  1679. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  1680. return False
  1681. def remove_plugin(self, pluginId):
  1682. return False
  1683. def remove_all_plugins(self):
  1684. return False
  1685. def rename_plugin(self, pluginId, newName):
  1686. return ""
  1687. def clone_plugin(self, pluginId):
  1688. return False
  1689. def replace_plugin(self, pluginId):
  1690. return False
  1691. def switch_plugins(self, pluginIdA, pluginIdB):
  1692. return False
  1693. def load_plugin_state(self, pluginId, filename):
  1694. return False
  1695. def save_plugin_state(self, pluginId, filename):
  1696. return False
  1697. def export_plugin_lv2(self, pluginId, lv2path):
  1698. return False
  1699. def get_plugin_info(self, pluginId):
  1700. return PyCarlaPluginInfo
  1701. def get_audio_port_count_info(self, pluginId):
  1702. return PyCarlaPortCountInfo
  1703. def get_midi_port_count_info(self, pluginId):
  1704. return PyCarlaPortCountInfo
  1705. def get_parameter_count_info(self, pluginId):
  1706. return PyCarlaPortCountInfo
  1707. def get_parameter_info(self, pluginId, parameterId):
  1708. return PyCarlaParameterInfo
  1709. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  1710. return PyCarlaScalePointInfo
  1711. def get_parameter_data(self, pluginId, parameterId):
  1712. return PyParameterData
  1713. def get_parameter_ranges(self, pluginId, parameterId):
  1714. return PyParameterRanges
  1715. def get_midi_program_data(self, pluginId, midiProgramId):
  1716. return PyMidiProgramData
  1717. def get_custom_data(self, pluginId, customDataId):
  1718. return PyCustomData
  1719. def get_custom_data_value(self, pluginId, type_, key):
  1720. return ""
  1721. def get_chunk_data(self, pluginId):
  1722. return ""
  1723. def get_parameter_count(self, pluginId):
  1724. return 0
  1725. def get_program_count(self, pluginId):
  1726. return 0
  1727. def get_midi_program_count(self, pluginId):
  1728. return 0
  1729. def get_custom_data_count(self, pluginId):
  1730. return 0
  1731. def get_parameter_text(self, pluginId, parameterId):
  1732. return ""
  1733. def get_program_name(self, pluginId, programId):
  1734. return ""
  1735. def get_midi_program_name(self, pluginId, midiProgramId):
  1736. return ""
  1737. def get_real_plugin_name(self, pluginId):
  1738. return ""
  1739. def get_current_program_index(self, pluginId):
  1740. return 0
  1741. def get_current_midi_program_index(self, pluginId):
  1742. return 0
  1743. def get_default_parameter_value(self, pluginId, parameterId):
  1744. return 0.0
  1745. def get_current_parameter_value(self, pluginId, parameterId):
  1746. return 0.0
  1747. def get_internal_parameter_value(self, pluginId, parameterId):
  1748. return 0.0
  1749. def get_input_peak_value(self, pluginId, isLeft):
  1750. return 0.0
  1751. def get_output_peak_value(self, pluginId, isLeft):
  1752. return 0.0
  1753. def render_inline_display(self, pluginId, width, height):
  1754. return None
  1755. def set_option(self, pluginId, option, yesNo):
  1756. return
  1757. def set_active(self, pluginId, onOff):
  1758. return
  1759. def set_drywet(self, pluginId, value):
  1760. return
  1761. def set_volume(self, pluginId, value):
  1762. return
  1763. def set_balance_left(self, pluginId, value):
  1764. return
  1765. def set_balance_right(self, pluginId, value):
  1766. return
  1767. def set_panning(self, pluginId, value):
  1768. return
  1769. def set_ctrl_channel(self, pluginId, channel):
  1770. return
  1771. def set_parameter_value(self, pluginId, parameterId, value):
  1772. return
  1773. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  1774. return
  1775. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  1776. return
  1777. def set_program(self, pluginId, programId):
  1778. return
  1779. def set_midi_program(self, pluginId, midiProgramId):
  1780. return
  1781. def set_custom_data(self, pluginId, type_, key, value):
  1782. return
  1783. def set_chunk_data(self, pluginId, chunkData):
  1784. return
  1785. def prepare_for_save(self, pluginId):
  1786. return
  1787. def reset_parameters(self, pluginId):
  1788. return
  1789. def randomize_parameters(self, pluginId):
  1790. return
  1791. def send_midi_note(self, pluginId, channel, note, velocity):
  1792. return
  1793. def show_custom_ui(self, pluginId, yesNo):
  1794. return
  1795. def get_buffer_size(self):
  1796. return 0
  1797. def get_sample_rate(self):
  1798. return 0.0
  1799. def get_last_error(self):
  1800. return ""
  1801. def get_host_osc_url_tcp(self):
  1802. return ""
  1803. def get_host_osc_url_udp(self):
  1804. return ""
  1805. def nsm_init(self, pid, executableName):
  1806. return False
  1807. def nsm_ready(self, opcode):
  1808. return
  1809. # ------------------------------------------------------------------------------------------------------------
  1810. # Carla Host object using a DLL
  1811. class CarlaHostDLL(CarlaHostMeta):
  1812. def __init__(self, libName, loadGlobal):
  1813. CarlaHostMeta.__init__(self)
  1814. # info about this host object
  1815. self.isPlugin = False
  1816. self.lib = CDLL(libName, RTLD_GLOBAL if loadGlobal else RTLD_LOCAL)
  1817. self.lib.carla_get_engine_driver_count.argtypes = None
  1818. self.lib.carla_get_engine_driver_count.restype = c_uint
  1819. self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
  1820. self.lib.carla_get_engine_driver_name.restype = c_char_p
  1821. self.lib.carla_get_engine_driver_device_names.argtypes = [c_uint]
  1822. self.lib.carla_get_engine_driver_device_names.restype = POINTER(c_char_p)
  1823. self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p]
  1824. self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo)
  1825. self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p]
  1826. self.lib.carla_engine_init.restype = c_bool
  1827. self.lib.carla_engine_close.argtypes = None
  1828. self.lib.carla_engine_close.restype = c_bool
  1829. self.lib.carla_engine_idle.argtypes = None
  1830. self.lib.carla_engine_idle.restype = None
  1831. self.lib.carla_is_engine_running.argtypes = None
  1832. self.lib.carla_is_engine_running.restype = c_bool
  1833. self.lib.carla_get_runtime_engine_info.argtypes = None
  1834. self.lib.carla_get_runtime_engine_info.restype = POINTER(CarlaRuntimeEngineInfo)
  1835. self.lib.carla_clear_engine_xruns.argtypes = None
  1836. self.lib.carla_clear_engine_xruns.restype = None
  1837. self.lib.carla_cancel_engine_action.argtypes = None
  1838. self.lib.carla_cancel_engine_action.restype = None
  1839. self.lib.carla_set_engine_about_to_close.argtypes = None
  1840. self.lib.carla_set_engine_about_to_close.restype = c_bool
  1841. self.lib.carla_set_engine_callback.argtypes = [EngineCallbackFunc, c_void_p]
  1842. self.lib.carla_set_engine_callback.restype = None
  1843. self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
  1844. self.lib.carla_set_engine_option.restype = None
  1845. self.lib.carla_set_file_callback.argtypes = [FileCallbackFunc, c_void_p]
  1846. self.lib.carla_set_file_callback.restype = None
  1847. self.lib.carla_load_file.argtypes = [c_char_p]
  1848. self.lib.carla_load_file.restype = c_bool
  1849. self.lib.carla_load_project.argtypes = [c_char_p]
  1850. self.lib.carla_load_project.restype = c_bool
  1851. self.lib.carla_save_project.argtypes = [c_char_p]
  1852. self.lib.carla_save_project.restype = c_bool
  1853. self.lib.carla_clear_project_filename.argtypes = None
  1854. self.lib.carla_clear_project_filename.restype = None
  1855. self.lib.carla_patchbay_connect.argtypes = [c_bool, c_uint, c_uint, c_uint, c_uint]
  1856. self.lib.carla_patchbay_connect.restype = c_bool
  1857. self.lib.carla_patchbay_disconnect.argtypes = [c_bool, c_uint]
  1858. self.lib.carla_patchbay_disconnect.restype = c_bool
  1859. self.lib.carla_patchbay_refresh.argtypes = [c_bool]
  1860. self.lib.carla_patchbay_refresh.restype = c_bool
  1861. self.lib.carla_transport_play.argtypes = None
  1862. self.lib.carla_transport_play.restype = None
  1863. self.lib.carla_transport_pause.argtypes = None
  1864. self.lib.carla_transport_pause.restype = None
  1865. self.lib.carla_transport_bpm.argtypes = [c_double]
  1866. self.lib.carla_transport_bpm.restype = None
  1867. self.lib.carla_transport_relocate.argtypes = [c_uint64]
  1868. self.lib.carla_transport_relocate.restype = None
  1869. self.lib.carla_get_current_transport_frame.argtypes = None
  1870. self.lib.carla_get_current_transport_frame.restype = c_uint64
  1871. self.lib.carla_get_transport_info.argtypes = None
  1872. self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)
  1873. self.lib.carla_get_current_plugin_count.argtypes = None
  1874. self.lib.carla_get_current_plugin_count.restype = c_uint32
  1875. self.lib.carla_get_max_plugin_number.argtypes = None
  1876. self.lib.carla_get_max_plugin_number.restype = c_uint32
  1877. 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]
  1878. self.lib.carla_add_plugin.restype = c_bool
  1879. self.lib.carla_remove_plugin.argtypes = [c_uint]
  1880. self.lib.carla_remove_plugin.restype = c_bool
  1881. self.lib.carla_remove_all_plugins.argtypes = None
  1882. self.lib.carla_remove_all_plugins.restype = c_bool
  1883. self.lib.carla_rename_plugin.argtypes = [c_uint, c_char_p]
  1884. self.lib.carla_rename_plugin.restype = c_char_p
  1885. self.lib.carla_clone_plugin.argtypes = [c_uint]
  1886. self.lib.carla_clone_plugin.restype = c_bool
  1887. self.lib.carla_replace_plugin.argtypes = [c_uint]
  1888. self.lib.carla_replace_plugin.restype = c_bool
  1889. self.lib.carla_switch_plugins.argtypes = [c_uint, c_uint]
  1890. self.lib.carla_switch_plugins.restype = c_bool
  1891. self.lib.carla_load_plugin_state.argtypes = [c_uint, c_char_p]
  1892. self.lib.carla_load_plugin_state.restype = c_bool
  1893. self.lib.carla_save_plugin_state.argtypes = [c_uint, c_char_p]
  1894. self.lib.carla_save_plugin_state.restype = c_bool
  1895. self.lib.carla_export_plugin_lv2.argtypes = [c_uint, c_char_p]
  1896. self.lib.carla_export_plugin_lv2.restype = c_bool
  1897. self.lib.carla_get_plugin_info.argtypes = [c_uint]
  1898. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  1899. self.lib.carla_get_audio_port_count_info.argtypes = [c_uint]
  1900. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1901. self.lib.carla_get_midi_port_count_info.argtypes = [c_uint]
  1902. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1903. self.lib.carla_get_parameter_count_info.argtypes = [c_uint]
  1904. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  1905. self.lib.carla_get_parameter_info.argtypes = [c_uint, c_uint32]
  1906. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  1907. self.lib.carla_get_parameter_scalepoint_info.argtypes = [c_uint, c_uint32, c_uint32]
  1908. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  1909. self.lib.carla_get_parameter_data.argtypes = [c_uint, c_uint32]
  1910. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  1911. self.lib.carla_get_parameter_ranges.argtypes = [c_uint, c_uint32]
  1912. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  1913. self.lib.carla_get_midi_program_data.argtypes = [c_uint, c_uint32]
  1914. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  1915. self.lib.carla_get_custom_data.argtypes = [c_uint, c_uint32]
  1916. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  1917. self.lib.carla_get_custom_data_value.argtypes = [c_uint, c_char_p, c_char_p]
  1918. self.lib.carla_get_custom_data_value.restype = c_char_p
  1919. self.lib.carla_get_chunk_data.argtypes = [c_uint]
  1920. self.lib.carla_get_chunk_data.restype = c_char_p
  1921. self.lib.carla_get_parameter_count.argtypes = [c_uint]
  1922. self.lib.carla_get_parameter_count.restype = c_uint32
  1923. self.lib.carla_get_program_count.argtypes = [c_uint]
  1924. self.lib.carla_get_program_count.restype = c_uint32
  1925. self.lib.carla_get_midi_program_count.argtypes = [c_uint]
  1926. self.lib.carla_get_midi_program_count.restype = c_uint32
  1927. self.lib.carla_get_custom_data_count.argtypes = [c_uint]
  1928. self.lib.carla_get_custom_data_count.restype = c_uint32
  1929. self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32]
  1930. self.lib.carla_get_parameter_text.restype = c_char_p
  1931. self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32]
  1932. self.lib.carla_get_program_name.restype = c_char_p
  1933. self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32]
  1934. self.lib.carla_get_midi_program_name.restype = c_char_p
  1935. self.lib.carla_get_real_plugin_name.argtypes = [c_uint]
  1936. self.lib.carla_get_real_plugin_name.restype = c_char_p
  1937. self.lib.carla_get_current_program_index.argtypes = [c_uint]
  1938. self.lib.carla_get_current_program_index.restype = c_int32
  1939. self.lib.carla_get_current_midi_program_index.argtypes = [c_uint]
  1940. self.lib.carla_get_current_midi_program_index.restype = c_int32
  1941. self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32]
  1942. self.lib.carla_get_default_parameter_value.restype = c_float
  1943. self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
  1944. self.lib.carla_get_current_parameter_value.restype = c_float
  1945. self.lib.carla_get_internal_parameter_value.argtypes = [c_uint, c_int32]
  1946. self.lib.carla_get_internal_parameter_value.restype = c_float
  1947. self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_bool]
  1948. self.lib.carla_get_input_peak_value.restype = c_float
  1949. self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_bool]
  1950. self.lib.carla_get_output_peak_value.restype = c_float
  1951. self.lib.carla_render_inline_display.argtypes = [c_uint, c_uint, c_uint]
  1952. self.lib.carla_render_inline_display.restype = POINTER(CarlaInlineDisplayImageSurface)
  1953. self.lib.carla_set_option.argtypes = [c_uint, c_uint, c_bool]
  1954. self.lib.carla_set_option.restype = None
  1955. self.lib.carla_set_active.argtypes = [c_uint, c_bool]
  1956. self.lib.carla_set_active.restype = None
  1957. self.lib.carla_set_drywet.argtypes = [c_uint, c_float]
  1958. self.lib.carla_set_drywet.restype = None
  1959. self.lib.carla_set_volume.argtypes = [c_uint, c_float]
  1960. self.lib.carla_set_volume.restype = None
  1961. self.lib.carla_set_balance_left.argtypes = [c_uint, c_float]
  1962. self.lib.carla_set_balance_left.restype = None
  1963. self.lib.carla_set_balance_right.argtypes = [c_uint, c_float]
  1964. self.lib.carla_set_balance_right.restype = None
  1965. self.lib.carla_set_panning.argtypes = [c_uint, c_float]
  1966. self.lib.carla_set_panning.restype = None
  1967. self.lib.carla_set_ctrl_channel.argtypes = [c_uint, c_int8]
  1968. self.lib.carla_set_ctrl_channel.restype = None
  1969. self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float]
  1970. self.lib.carla_set_parameter_value.restype = None
  1971. self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8]
  1972. self.lib.carla_set_parameter_midi_channel.restype = None
  1973. self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16]
  1974. self.lib.carla_set_parameter_midi_cc.restype = None
  1975. self.lib.carla_set_program.argtypes = [c_uint, c_uint32]
  1976. self.lib.carla_set_program.restype = None
  1977. self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32]
  1978. self.lib.carla_set_midi_program.restype = None
  1979. self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p]
  1980. self.lib.carla_set_custom_data.restype = None
  1981. self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p]
  1982. self.lib.carla_set_chunk_data.restype = None
  1983. self.lib.carla_prepare_for_save.argtypes = [c_uint]
  1984. self.lib.carla_prepare_for_save.restype = None
  1985. self.lib.carla_reset_parameters.argtypes = [c_uint]
  1986. self.lib.carla_reset_parameters.restype = None
  1987. self.lib.carla_randomize_parameters.argtypes = [c_uint]
  1988. self.lib.carla_randomize_parameters.restype = None
  1989. self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8]
  1990. self.lib.carla_send_midi_note.restype = None
  1991. self.lib.carla_show_custom_ui.argtypes = [c_uint, c_bool]
  1992. self.lib.carla_show_custom_ui.restype = None
  1993. self.lib.carla_get_buffer_size.argtypes = None
  1994. self.lib.carla_get_buffer_size.restype = c_uint32
  1995. self.lib.carla_get_sample_rate.argtypes = None
  1996. self.lib.carla_get_sample_rate.restype = c_double
  1997. self.lib.carla_get_last_error.argtypes = None
  1998. self.lib.carla_get_last_error.restype = c_char_p
  1999. self.lib.carla_get_host_osc_url_tcp.argtypes = None
  2000. self.lib.carla_get_host_osc_url_tcp.restype = c_char_p
  2001. self.lib.carla_get_host_osc_url_udp.argtypes = None
  2002. self.lib.carla_get_host_osc_url_udp.restype = c_char_p
  2003. self.lib.carla_nsm_init.argtypes = [c_int, c_char_p]
  2004. self.lib.carla_nsm_init.restype = c_bool
  2005. self.lib.carla_nsm_ready.argtypes = [c_int]
  2006. self.lib.carla_nsm_ready.restype = None
  2007. # --------------------------------------------------------------------------------------------------------
  2008. def get_engine_driver_count(self):
  2009. return int(self.lib.carla_get_engine_driver_count())
  2010. def get_engine_driver_name(self, index):
  2011. return charPtrToString(self.lib.carla_get_engine_driver_name(index))
  2012. def get_engine_driver_device_names(self, index):
  2013. return charPtrPtrToStringList(self.lib.carla_get_engine_driver_device_names(index))
  2014. def get_engine_driver_device_info(self, index, name):
  2015. return structToDict(self.lib.carla_get_engine_driver_device_info(index, name.encode("utf-8")).contents)
  2016. def engine_init(self, driverName, clientName):
  2017. return bool(self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8")))
  2018. def engine_close(self):
  2019. return bool(self.lib.carla_engine_close())
  2020. def engine_idle(self):
  2021. self.lib.carla_engine_idle()
  2022. def is_engine_running(self):
  2023. return bool(self.lib.carla_is_engine_running())
  2024. def get_runtime_engine_info(self):
  2025. return structToDict(self.lib.carla_get_runtime_engine_info().contents)
  2026. def clear_engine_xruns(self):
  2027. return self.lib.carla_clear_engine_xruns()
  2028. def cancel_engine_action(self):
  2029. return self.lib.carla_cancel_engine_action()
  2030. def set_engine_about_to_close(self):
  2031. return bool(self.lib.carla_set_engine_about_to_close())
  2032. def set_engine_callback(self, func):
  2033. self._engineCallback = EngineCallbackFunc(func)
  2034. self.lib.carla_set_engine_callback(self._engineCallback, None)
  2035. def set_engine_option(self, option, value, valueStr):
  2036. self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))
  2037. def set_file_callback(self, func):
  2038. self._fileCallback = FileCallbackFunc(func)
  2039. self.lib.carla_set_file_callback(self._fileCallback, None)
  2040. def load_file(self, filename):
  2041. return bool(self.lib.carla_load_file(filename.encode("utf-8")))
  2042. def load_project(self, filename):
  2043. return bool(self.lib.carla_load_project(filename.encode("utf-8")))
  2044. def save_project(self, filename):
  2045. return bool(self.lib.carla_save_project(filename.encode("utf-8")))
  2046. def clear_project_filename(self):
  2047. self.lib.carla_clear_project_filename()
  2048. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  2049. return bool(self.lib.carla_patchbay_connect(external, groupIdA, portIdA, groupIdB, portIdB))
  2050. def patchbay_disconnect(self, external, connectionId):
  2051. return bool(self.lib.carla_patchbay_disconnect(external, connectionId))
  2052. def patchbay_refresh(self, external):
  2053. return bool(self.lib.carla_patchbay_refresh(external))
  2054. def transport_play(self):
  2055. self.lib.carla_transport_play()
  2056. def transport_pause(self):
  2057. self.lib.carla_transport_pause()
  2058. def transport_bpm(self, bpm):
  2059. self.lib.carla_transport_bpm(bpm)
  2060. def transport_relocate(self, frame):
  2061. self.lib.carla_transport_relocate(frame)
  2062. def get_current_transport_frame(self):
  2063. return int(self.lib.carla_get_current_transport_frame())
  2064. def get_transport_info(self):
  2065. return structToDict(self.lib.carla_get_transport_info().contents)
  2066. def get_current_plugin_count(self):
  2067. return int(self.lib.carla_get_current_plugin_count())
  2068. def get_max_plugin_number(self):
  2069. return int(self.lib.carla_get_max_plugin_number())
  2070. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  2071. cfilename = filename.encode("utf-8") if filename else None
  2072. cname = name.encode("utf-8") if name else None
  2073. clabel = label.encode("utf-8") if label else None
  2074. return bool(self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, uniqueId, cast(extraPtr, c_void_p), options))
  2075. def remove_plugin(self, pluginId):
  2076. return bool(self.lib.carla_remove_plugin(pluginId))
  2077. def remove_all_plugins(self):
  2078. return bool(self.lib.carla_remove_all_plugins())
  2079. def rename_plugin(self, pluginId, newName):
  2080. return charPtrToString(self.lib.carla_rename_plugin(pluginId, newName.encode("utf-8")))
  2081. def clone_plugin(self, pluginId):
  2082. return bool(self.lib.carla_clone_plugin(pluginId))
  2083. def replace_plugin(self, pluginId):
  2084. return bool(self.lib.carla_replace_plugin(pluginId))
  2085. def switch_plugins(self, pluginIdA, pluginIdB):
  2086. return bool(self.lib.carla_switch_plugins(pluginIdA, pluginIdB))
  2087. def load_plugin_state(self, pluginId, filename):
  2088. return bool(self.lib.carla_load_plugin_state(pluginId, filename.encode("utf-8")))
  2089. def save_plugin_state(self, pluginId, filename):
  2090. return bool(self.lib.carla_save_plugin_state(pluginId, filename.encode("utf-8")))
  2091. def export_plugin_lv2(self, pluginId, lv2path):
  2092. return bool(self.lib.carla_export_plugin_lv2(pluginId, lv2path.encode("utf-8")))
  2093. def get_plugin_info(self, pluginId):
  2094. return structToDict(self.lib.carla_get_plugin_info(pluginId).contents)
  2095. def get_audio_port_count_info(self, pluginId):
  2096. return structToDict(self.lib.carla_get_audio_port_count_info(pluginId).contents)
  2097. def get_midi_port_count_info(self, pluginId):
  2098. return structToDict(self.lib.carla_get_midi_port_count_info(pluginId).contents)
  2099. def get_parameter_count_info(self, pluginId):
  2100. return structToDict(self.lib.carla_get_parameter_count_info(pluginId).contents)
  2101. def get_parameter_info(self, pluginId, parameterId):
  2102. return structToDict(self.lib.carla_get_parameter_info(pluginId, parameterId).contents)
  2103. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  2104. return structToDict(self.lib.carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId).contents)
  2105. def get_parameter_data(self, pluginId, parameterId):
  2106. return structToDict(self.lib.carla_get_parameter_data(pluginId, parameterId).contents)
  2107. def get_parameter_ranges(self, pluginId, parameterId):
  2108. return structToDict(self.lib.carla_get_parameter_ranges(pluginId, parameterId).contents)
  2109. def get_midi_program_data(self, pluginId, midiProgramId):
  2110. return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents)
  2111. def get_custom_data(self, pluginId, customDataId):
  2112. return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents)
  2113. def get_custom_data_value(self, pluginId, type_, key):
  2114. return charPtrToString(self.lib.carla_get_custom_data_value(pluginId, type_.encode("utf-8"), key.encode("utf-8")))
  2115. def get_chunk_data(self, pluginId):
  2116. return charPtrToString(self.lib.carla_get_chunk_data(pluginId))
  2117. def get_parameter_count(self, pluginId):
  2118. return int(self.lib.carla_get_parameter_count(pluginId))
  2119. def get_program_count(self, pluginId):
  2120. return int(self.lib.carla_get_program_count(pluginId))
  2121. def get_midi_program_count(self, pluginId):
  2122. return int(self.lib.carla_get_midi_program_count(pluginId))
  2123. def get_custom_data_count(self, pluginId):
  2124. return int(self.lib.carla_get_custom_data_count(pluginId))
  2125. def get_parameter_text(self, pluginId, parameterId):
  2126. return charPtrToString(self.lib.carla_get_parameter_text(pluginId, parameterId))
  2127. def get_program_name(self, pluginId, programId):
  2128. return charPtrToString(self.lib.carla_get_program_name(pluginId, programId))
  2129. def get_midi_program_name(self, pluginId, midiProgramId):
  2130. return charPtrToString(self.lib.carla_get_midi_program_name(pluginId, midiProgramId))
  2131. def get_real_plugin_name(self, pluginId):
  2132. return charPtrToString(self.lib.carla_get_real_plugin_name(pluginId))
  2133. def get_current_program_index(self, pluginId):
  2134. return int(self.lib.carla_get_current_program_index(pluginId))
  2135. def get_current_midi_program_index(self, pluginId):
  2136. return int(self.lib.carla_get_current_midi_program_index(pluginId))
  2137. def get_default_parameter_value(self, pluginId, parameterId):
  2138. return float(self.lib.carla_get_default_parameter_value(pluginId, parameterId))
  2139. def get_current_parameter_value(self, pluginId, parameterId):
  2140. return float(self.lib.carla_get_current_parameter_value(pluginId, parameterId))
  2141. def get_internal_parameter_value(self, pluginId, parameterId):
  2142. return float(self.lib.carla_get_internal_parameter_value(pluginId, parameterId))
  2143. def get_input_peak_value(self, pluginId, isLeft):
  2144. return float(self.lib.carla_get_input_peak_value(pluginId, isLeft))
  2145. def get_output_peak_value(self, pluginId, isLeft):
  2146. return float(self.lib.carla_get_output_peak_value(pluginId, isLeft))
  2147. def render_inline_display(self, pluginId, width, height):
  2148. return structToDict(self.lib.carla_render_inline_display(pluginId, width, height))
  2149. def set_option(self, pluginId, option, yesNo):
  2150. self.lib.carla_set_option(pluginId, option, yesNo)
  2151. def set_active(self, pluginId, onOff):
  2152. self.lib.carla_set_active(pluginId, onOff)
  2153. def set_drywet(self, pluginId, value):
  2154. self.lib.carla_set_drywet(pluginId, value)
  2155. def set_volume(self, pluginId, value):
  2156. self.lib.carla_set_volume(pluginId, value)
  2157. def set_balance_left(self, pluginId, value):
  2158. self.lib.carla_set_balance_left(pluginId, value)
  2159. def set_balance_right(self, pluginId, value):
  2160. self.lib.carla_set_balance_right(pluginId, value)
  2161. def set_panning(self, pluginId, value):
  2162. self.lib.carla_set_panning(pluginId, value)
  2163. def set_ctrl_channel(self, pluginId, channel):
  2164. self.lib.carla_set_ctrl_channel(pluginId, channel)
  2165. def set_parameter_value(self, pluginId, parameterId, value):
  2166. self.lib.carla_set_parameter_value(pluginId, parameterId, value)
  2167. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  2168. self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel)
  2169. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  2170. self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc)
  2171. def set_program(self, pluginId, programId):
  2172. self.lib.carla_set_program(pluginId, programId)
  2173. def set_midi_program(self, pluginId, midiProgramId):
  2174. self.lib.carla_set_midi_program(pluginId, midiProgramId)
  2175. def set_custom_data(self, pluginId, type_, key, value):
  2176. self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8"))
  2177. def set_chunk_data(self, pluginId, chunkData):
  2178. self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8"))
  2179. def prepare_for_save(self, pluginId):
  2180. self.lib.carla_prepare_for_save(pluginId)
  2181. def reset_parameters(self, pluginId):
  2182. self.lib.carla_reset_parameters(pluginId)
  2183. def randomize_parameters(self, pluginId):
  2184. self.lib.carla_randomize_parameters(pluginId)
  2185. def send_midi_note(self, pluginId, channel, note, velocity):
  2186. self.lib.carla_send_midi_note(pluginId, channel, note, velocity)
  2187. def show_custom_ui(self, pluginId, yesNo):
  2188. self.lib.carla_show_custom_ui(pluginId, yesNo)
  2189. def get_buffer_size(self):
  2190. return int(self.lib.carla_get_buffer_size())
  2191. def get_sample_rate(self):
  2192. return float(self.lib.carla_get_sample_rate())
  2193. def get_last_error(self):
  2194. return charPtrToString(self.lib.carla_get_last_error())
  2195. def get_host_osc_url_tcp(self):
  2196. return charPtrToString(self.lib.carla_get_host_osc_url_tcp())
  2197. def get_host_osc_url_udp(self):
  2198. return charPtrToString(self.lib.carla_get_host_osc_url_udp())
  2199. def nsm_init(self, pid, executableName):
  2200. return bool(self.lib.carla_nsm_init(pid, executableName.encode("utf-8")))
  2201. def nsm_ready(self, opcode):
  2202. self.lib.carla_nsm_ready(opcode)
  2203. # ------------------------------------------------------------------------------------------------------------
  2204. # Helper object for CarlaHostPlugin
  2205. class PluginStoreInfo(object):
  2206. __slots__ = [
  2207. 'pluginInfo',
  2208. 'pluginRealName',
  2209. 'internalValues',
  2210. 'audioCountInfo',
  2211. 'midiCountInfo',
  2212. 'parameterCount',
  2213. 'parameterCountInfo',
  2214. 'parameterInfo',
  2215. 'parameterData',
  2216. 'parameterRanges',
  2217. 'parameterValues',
  2218. 'programCount',
  2219. 'programCurrent',
  2220. 'programNames',
  2221. 'midiProgramCount',
  2222. 'midiProgramCurrent',
  2223. 'midiProgramData',
  2224. 'customDataCount',
  2225. 'customData',
  2226. 'peaks'
  2227. ]
  2228. # ------------------------------------------------------------------------------------------------------------
  2229. # Carla Host object for plugins (using pipes)
  2230. class CarlaHostPlugin(CarlaHostMeta):
  2231. #class CarlaHostPlugin(CarlaHostMeta, metaclass=ABCMeta):
  2232. def __init__(self):
  2233. CarlaHostMeta.__init__(self)
  2234. # info about this host object
  2235. self.isPlugin = True
  2236. self.processModeForced = True
  2237. # text data to return when requested
  2238. self.fMaxPluginNumber = 0
  2239. self.fLastError = ""
  2240. # plugin info
  2241. self.fPluginsInfo = []
  2242. # runtime engine info
  2243. self.fRuntimeEngineInfo = {
  2244. "load": 0.0,
  2245. "xruns": 0
  2246. }
  2247. # transport info
  2248. self.fTransportInfo = {
  2249. "playing": False,
  2250. "frame": 0,
  2251. "bar": 0,
  2252. "beat": 0,
  2253. "tick": 0,
  2254. "bpm": 0.0
  2255. }
  2256. # some other vars
  2257. self.fBufferSize = 0
  2258. self.fSampleRate = 0.0
  2259. self.fOscTCP = ""
  2260. self.fOscUDP = ""
  2261. # --------------------------------------------------------------------------------------------------------
  2262. # Needs to be reimplemented
  2263. @abstractmethod
  2264. def sendMsg(self, lines):
  2265. raise NotImplementedError
  2266. # internal, sets error if sendMsg failed
  2267. def sendMsgAndSetError(self, lines):
  2268. if self.sendMsg(lines):
  2269. return True
  2270. self.fLastError = "Communication error with backend"
  2271. return False
  2272. # --------------------------------------------------------------------------------------------------------
  2273. def get_engine_driver_count(self):
  2274. return 1
  2275. def get_engine_driver_name(self, index):
  2276. return "Plugin"
  2277. def get_engine_driver_device_names(self, index):
  2278. return []
  2279. def get_engine_driver_device_info(self, index, name):
  2280. return PyEngineDriverDeviceInfo
  2281. def get_runtime_engine_info(self):
  2282. return self.fRuntimeEngineInfo
  2283. def clear_engine_xruns(self):
  2284. self.sendMsg(["clear_engine_xruns"])
  2285. def cancel_engine_action(self):
  2286. self.sendMsg(["cancel_engine_action"])
  2287. def set_engine_callback(self, func):
  2288. return # TODO
  2289. def set_engine_option(self, option, value, valueStr):
  2290. self.sendMsg(["set_engine_option", option, int(value), valueStr])
  2291. def set_file_callback(self, func):
  2292. return # TODO
  2293. def load_file(self, filename):
  2294. return self.sendMsgAndSetError(["load_file", filename])
  2295. def load_project(self, filename):
  2296. return self.sendMsgAndSetError(["load_project", filename])
  2297. def save_project(self, filename):
  2298. return self.sendMsgAndSetError(["save_project", filename])
  2299. def clear_project_filename(self):
  2300. return self.sendMsgAndSetError(["clear_project_filename"])
  2301. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  2302. return self.sendMsgAndSetError(["patchbay_connect", external, groupIdA, portIdA, groupIdB, portIdB])
  2303. def patchbay_disconnect(self, external, connectionId):
  2304. return self.sendMsgAndSetError(["patchbay_disconnect", external, connectionId])
  2305. def patchbay_refresh(self, external):
  2306. return self.sendMsgAndSetError(["patchbay_refresh", external])
  2307. def transport_play(self):
  2308. self.sendMsg(["transport_play"])
  2309. def transport_pause(self):
  2310. self.sendMsg(["transport_pause"])
  2311. def transport_bpm(self, bpm):
  2312. self.sendMsg(["transport_bpm", bpm])
  2313. def transport_relocate(self, frame):
  2314. self.sendMsg(["transport_relocate", frame])
  2315. def get_current_transport_frame(self):
  2316. return self.fTransportInfo['frame']
  2317. def get_transport_info(self):
  2318. return self.fTransportInfo
  2319. def get_current_plugin_count(self):
  2320. return len(self.fPluginsInfo)
  2321. def get_max_plugin_number(self):
  2322. return self.fMaxPluginNumber
  2323. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  2324. return self.sendMsgAndSetError(["add_plugin",
  2325. btype, ptype,
  2326. filename or "(null)",
  2327. name or "(null)",
  2328. label, uniqueId, options])
  2329. def remove_plugin(self, pluginId):
  2330. return self.sendMsgAndSetError(["remove_plugin", pluginId])
  2331. def remove_all_plugins(self):
  2332. return self.sendMsgAndSetError(["remove_all_plugins"])
  2333. def rename_plugin(self, pluginId, newName):
  2334. if self.sendMsg(["rename_plugin", pluginId, newName]):
  2335. return newName
  2336. self.fLastError = "Communication error with backend"
  2337. return ""
  2338. def clone_plugin(self, pluginId):
  2339. return self.sendMsgAndSetError(["clone_plugin", pluginId])
  2340. def replace_plugin(self, pluginId):
  2341. return self.sendMsgAndSetError(["replace_plugin", pluginId])
  2342. def switch_plugins(self, pluginIdA, pluginIdB):
  2343. ret = self.sendMsgAndSetError(["switch_plugins", pluginIdA, pluginIdB])
  2344. if ret:
  2345. self._switchPlugins(pluginIdA, pluginIdB)
  2346. return ret
  2347. def load_plugin_state(self, pluginId, filename):
  2348. return self.sendMsgAndSetError(["load_plugin_state", pluginId, filename])
  2349. def save_plugin_state(self, pluginId, filename):
  2350. return self.sendMsgAndSetError(["save_plugin_state", pluginId, filename])
  2351. def export_plugin_lv2(self, pluginId, lv2path):
  2352. self.fLastError = "Operation unavailable in plugin version"
  2353. return False
  2354. def get_plugin_info(self, pluginId):
  2355. return self.fPluginsInfo[pluginId].pluginInfo
  2356. def get_audio_port_count_info(self, pluginId):
  2357. return self.fPluginsInfo[pluginId].audioCountInfo
  2358. def get_midi_port_count_info(self, pluginId):
  2359. return self.fPluginsInfo[pluginId].midiCountInfo
  2360. def get_parameter_count_info(self, pluginId):
  2361. return self.fPluginsInfo[pluginId].parameterCountInfo
  2362. def get_parameter_info(self, pluginId, parameterId):
  2363. return self.fPluginsInfo[pluginId].parameterInfo[parameterId]
  2364. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  2365. return PyCarlaScalePointInfo
  2366. def get_parameter_data(self, pluginId, parameterId):
  2367. return self.fPluginsInfo[pluginId].parameterData[parameterId]
  2368. def get_parameter_ranges(self, pluginId, parameterId):
  2369. return self.fPluginsInfo[pluginId].parameterRanges[parameterId]
  2370. def get_midi_program_data(self, pluginId, midiProgramId):
  2371. return self.fPluginsInfo[pluginId].midiProgramData[midiProgramId]
  2372. def get_custom_data(self, pluginId, customDataId):
  2373. return self.fPluginsInfo[pluginId].customData[customDataId]
  2374. def get_custom_data_value(self, pluginId, type_, key):
  2375. for customData in self.fPluginsInfo[pluginId].customData:
  2376. if customData['type'] == type_ and customData['key'] == key:
  2377. return customData['value']
  2378. return ""
  2379. def get_chunk_data(self, pluginId):
  2380. return ""
  2381. def get_parameter_count(self, pluginId):
  2382. return self.fPluginsInfo[pluginId].parameterCount
  2383. def get_program_count(self, pluginId):
  2384. return self.fPluginsInfo[pluginId].programCount
  2385. def get_midi_program_count(self, pluginId):
  2386. return self.fPluginsInfo[pluginId].midiProgramCount
  2387. def get_custom_data_count(self, pluginId):
  2388. return self.fPluginsInfo[pluginId].customDataCount
  2389. def get_parameter_text(self, pluginId, parameterId):
  2390. return ""
  2391. def get_program_name(self, pluginId, programId):
  2392. return self.fPluginsInfo[pluginId].programNames[programId]
  2393. def get_midi_program_name(self, pluginId, midiProgramId):
  2394. return self.fPluginsInfo[pluginId].midiProgramData[midiProgramId]['label']
  2395. def get_real_plugin_name(self, pluginId):
  2396. return self.fPluginsInfo[pluginId].pluginRealName
  2397. def get_current_program_index(self, pluginId):
  2398. return self.fPluginsInfo[pluginId].programCurrent
  2399. def get_current_midi_program_index(self, pluginId):
  2400. return self.fPluginsInfo[pluginId].midiProgramCurrent
  2401. def get_default_parameter_value(self, pluginId, parameterId):
  2402. return self.fPluginsInfo[pluginId].parameterRanges[parameterId]['def']
  2403. def get_current_parameter_value(self, pluginId, parameterId):
  2404. return self.fPluginsInfo[pluginId].parameterValues[parameterId]
  2405. def get_internal_parameter_value(self, pluginId, parameterId):
  2406. if parameterId == PARAMETER_NULL or parameterId <= PARAMETER_MAX:
  2407. return 0.0
  2408. if parameterId < 0:
  2409. return self.fPluginsInfo[pluginId].internalValues[abs(parameterId)-2]
  2410. return self.fPluginsInfo[pluginId].parameterValues[parameterId]
  2411. def get_input_peak_value(self, pluginId, isLeft):
  2412. return self.fPluginsInfo[pluginId].peaks[0 if isLeft else 1]
  2413. def get_output_peak_value(self, pluginId, isLeft):
  2414. return self.fPluginsInfo[pluginId].peaks[2 if isLeft else 3]
  2415. def render_inline_display(self, pluginId, width, height):
  2416. return None
  2417. def set_option(self, pluginId, option, yesNo):
  2418. self.sendMsg(["set_option", pluginId, option, yesNo])
  2419. def set_active(self, pluginId, onOff):
  2420. self.sendMsg(["set_active", pluginId, onOff])
  2421. self.fPluginsInfo[pluginId].internalValues[0] = 1.0 if onOff else 0.0
  2422. def set_drywet(self, pluginId, value):
  2423. self.sendMsg(["set_drywet", pluginId, value])
  2424. self.fPluginsInfo[pluginId].internalValues[1] = value
  2425. def set_volume(self, pluginId, value):
  2426. self.sendMsg(["set_volume", pluginId, value])
  2427. self.fPluginsInfo[pluginId].internalValues[2] = value
  2428. def set_balance_left(self, pluginId, value):
  2429. self.sendMsg(["set_balance_left", pluginId, value])
  2430. self.fPluginsInfo[pluginId].internalValues[3] = value
  2431. def set_balance_right(self, pluginId, value):
  2432. self.sendMsg(["set_balance_right", pluginId, value])
  2433. self.fPluginsInfo[pluginId].internalValues[4] = value
  2434. def set_panning(self, pluginId, value):
  2435. self.sendMsg(["set_panning", pluginId, value])
  2436. self.fPluginsInfo[pluginId].internalValues[5] = value
  2437. def set_ctrl_channel(self, pluginId, channel):
  2438. self.sendMsg(["set_ctrl_channel", pluginId, channel])
  2439. self.fPluginsInfo[pluginId].internalValues[6] = float(channel)
  2440. def set_parameter_value(self, pluginId, parameterId, value):
  2441. self.sendMsg(["set_parameter_value", pluginId, parameterId, value])
  2442. self.fPluginsInfo[pluginId].parameterValues[parameterId] = value
  2443. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  2444. self.sendMsg(["set_parameter_midi_channel", pluginId, parameterId, channel])
  2445. self.fPluginsInfo[pluginId].parameterData[parameterId]['midiCC'] = channel
  2446. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  2447. self.sendMsg(["set_parameter_midi_cc", pluginId, parameterId, cc])
  2448. self.fPluginsInfo[pluginId].parameterData[parameterId]['midiCC'] = cc
  2449. def set_program(self, pluginId, programId):
  2450. self.sendMsg(["set_program", pluginId, programId])
  2451. self.fPluginsInfo[pluginId].programCurrent = programId
  2452. def set_midi_program(self, pluginId, midiProgramId):
  2453. self.sendMsg(["set_midi_program", pluginId, midiProgramId])
  2454. self.fPluginsInfo[pluginId].midiProgramCurrent = midiProgramId
  2455. def set_custom_data(self, pluginId, type_, key, value):
  2456. self.sendMsg(["set_custom_data", pluginId, type_, key, value])
  2457. for cdata in self.fPluginsInfo[pluginId].customData:
  2458. if cdata['type'] != type_:
  2459. continue
  2460. if cdata['key'] != key:
  2461. continue
  2462. cdata['value'] = value
  2463. break
  2464. def set_chunk_data(self, pluginId, chunkData):
  2465. self.sendMsg(["set_chunk_data", pluginId, chunkData])
  2466. def prepare_for_save(self, pluginId):
  2467. self.sendMsg(["prepare_for_save", pluginId])
  2468. def reset_parameters(self, pluginId):
  2469. self.sendMsg(["reset_parameters", pluginId])
  2470. def randomize_parameters(self, pluginId):
  2471. self.sendMsg(["randomize_parameters", pluginId])
  2472. def send_midi_note(self, pluginId, channel, note, velocity):
  2473. self.sendMsg(["send_midi_note", pluginId, channel, note, velocity])
  2474. def show_custom_ui(self, pluginId, yesNo):
  2475. self.sendMsg(["show_custom_ui", pluginId, yesNo])
  2476. def get_buffer_size(self):
  2477. return self.fBufferSize
  2478. def get_sample_rate(self):
  2479. return self.fSampleRate
  2480. def get_last_error(self):
  2481. return self.fLastError
  2482. def get_host_osc_url_tcp(self):
  2483. return self.fOscTCP
  2484. def get_host_osc_url_udp(self):
  2485. return self.fOscUDP
  2486. # --------------------------------------------------------------------------------------------------------
  2487. def _set_runtime_info(self, load, xruns):
  2488. self.fRuntimeEngineInfo = {
  2489. "load": load,
  2490. "xruns": xruns
  2491. }
  2492. def _set_transport(self, playing, frame, bar, beat, tick, bpm):
  2493. self.fTransportInfo = {
  2494. "playing": playing,
  2495. "frame": frame,
  2496. "bar": bar,
  2497. "beat": beat,
  2498. "tick": tick,
  2499. "bpm": bpm
  2500. }
  2501. def _add(self, pluginId):
  2502. if len(self.fPluginsInfo) != pluginId:
  2503. self._reset_info(self.fPluginsInfo[pluginId])
  2504. return
  2505. info = PluginStoreInfo()
  2506. self._reset_info(info)
  2507. self.fPluginsInfo.append(info)
  2508. def _allocateAsNeeded(self, pluginId):
  2509. if pluginId < len(self.fPluginsInfo):
  2510. return
  2511. for i in range(pluginId + 1 - len(self.fPluginsInfo)):
  2512. info = PluginStoreInfo()
  2513. self._reset_info(info)
  2514. self.fPluginsInfo.append(info)
  2515. def _reset_info(self, info):
  2516. info.pluginInfo = PyCarlaPluginInfo.copy()
  2517. info.pluginRealName = ""
  2518. info.internalValues = [0.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0]
  2519. info.audioCountInfo = PyCarlaPortCountInfo.copy()
  2520. info.midiCountInfo = PyCarlaPortCountInfo.copy()
  2521. info.parameterCount = 0
  2522. info.parameterCountInfo = PyCarlaPortCountInfo.copy()
  2523. info.parameterInfo = []
  2524. info.parameterData = []
  2525. info.parameterRanges = []
  2526. info.parameterValues = []
  2527. info.programCount = 0
  2528. info.programCurrent = -1
  2529. info.programNames = []
  2530. info.midiProgramCount = 0
  2531. info.midiProgramCurrent = -1
  2532. info.midiProgramData = []
  2533. info.customDataCount = 0
  2534. info.customData = []
  2535. info.peaks = [0.0, 0.0, 0.0, 0.0]
  2536. def _set_pluginInfo(self, pluginId, info):
  2537. self.fPluginsInfo[pluginId].pluginInfo = info
  2538. def _set_pluginInfoUpdate(self, pluginId, info):
  2539. self.fPluginsInfo[pluginId].pluginInfo.update(info)
  2540. def _set_pluginName(self, pluginId, name):
  2541. self.fPluginsInfo[pluginId].pluginInfo['name'] = name
  2542. def _set_pluginRealName(self, pluginId, realName):
  2543. self.fPluginsInfo[pluginId].pluginRealName = realName
  2544. def _set_internalValue(self, pluginId, paramIndex, value):
  2545. if pluginId < len(self.fPluginsInfo) and PARAMETER_NULL > paramIndex > PARAMETER_MAX:
  2546. self.fPluginsInfo[pluginId].internalValues[abs(paramIndex)-2] = float(value)
  2547. def _set_audioCountInfo(self, pluginId, info):
  2548. #self._allocateAsNeeded(pluginId)
  2549. self.fPluginsInfo[pluginId].audioCountInfo = info
  2550. def _set_midiCountInfo(self, pluginId, info):
  2551. self.fPluginsInfo[pluginId].midiCountInfo = info
  2552. def _set_parameterCountInfo(self, pluginId, count, info):
  2553. self.fPluginsInfo[pluginId].parameterCount = count
  2554. self.fPluginsInfo[pluginId].parameterCountInfo = info
  2555. # clear
  2556. self.fPluginsInfo[pluginId].parameterInfo = []
  2557. self.fPluginsInfo[pluginId].parameterData = []
  2558. self.fPluginsInfo[pluginId].parameterRanges = []
  2559. self.fPluginsInfo[pluginId].parameterValues = []
  2560. # add placeholders
  2561. for x in range(count):
  2562. self.fPluginsInfo[pluginId].parameterInfo.append(PyCarlaParameterInfo.copy())
  2563. self.fPluginsInfo[pluginId].parameterData.append(PyParameterData.copy())
  2564. self.fPluginsInfo[pluginId].parameterRanges.append(PyParameterRanges.copy())
  2565. self.fPluginsInfo[pluginId].parameterValues.append(0.0)
  2566. def _set_programCount(self, pluginId, count):
  2567. self.fPluginsInfo[pluginId].programCount = count
  2568. # clear
  2569. self.fPluginsInfo[pluginId].programNames = []
  2570. # add placeholders
  2571. for x in range(count):
  2572. self.fPluginsInfo[pluginId].programNames.append("")
  2573. def _set_midiProgramCount(self, pluginId, count):
  2574. self.fPluginsInfo[pluginId].midiProgramCount = count
  2575. # clear
  2576. self.fPluginsInfo[pluginId].midiProgramData = []
  2577. # add placeholders
  2578. for x in range(count):
  2579. self.fPluginsInfo[pluginId].midiProgramData.append(PyMidiProgramData.copy())
  2580. def _set_customDataCount(self, pluginId, count):
  2581. self.fPluginsInfo[pluginId].customDataCount = count
  2582. # clear
  2583. self.fPluginsInfo[pluginId].customData = []
  2584. # add placeholders
  2585. for x in range(count):
  2586. self.fPluginsInfo[pluginId].customData.append(PyCustomData.copy())
  2587. def _set_parameterInfo(self, pluginId, paramIndex, info):
  2588. if pluginId < len(self.fPluginsInfo) and paramIndex < self.fPluginsInfo[pluginId].parameterCount:
  2589. self.fPluginsInfo[pluginId].parameterInfo[paramIndex] = info
  2590. def _set_parameterData(self, pluginId, paramIndex, data):
  2591. if pluginId < len(self.fPluginsInfo) and paramIndex < self.fPluginsInfo[pluginId].parameterCount:
  2592. self.fPluginsInfo[pluginId].parameterData[paramIndex] = data
  2593. def _set_parameterRanges(self, pluginId, paramIndex, ranges):
  2594. if pluginId < len(self.fPluginsInfo) and paramIndex < self.fPluginsInfo[pluginId].parameterCount:
  2595. self.fPluginsInfo[pluginId].parameterRanges[paramIndex] = ranges
  2596. def _set_parameterRangesUpdate(self, pluginId, paramIndex, ranges):
  2597. if pluginId < len(self.fPluginsInfo) and paramIndex < self.fPluginsInfo[pluginId].parameterCount:
  2598. self.fPluginsInfo[pluginId].parameterRanges[paramIndex].update(ranges)
  2599. def _set_parameterValue(self, pluginId, paramIndex, value):
  2600. if pluginId < len(self.fPluginsInfo) and paramIndex < self.fPluginsInfo[pluginId].parameterCount:
  2601. self.fPluginsInfo[pluginId].parameterValues[paramIndex] = value
  2602. def _set_parameterDefault(self, pluginId, paramIndex, value):
  2603. if pluginId < len(self.fPluginsInfo) and paramIndex < self.fPluginsInfo[pluginId].parameterCount:
  2604. self.fPluginsInfo[pluginId].parameterRanges[paramIndex]['def'] = value
  2605. def _set_parameterMidiChannel(self, pluginId, paramIndex, channel):
  2606. if pluginId < len(self.fPluginsInfo) and paramIndex < self.fPluginsInfo[pluginId].parameterCount:
  2607. self.fPluginsInfo[pluginId].parameterData[paramIndex]['midiChannel'] = channel
  2608. def _set_parameterMidiCC(self, pluginId, paramIndex, cc):
  2609. if pluginId < len(self.fPluginsInfo) and paramIndex < self.fPluginsInfo[pluginId].parameterCount:
  2610. self.fPluginsInfo[pluginId].parameterData[paramIndex]['midiCC'] = cc
  2611. def _set_currentProgram(self, pluginId, pIndex):
  2612. self.fPluginsInfo[pluginId].programCurrent = pIndex
  2613. def _set_currentMidiProgram(self, pluginId, mpIndex):
  2614. self.fPluginsInfo[pluginId].midiProgramCurrent = mpIndex
  2615. def _set_programName(self, pluginId, pIndex, name):
  2616. if pIndex < self.fPluginsInfo[pluginId].programCount:
  2617. self.fPluginsInfo[pluginId].programNames[pIndex] = name
  2618. def _set_midiProgramData(self, pluginId, mpIndex, data):
  2619. if mpIndex < self.fPluginsInfo[pluginId].midiProgramCount:
  2620. self.fPluginsInfo[pluginId].midiProgramData[mpIndex] = data
  2621. def _set_customData(self, pluginId, cdIndex, data):
  2622. if cdIndex < self.fPluginsInfo[pluginId].customDataCount:
  2623. self.fPluginsInfo[pluginId].customData[cdIndex] = data
  2624. def _set_peaks(self, pluginId, in1, in2, out1, out2):
  2625. if pluginId < len(self.fPluginsInfo):
  2626. self.fPluginsInfo[pluginId].peaks = [in1, in2, out1, out2]
  2627. def _switchPlugins(self, pluginIdA, pluginIdB):
  2628. tmp = self.fPluginsInfo[pluginIdA]
  2629. self.fPluginsInfo[pluginIdA] = self.fPluginsInfo[pluginIdB]
  2630. self.fPluginsInfo[pluginIdB] = tmp
  2631. def _setViaCallback(self, action, pluginId, value1, value2, value3, valuef, valueStr):
  2632. if action == ENGINE_CALLBACK_ENGINE_STARTED:
  2633. self._allocateAsNeeded(pluginId)
  2634. self.fBufferSize = value3
  2635. self.fSampleRate = valuef
  2636. elif ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  2637. self.fBufferSize = value1
  2638. elif ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  2639. self.fSampleRate = valuef
  2640. elif action == ENGINE_CALLBACK_PLUGIN_RENAMED:
  2641. self._set_pluginName(pluginId, valueStr)
  2642. elif action == ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  2643. if value1 < 0:
  2644. self._set_internalValue(pluginId, value1, valuef)
  2645. else:
  2646. self._set_parameterValue(pluginId, value1, valuef)
  2647. elif action == ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  2648. self._set_parameterDefault(pluginId, value1, valuef)
  2649. elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED:
  2650. self._set_parameterMidiCC(pluginId, value1, value2)
  2651. elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  2652. self._set_parameterMidiChannel(pluginId, value1, value2)
  2653. elif action == ENGINE_CALLBACK_PROGRAM_CHANGED:
  2654. self._set_currentProgram(pluginId, value1)
  2655. elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  2656. self._set_currentMidiProgram(pluginId, value1)
  2657. # ------------------------------------------------------------------------------------------------------------