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.

3072 lines
96KB

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