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.

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