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.

3160 lines
98KB

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