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.

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