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.

3782 lines
120KB

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