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.

3231 lines
101KB

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