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.

3289 lines
102KB

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