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.

3243 lines
102KB

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