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.

3817 lines
121KB

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