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.

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