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.

3233 lines
100KB

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