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.

3248 lines
102KB

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