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 os import environ
  22. from platform import architecture
  23. from sys import platform, maxsize
  24. # ------------------------------------------------------------------------------------------------------------
  25. # 64bit check
  26. kIs64bit = bool(architecture()[0] == "64bit" and maxsize > 2**32)
  27. # ------------------------------------------------------------------------------------------------------------
  28. # Define custom types
  29. c_enum = c_int
  30. c_uintptr = c_uint64 if kIs64bit else c_uint32
  31. # ------------------------------------------------------------------------------------------------------------
  32. # Set Platform
  33. if platform == "darwin":
  34. HAIKU = False
  35. LINUX = False
  36. MACOS = True
  37. WINDOWS = False
  38. elif "haiku" in platform:
  39. HAIKU = True
  40. LINUX = False
  41. MACOS = False
  42. WINDOWS = False
  43. elif "linux" in platform:
  44. HAIKU = False
  45. LINUX = True
  46. MACOS = False
  47. WINDOWS = False
  48. elif platform in ("win32", "win64", "cygwin"):
  49. HAIKU = False
  50. LINUX = False
  51. MACOS = False
  52. WINDOWS = True
  53. else:
  54. HAIKU = False
  55. LINUX = False
  56. MACOS = False
  57. WINDOWS = False
  58. # ------------------------------------------------------------------------------------------------------------
  59. # Convert a ctypes c_char_p into a python string
  60. def charPtrToString(charPtr):
  61. if not charPtr:
  62. return ""
  63. if isinstance(charPtr, str):
  64. return charPtr
  65. return charPtr.decode("utf-8", errors="ignore")
  66. # ------------------------------------------------------------------------------------------------------------
  67. # Convert a ctypes POINTER(c_char_p) into a python string list
  68. def charPtrPtrToStringList(charPtrPtr):
  69. if not charPtrPtr:
  70. return []
  71. i = 0
  72. charPtr = charPtrPtr[0]
  73. strList = []
  74. while charPtr:
  75. strList.append(charPtr.decode("utf-8", errors="ignore"))
  76. i += 1
  77. charPtr = charPtrPtr[i]
  78. return strList
  79. # ------------------------------------------------------------------------------------------------------------
  80. # Convert a ctypes POINTER(c_<num>) into a python number list
  81. def numPtrToList(numPtr):
  82. if not numPtr:
  83. return []
  84. i = 0
  85. num = numPtr[0] #.value
  86. numList = []
  87. while num not in (0, 0.0):
  88. numList.append(num)
  89. i += 1
  90. num = numPtr[i] #.value
  91. return numList
  92. # ------------------------------------------------------------------------------------------------------------
  93. # Convert a ctypes value into a python one
  94. c_int_types = (c_int, c_int8, c_int16, c_int32, c_int64, c_uint, c_uint8, c_uint16, c_uint32, c_uint64, c_long, c_longlong)
  95. c_float_types = (c_float, c_double, c_longdouble)
  96. c_intp_types = tuple(POINTER(i) for i in c_int_types)
  97. c_floatp_types = tuple(POINTER(i) for i in c_float_types)
  98. def toPythonType(value, attr):
  99. if isinstance(value, (bool, int, float)):
  100. return value
  101. if isinstance(value, bytes):
  102. return charPtrToString(value)
  103. if isinstance(value, c_intp_types) or isinstance(value, c_floatp_types):
  104. return numPtrToList(value)
  105. if isinstance(value, POINTER(c_char_p)):
  106. return charPtrPtrToStringList(value)
  107. print("..............", attr, ".....................", value, ":", type(value))
  108. return value
  109. # ------------------------------------------------------------------------------------------------------------
  110. # Convert a ctypes struct into a python dict
  111. def structToDict(struct):
  112. return dict((attr, toPythonType(getattr(struct, attr), attr)) for attr, value in struct._fields_)
  113. # ------------------------------------------------------------------------------------------------------------
  114. # Carla Backend API (base definitions)
  115. # Maximum default number of loadable plugins.
  116. MAX_DEFAULT_PLUGINS = 99
  117. # Maximum number of loadable plugins in rack mode.
  118. MAX_RACK_PLUGINS = 16
  119. # Maximum number of loadable plugins in patchbay mode.
  120. MAX_PATCHBAY_PLUGINS = 255
  121. # Maximum default number of parameters allowed.
  122. # @see ENGINE_OPTION_MAX_PARAMETERS
  123. MAX_DEFAULT_PARAMETERS = 200
  124. # ------------------------------------------------------------------------------------------------------------
  125. # Engine Driver Device Hints
  126. # Various engine driver device hints.
  127. # @see carla_get_engine_driver_device_info()
  128. # Engine driver device has custom control-panel.
  129. ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL = 0x1
  130. # Engine driver device can use a triple-buffer (3 number of periods instead of the usual 2).
  131. # @see ENGINE_OPTION_AUDIO_NUM_PERIODS
  132. ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER = 0x2
  133. # Engine driver device can change buffer-size on the fly.
  134. # @see ENGINE_OPTION_AUDIO_BUFFER_SIZE
  135. ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE = 0x4
  136. # Engine driver device can change sample-rate on the fly.
  137. # @see ENGINE_OPTION_AUDIO_SAMPLE_RATE
  138. ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x8
  139. # ------------------------------------------------------------------------------------------------------------
  140. # Plugin Hints
  141. # Various plugin hints.
  142. # @see carla_get_plugin_info()
  143. # Plugin is a bridge.
  144. # This hint is required because "bridge" itself is not a plugin type.
  145. PLUGIN_IS_BRIDGE = 0x001
  146. # Plugin is hard real-time safe.
  147. PLUGIN_IS_RTSAFE = 0x002
  148. # Plugin is a synth (produces sound).
  149. PLUGIN_IS_SYNTH = 0x004
  150. # Plugin has its own custom UI.
  151. # @see carla_show_custom_ui()
  152. PLUGIN_HAS_CUSTOM_UI = 0x008
  153. # Plugin can use internal Dry/Wet control.
  154. PLUGIN_CAN_DRYWET = 0x010
  155. # Plugin can use internal Volume control.
  156. PLUGIN_CAN_VOLUME = 0x020
  157. # Plugin can use internal (Stereo) Balance controls.
  158. PLUGIN_CAN_BALANCE = 0x040
  159. # Plugin can use internal (Mono) Panning control.
  160. PLUGIN_CAN_PANNING = 0x080
  161. # Plugin needs a constant, fixed-size audio buffer.
  162. PLUGIN_NEEDS_FIXED_BUFFERS = 0x100
  163. # Plugin needs to receive all UI events in the main thread.
  164. PLUGIN_NEEDS_UI_MAIN_THREAD = 0x200
  165. # ------------------------------------------------------------------------------------------------------------
  166. # Plugin Options
  167. # Various plugin options.
  168. # @see carla_get_plugin_info() and carla_set_option()
  169. # Use constant/fixed-size audio buffers.
  170. PLUGIN_OPTION_FIXED_BUFFERS = 0x001
  171. # Force mono plugin as stereo.
  172. PLUGIN_OPTION_FORCE_STEREO = 0x002
  173. # Map MIDI programs to plugin programs.
  174. PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004
  175. # Use chunks to save and restore data instead of parameter values.
  176. PLUGIN_OPTION_USE_CHUNKS = 0x008
  177. # Send MIDI control change events.
  178. PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010
  179. # Send MIDI channel pressure events.
  180. PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020
  181. # Send MIDI note after-touch events.
  182. PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040
  183. # Send MIDI pitch-bend events.
  184. PLUGIN_OPTION_SEND_PITCHBEND = 0x080
  185. # Send MIDI all-sounds/notes-off events, single note-offs otherwise.
  186. PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100
  187. # Send MIDI bank/program changes.
  188. # @note: This option conflicts with PLUGIN_OPTION_MAP_PROGRAM_CHANGES and cannot be used at the same time.
  189. PLUGIN_OPTION_SEND_PROGRAM_CHANGES = 0x200
  190. # ------------------------------------------------------------------------------------------------------------
  191. # Parameter Hints
  192. # Various parameter hints.
  193. # @see CarlaPlugin::getParameterData() and carla_get_parameter_data()
  194. # Parameter value is boolean.
  195. PARAMETER_IS_BOOLEAN = 0x001
  196. # Parameter value is integer.
  197. PARAMETER_IS_INTEGER = 0x002
  198. # Parameter value is logarithmic.
  199. PARAMETER_IS_LOGARITHMIC = 0x004
  200. # Parameter is enabled.
  201. # It can be viewed, changed and stored.
  202. PARAMETER_IS_ENABLED = 0x010
  203. # Parameter is automable (real-time safe).
  204. PARAMETER_IS_AUTOMABLE = 0x020
  205. # Parameter is read-only.
  206. # It cannot be changed.
  207. PARAMETER_IS_READ_ONLY = 0x040
  208. # Parameter needs sample rate to work.
  209. # Value and ranges are multiplied by sample rate on usage and divided by sample rate on save.
  210. PARAMETER_USES_SAMPLERATE = 0x100
  211. # Parameter uses scale points to define internal values in a meaningful way.
  212. PARAMETER_USES_SCALEPOINTS = 0x200
  213. # Parameter uses custom text for displaying its value.
  214. # @see carla_get_parameter_text()
  215. PARAMETER_USES_CUSTOM_TEXT = 0x400
  216. # ------------------------------------------------------------------------------------------------------------
  217. # Patchbay Port Hints
  218. # Various patchbay port hints.
  219. # Patchbay port is input.
  220. # When this hint is not set, port is assumed to be output.
  221. PATCHBAY_PORT_IS_INPUT = 0x1
  222. # Patchbay port is of Audio type.
  223. PATCHBAY_PORT_TYPE_AUDIO = 0x2
  224. # Patchbay port is of CV type (Control Voltage).
  225. PATCHBAY_PORT_TYPE_CV = 0x4
  226. # Patchbay port is of MIDI type.
  227. PATCHBAY_PORT_TYPE_MIDI = 0x8
  228. # ------------------------------------------------------------------------------------------------------------
  229. # Custom Data Types
  230. # These types define how the value in the CustomData struct is stored.
  231. # @see CustomData.type
  232. # Boolean string type URI.
  233. # Only "true" and "false" are valid values.
  234. CUSTOM_DATA_TYPE_BOOLEAN = "http://kxstudio.sf.net/ns/carla/boolean"
  235. # Chunk type URI.
  236. CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"
  237. # String type URI.
  238. CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string"
  239. # ------------------------------------------------------------------------------------------------------------
  240. # Custom Data Keys
  241. # Pre-defined keys used internally in Carla.
  242. # @see CustomData.key
  243. # Plugin options key.
  244. CUSTOM_DATA_KEY_PLUGIN_OPTIONS = "CarlaPluginOptions"
  245. # UI position key.
  246. CUSTOM_DATA_KEY_UI_POSITION = "CarlaUiPosition"
  247. # UI size key.
  248. CUSTOM_DATA_KEY_UI_SIZE = "CarlaUiSize"
  249. # UI visible key.
  250. CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUiVisible"
  251. # ------------------------------------------------------------------------------------------------------------
  252. # Binary Type
  253. # The binary type of a plugin.
  254. # Null binary type.
  255. BINARY_NONE = 0
  256. # POSIX 32bit binary.
  257. BINARY_POSIX32 = 1
  258. # POSIX 64bit binary.
  259. BINARY_POSIX64 = 2
  260. # Windows 32bit binary.
  261. BINARY_WIN32 = 3
  262. # Windows 64bit binary.
  263. BINARY_WIN64 = 4
  264. # Other binary type.
  265. BINARY_OTHER = 5
  266. # ------------------------------------------------------------------------------------------------------------
  267. # Plugin Type
  268. # Plugin type.
  269. # Some files are handled as if they were plugins.
  270. # Null plugin type.
  271. PLUGIN_NONE = 0
  272. # Internal plugin.
  273. PLUGIN_INTERNAL = 1
  274. # LADSPA plugin.
  275. PLUGIN_LADSPA = 2
  276. # DSSI plugin.
  277. PLUGIN_DSSI = 3
  278. # LV2 plugin.
  279. PLUGIN_LV2 = 4
  280. # VST2 plugin.
  281. PLUGIN_VST2 = 5
  282. # VST3 plugin.
  283. PLUGIN_VST3 = 6
  284. # AU plugin.
  285. # @note MacOS only
  286. PLUGIN_AU = 7
  287. # GIG file.
  288. PLUGIN_GIG = 8
  289. # SF2 file (SoundFont).
  290. PLUGIN_SF2 = 9
  291. # SFZ file.
  292. PLUGIN_SFZ = 10
  293. # ------------------------------------------------------------------------------------------------------------
  294. # Plugin Category
  295. # Plugin category, which describes the functionality of a plugin.
  296. # Null plugin category.
  297. PLUGIN_CATEGORY_NONE = 0
  298. # A synthesizer or generator.
  299. PLUGIN_CATEGORY_SYNTH = 1
  300. # A delay or reverb.
  301. PLUGIN_CATEGORY_DELAY = 2
  302. # An equalizer.
  303. PLUGIN_CATEGORY_EQ = 3
  304. # A filter.
  305. PLUGIN_CATEGORY_FILTER = 4
  306. # A distortion plugin.
  307. PLUGIN_CATEGORY_DISTORTION = 5
  308. # A 'dynamic' plugin (amplifier, compressor, gate, etc).
  309. PLUGIN_CATEGORY_DYNAMICS = 6
  310. # A 'modulator' plugin (chorus, flanger, phaser, etc).
  311. PLUGIN_CATEGORY_MODULATOR = 7
  312. # An 'utility' plugin (analyzer, converter, mixer, etc).
  313. PLUGIN_CATEGORY_UTILITY = 8
  314. # Miscellaneous plugin (used to check if the plugin has a category).
  315. PLUGIN_CATEGORY_OTHER = 9
  316. # ------------------------------------------------------------------------------------------------------------
  317. # Parameter Type
  318. # Plugin parameter type.
  319. # Null parameter type.
  320. PARAMETER_UNKNOWN = 0
  321. # Input parameter.
  322. PARAMETER_INPUT = 1
  323. # Ouput parameter.
  324. PARAMETER_OUTPUT = 2
  325. # ------------------------------------------------------------------------------------------------------------
  326. # Internal Parameter Index
  327. # Special parameters used internally in Carla.
  328. # Plugins do not know about their existence.
  329. # Null parameter.
  330. PARAMETER_NULL = -1
  331. # Active parameter, boolean type.
  332. # Default is 'false'.
  333. PARAMETER_ACTIVE = -2
  334. # Dry/Wet parameter.
  335. # Range 0.0...1.0; default is 1.0.
  336. PARAMETER_DRYWET = -3
  337. # Volume parameter.
  338. # Range 0.0...1.27; default is 1.0.
  339. PARAMETER_VOLUME = -4
  340. # Stereo Balance-Left parameter.
  341. # Range -1.0...1.0; default is -1.0.
  342. PARAMETER_BALANCE_LEFT = -5
  343. # Stereo Balance-Right parameter.
  344. # Range -1.0...1.0; default is 1.0.
  345. PARAMETER_BALANCE_RIGHT = -6
  346. # Mono Panning parameter.
  347. # Range -1.0...1.0; default is 0.0.
  348. PARAMETER_PANNING = -7
  349. # MIDI Control channel, integer type.
  350. # Range -1...15 (-1 = off).
  351. PARAMETER_CTRL_CHANNEL = -8
  352. # Max value, defined only for convenience.
  353. PARAMETER_MAX = -9
  354. # ------------------------------------------------------------------------------------------------------------
  355. # Engine Callback Opcode
  356. # Engine callback opcodes.
  357. # Front-ends must never block indefinitely during a callback.
  358. # @see EngineCallbackFunc and carla_set_engine_callback()
  359. # Debug.
  360. # This opcode is undefined and used only for testing purposes.
  361. ENGINE_CALLBACK_DEBUG = 0
  362. # A plugin has been added.
  363. # @a pluginId Plugin Id
  364. # @a valueStr Plugin name
  365. ENGINE_CALLBACK_PLUGIN_ADDED = 1
  366. # A plugin has been removed.
  367. # @a pluginId Plugin Id
  368. ENGINE_CALLBACK_PLUGIN_REMOVED = 2
  369. # A plugin has been renamed.
  370. # @a pluginId Plugin Id
  371. # @a valueStr New plugin name
  372. ENGINE_CALLBACK_PLUGIN_RENAMED = 3
  373. # A plugin has become unavailable.
  374. # @a pluginId Plugin Id
  375. # @a valueStr Related error string
  376. ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4
  377. # A parameter value has changed.
  378. # @a pluginId Plugin Id
  379. # @a value1 Parameter index
  380. # @a value3 New parameter value
  381. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5
  382. # A parameter default has changed.
  383. # @a pluginId Plugin Id
  384. # @a value1 Parameter index
  385. # @a value3 New default value
  386. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6
  387. # A parameter's MIDI CC has changed.
  388. # @a pluginId Plugin Id
  389. # @a value1 Parameter index
  390. # @a value2 New MIDI CC
  391. ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7
  392. # A parameter's MIDI channel has changed.
  393. # @a pluginId Plugin Id
  394. # @a value1 Parameter index
  395. # @a value2 New MIDI channel
  396. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8
  397. # A plugin option has changed.
  398. # @a pluginId Plugin Id
  399. # @a value1 Option
  400. # @a value2 New on/off state (1 for on, 0 for off)
  401. # @see PluginOptions
  402. ENGINE_CALLBACK_OPTION_CHANGED = 9
  403. # The current program of a plugin has changed.
  404. # @a pluginId Plugin Id
  405. # @a value1 New program index
  406. ENGINE_CALLBACK_PROGRAM_CHANGED = 10
  407. # The current MIDI program of a plugin has changed.
  408. # @a pluginId Plugin Id
  409. # @a value1 New MIDI program index
  410. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 11
  411. # A plugin's custom UI state has changed.
  412. # @a pluginId Plugin Id
  413. # @a value1 New state, as follows:
  414. # 0: UI is now hidden
  415. # 1: UI is now visible
  416. # -1: UI has crashed and should not be shown again
  417. ENGINE_CALLBACK_UI_STATE_CHANGED = 12
  418. # A note has been pressed.
  419. # @a pluginId Plugin Id
  420. # @a value1 Channel
  421. # @a value2 Note
  422. # @a value3 Velocity
  423. ENGINE_CALLBACK_NOTE_ON = 13
  424. # A note has been released.
  425. # @a pluginId Plugin Id
  426. # @a value1 Channel
  427. # @a value2 Note
  428. ENGINE_CALLBACK_NOTE_OFF = 14
  429. # A plugin needs update.
  430. # @a pluginId Plugin Id
  431. ENGINE_CALLBACK_UPDATE = 15
  432. # A plugin's data/information has changed.
  433. # @a pluginId Plugin Id
  434. ENGINE_CALLBACK_RELOAD_INFO = 16
  435. # A plugin's parameters have changed.
  436. # @a pluginId Plugin Id
  437. ENGINE_CALLBACK_RELOAD_PARAMETERS = 17
  438. # A plugin's programs have changed.
  439. # @a pluginId Plugin Id
  440. ENGINE_CALLBACK_RELOAD_PROGRAMS = 18
  441. # A plugin state has changed.
  442. # @a pluginId Plugin Id
  443. ENGINE_CALLBACK_RELOAD_ALL = 19
  444. # A patchbay client has been added.
  445. # @a pluginId Client Id
  446. # @a value1 Client icon
  447. # @a value2 Plugin Id (-1 if not a plugin)
  448. # @a valueStr Client name
  449. # @see PatchbayIcon
  450. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 20
  451. # A patchbay client has been removed.
  452. # @a pluginId Client Id
  453. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 21
  454. # A patchbay client has been renamed.
  455. # @a pluginId Client Id
  456. # @a valueStr New client name
  457. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 22
  458. # A patchbay client data has changed.
  459. # @a pluginId Client Id
  460. # @a value1 New icon
  461. # @a value2 New plugin Id (-1 if not a plugin)
  462. # @see PatchbayIcon
  463. ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 23
  464. # A patchbay port has been added.
  465. # @a pluginId Client Id
  466. # @a value1 Port Id
  467. # @a value2 Port hints
  468. # @a valueStr Port name
  469. # @see PatchbayPortHints
  470. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 24
  471. # A patchbay port has been removed.
  472. # @a pluginId Client Id
  473. # @a value1 Port Id
  474. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 25
  475. # A patchbay port has been renamed.
  476. # @a pluginId Client Id
  477. # @a value1 Port Id
  478. # @a valueStr New port name
  479. ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 26
  480. # A patchbay connection has been added.
  481. # @a pluginId Connection Id
  482. # @a valueStr Out group, port plus in group and port, in "og:op:ig:ip" syntax.
  483. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27
  484. # A patchbay connection has been removed.
  485. # @a pluginId Connection Id
  486. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28
  487. # Engine started.
  488. # @a value1 Process mode
  489. # @a value2 Transport mode
  490. # @a valuestr Engine driver
  491. # @see EngineProcessMode
  492. # @see EngineTransportMode
  493. ENGINE_CALLBACK_ENGINE_STARTED = 29
  494. # Engine stopped.
  495. ENGINE_CALLBACK_ENGINE_STOPPED = 30
  496. # Engine process mode has changed.
  497. # @a value1 New process mode
  498. # @see EngineProcessMode
  499. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31
  500. # Engine transport mode has changed.
  501. # @a value1 New transport mode
  502. # @see EngineTransportMode
  503. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32
  504. # Engine buffer-size changed.
  505. # @a value1 New buffer size
  506. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33
  507. # Engine sample-rate changed.
  508. # @a value3 New sample rate
  509. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34
  510. # Idle frontend.
  511. # This is used by the engine during long operations that might block the frontend,
  512. # giving it the possibility to idle while the operation is still in place.
  513. ENGINE_CALLBACK_IDLE = 35
  514. # Show a message as information.
  515. # @a valueStr The message
  516. ENGINE_CALLBACK_INFO = 36
  517. # Show a message as an error.
  518. # @a valueStr The message
  519. ENGINE_CALLBACK_ERROR = 37
  520. # The engine has crashed or malfunctioned and will no longer work.
  521. ENGINE_CALLBACK_QUIT = 38
  522. # ------------------------------------------------------------------------------------------------------------
  523. # Engine Option
  524. # Engine options.
  525. # @see carla_set_engine_option()
  526. # Debug.
  527. # This option is undefined and used only for testing purposes.
  528. ENGINE_OPTION_DEBUG = 0
  529. # Set the engine processing mode.
  530. # Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_CONTINUOUS_RACK for all other OSes.
  531. # @see EngineProcessMode
  532. ENGINE_OPTION_PROCESS_MODE = 1
  533. # Set the engine transport mode.
  534. # Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  535. # @see EngineTransportMode
  536. ENGINE_OPTION_TRANSPORT_MODE = 2
  537. # Force mono plugins as stereo, by running 2 instances at the same time.
  538. # Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  539. # @note Not supported by all plugins
  540. # @see PLUGIN_OPTION_FORCE_STEREO
  541. ENGINE_OPTION_FORCE_STEREO = 3
  542. # Use plugin bridges whenever possible.
  543. # Default is no, EXPERIMENTAL.
  544. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4
  545. # Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  546. # Default is yes.
  547. ENGINE_OPTION_PREFER_UI_BRIDGES = 5
  548. # Make custom plugin UIs always-on-top.
  549. # Default is yes.
  550. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6
  551. # Maximum number of parameters allowed.
  552. # Default is MAX_DEFAULT_PARAMETERS.
  553. ENGINE_OPTION_MAX_PARAMETERS = 7
  554. # Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  555. # Default is 4000 (4 seconds).
  556. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8
  557. # Number of audio periods.
  558. # Default is 2.
  559. ENGINE_OPTION_AUDIO_NUM_PERIODS = 9
  560. # Audio buffer size.
  561. # Default is 512.
  562. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10
  563. # Audio sample rate.
  564. # Default is 44100.
  565. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11
  566. # Audio device (within a driver).
  567. # Default unset.
  568. ENGINE_OPTION_AUDIO_DEVICE = 12
  569. # Set data needed for NSM support.
  570. ENGINE_OPTION_NSM_INIT = 13
  571. # Set path used for a specific plugin type.
  572. # Uses value as the plugin format, valueStr as actual path.
  573. # @see PluginType
  574. ENGINE_OPTION_PLUGIN_PATH = 14
  575. # Set path to the binary files.
  576. # Default unset.
  577. # @note Must be set for plugin and UI bridges to work
  578. ENGINE_OPTION_PATH_BINARIES = 15
  579. # Set path to the resource files.
  580. # Default unset.
  581. # @note Must be set for some internal plugins to work
  582. ENGINE_OPTION_PATH_RESOURCES = 16
  583. # Prevent bad plugin and UI behaviour.
  584. # @note: Linux only
  585. ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 17
  586. # Set frontend winId, used to define as parent window for plugin UIs.
  587. ENGINE_OPTION_FRONTEND_WIN_ID = 18
  588. # ------------------------------------------------------------------------------------------------------------
  589. # Engine Process Mode
  590. # Engine process mode.
  591. # @see ENGINE_OPTION_PROCESS_MODE
  592. # Single client mode.
  593. # Inputs and outputs are added dynamically as needed by plugins.
  594. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0
  595. # Multiple client mode.
  596. # It has 1 master client + 1 client per plugin.
  597. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1
  598. # Single client, 'rack' mode.
  599. # Processes plugins in order of Id, with forced stereo always on.
  600. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2
  601. # Single client, 'patchbay' mode.
  602. ENGINE_PROCESS_MODE_PATCHBAY = 3
  603. # Special mode, used in plugin-bridges only.
  604. ENGINE_PROCESS_MODE_BRIDGE = 4
  605. # ------------------------------------------------------------------------------------------------------------
  606. # Engine Transport Mode
  607. # Engine transport mode.
  608. # @see ENGINE_OPTION_TRANSPORT_MODE
  609. # Internal transport mode.
  610. ENGINE_TRANSPORT_MODE_INTERNAL = 0
  611. # Transport from JACK.
  612. # Only available if driver name is "JACK".
  613. ENGINE_TRANSPORT_MODE_JACK = 1
  614. # Transport from host, used when Carla is a plugin.
  615. ENGINE_TRANSPORT_MODE_PLUGIN = 2
  616. # Special mode, used in plugin-bridges only.
  617. ENGINE_TRANSPORT_MODE_BRIDGE = 3
  618. # ------------------------------------------------------------------------------------------------------------
  619. # File Callback Opcode
  620. # File callback opcodes.
  621. # Front-ends must always block-wait for user input.
  622. # @see FileCallbackFunc and carla_set_file_callback()
  623. # Debug.
  624. # This opcode is undefined and used only for testing purposes.
  625. FILE_CALLBACK_DEBUG = 0
  626. # Open file or folder.
  627. FILE_CALLBACK_OPEN = 1
  628. # Save file or folder.
  629. FILE_CALLBACK_SAVE = 2
  630. # ------------------------------------------------------------------------------------------------------------
  631. # Patchbay Icon
  632. # The icon of a patchbay client/group.
  633. # Generic application icon.
  634. # Used for all non-plugin clients that don't have a specific icon.
  635. PATCHBAY_ICON_APPLICATION = 0
  636. # Plugin icon.
  637. # Used for all plugin clients that don't have a specific icon.
  638. PATCHBAY_ICON_PLUGIN = 1
  639. # Hardware icon.
  640. # Used for hardware (audio or MIDI) clients.
  641. PATCHBAY_ICON_HARDWARE = 2
  642. # Carla icon.
  643. # Used for the main app.
  644. PATCHBAY_ICON_CARLA = 3
  645. # DISTRHO icon.
  646. # Used for DISTRHO based plugins.
  647. PATCHBAY_ICON_DISTRHO = 4
  648. # File icon.
  649. # Used for file type plugins (like GIG and SF2).
  650. PATCHBAY_ICON_FILE = 5
  651. # ------------------------------------------------------------------------------------------------------------
  652. # Carla Backend API (C stuff)
  653. # Engine callback function.
  654. # Front-ends must never block indefinitely during a callback.
  655. # @see EngineCallbackOpcode and carla_set_engine_callback()
  656. EngineCallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_float, c_char_p)
  657. # File callback function.
  658. # @see FileCallbackOpcode
  659. FileCallbackFunc = CFUNCTYPE(c_char_p, c_void_p, c_enum, c_bool, c_char_p, c_char_p)
  660. # Parameter data.
  661. class ParameterData(Structure):
  662. _fields_ = [
  663. # This parameter type.
  664. ("type", c_enum),
  665. # This parameter hints.
  666. # @see ParameterHints
  667. ("hints", c_uint),
  668. # Index as seen by Carla.
  669. ("index", c_int32),
  670. # Real index as seen by plugins.
  671. ("rindex", c_int32),
  672. # Currently mapped MIDI CC.
  673. # A value lower than 0 means invalid or unused.
  674. # Maximum allowed value is 119 (0x77).
  675. ("midiCC", c_int16),
  676. # Currently mapped MIDI channel.
  677. # Counts from 0 to 15.
  678. ("midiChannel", c_uint8)
  679. ]
  680. # Parameter ranges.
  681. class ParameterRanges(Structure):
  682. _fields_ = [
  683. # Default value.
  684. ("def", c_float),
  685. # Minimum value.
  686. ("min", c_float),
  687. # Maximum value.
  688. ("max", c_float),
  689. # Regular, single step value.
  690. ("step", c_float),
  691. # Small step value.
  692. ("stepSmall", c_float),
  693. # Large step value.
  694. ("stepLarge", c_float)
  695. ]
  696. # MIDI Program data.
  697. class MidiProgramData(Structure):
  698. _fields_ = [
  699. # MIDI bank.
  700. ("bank", c_uint32),
  701. # MIDI program.
  702. ("program", c_uint32),
  703. # MIDI program name.
  704. ("name", c_char_p)
  705. ]
  706. # Custom data, used for saving key:value 'dictionaries'.
  707. class CustomData(Structure):
  708. _fields_ = [
  709. # Value type, in URI form.
  710. # @see CustomDataTypes
  711. ("type", c_char_p),
  712. # Key.
  713. # @see CustomDataKeys
  714. ("key", c_char_p),
  715. # Value.
  716. ("value", c_char_p)
  717. ]
  718. # Engine driver device information.
  719. class EngineDriverDeviceInfo(Structure):
  720. _fields_ = [
  721. # This driver device hints.
  722. # @see EngineDriverHints
  723. ("hints", c_uint),
  724. # Available buffer sizes.
  725. # Terminated with 0.
  726. ("bufferSizes", POINTER(c_uint32)),
  727. # Available sample rates.
  728. # Terminated with 0.0.
  729. ("sampleRates", POINTER(c_double))
  730. ]
  731. # ------------------------------------------------------------------------------------------------------------
  732. # Carla Backend API (Python compatible stuff)
  733. # @see ParameterData
  734. PyParameterData = {
  735. 'type': PARAMETER_UNKNOWN,
  736. 'hints': 0x0,
  737. 'index': PARAMETER_NULL,
  738. 'rindex': -1,
  739. 'midiCC': -1,
  740. 'midiChannel': 0
  741. }
  742. # @see ParameterRanges
  743. PyParameterRanges = {
  744. 'def': 0.0,
  745. 'min': 0.0,
  746. 'max': 1.0,
  747. 'step': 0.01,
  748. 'stepSmall': 0.0001,
  749. 'stepLarge': 0.1
  750. }
  751. # @see MidiProgramData
  752. PyMidiProgramData = {
  753. 'bank': 0,
  754. 'program': 0,
  755. 'name': None
  756. }
  757. # @see CustomData
  758. PyCustomData = {
  759. 'type': None,
  760. 'key': None,
  761. 'value': None
  762. }
  763. # @see EngineDriverDeviceInfo
  764. PyEngineDriverDeviceInfo = {
  765. 'hints': 0x0,
  766. 'bufferSizes': [],
  767. 'sampleRates': []
  768. }
  769. # ------------------------------------------------------------------------------------------------------------
  770. # Carla Host API (C stuff)
  771. # Information about a loaded plugin.
  772. # @see carla_get_plugin_info()
  773. class CarlaPluginInfo(Structure):
  774. _fields_ = [
  775. # Plugin type.
  776. ("type", c_enum),
  777. # Plugin category.
  778. ("category", c_enum),
  779. # Plugin hints.
  780. # @see PluginHints
  781. ("hints", c_uint),
  782. # Plugin options available for the user to change.
  783. # @see PluginOptions
  784. ("optionsAvailable", c_uint),
  785. # Plugin options currently enabled.
  786. # Some options are enabled but not available, which means they will always be on.
  787. # @see PluginOptions
  788. ("optionsEnabled", c_uint),
  789. # Plugin filename.
  790. # This can be the plugin binary or resource file.
  791. ("filename", c_char_p),
  792. # Plugin name.
  793. # This name is unique within a Carla instance.
  794. # @see carla_get_real_plugin_name()
  795. ("name", c_char_p),
  796. # Plugin label or URI.
  797. ("label", c_char_p),
  798. # Plugin author/maker.
  799. ("maker", c_char_p),
  800. # Plugin copyright/license.
  801. ("copyright", c_char_p),
  802. # Icon name for this plugin, in lowercase.
  803. # Default is "plugin".
  804. ("iconName", c_char_p),
  805. # Plugin unique Id.
  806. # This Id is dependant on the plugin type and may sometimes be 0.
  807. ("uniqueId", c_int64)
  808. ]
  809. # Port count information, used for Audio and MIDI ports and parameters.
  810. # @see carla_get_audio_port_count_info()
  811. # @see carla_get_midi_port_count_info()
  812. # @see carla_get_parameter_count_info()
  813. class CarlaPortCountInfo(Structure):
  814. _fields_ = [
  815. # Number of inputs.
  816. ("ins", c_uint32),
  817. # Number of outputs.
  818. ("outs", c_uint32)
  819. ]
  820. # Parameter information.
  821. # @see carla_get_parameter_info()
  822. class CarlaParameterInfo(Structure):
  823. _fields_ = [
  824. # Parameter name.
  825. ("name", c_char_p),
  826. # Parameter symbol.
  827. ("symbol", c_char_p),
  828. # Parameter unit.
  829. ("unit", c_char_p),
  830. # Number of scale points.
  831. # @see CarlaScalePointInfo
  832. ("scalePointCount", c_uint32)
  833. ]
  834. # Parameter scale point information.
  835. # @see carla_get_parameter_scalepoint_info()
  836. class CarlaScalePointInfo(Structure):
  837. _fields_ = [
  838. # Scale point value.
  839. ("value", c_float),
  840. # Scale point label.
  841. ("label", c_char_p)
  842. ]
  843. # Transport information.
  844. # @see carla_get_transport_info()
  845. class CarlaTransportInfo(Structure):
  846. _fields_ = [
  847. # Wherever transport is playing.
  848. ("playing", c_bool),
  849. # Current transport frame.
  850. ("frame", c_uint64),
  851. # Bar
  852. ("bar", c_int32),
  853. # Beat
  854. ("beat", c_int32),
  855. # Tick
  856. ("tick", c_int32),
  857. # Beats per minute.
  858. ("bpm", c_double)
  859. ]
  860. # ------------------------------------------------------------------------------------------------------------
  861. # Carla Host API (Python compatible stuff)
  862. # @see CarlaPluginInfo
  863. PyCarlaPluginInfo = {
  864. 'type': PLUGIN_NONE,
  865. 'category': PLUGIN_CATEGORY_NONE,
  866. 'hints': 0x0,
  867. 'optionsAvailable': 0x0,
  868. 'optionsEnabled': 0x0,
  869. 'filename': "",
  870. 'name': "",
  871. 'label': "",
  872. 'maker': "",
  873. 'copyright': "",
  874. 'iconName': "",
  875. 'uniqueId': 0
  876. }
  877. # @see CarlaPortCountInfo
  878. PyCarlaPortCountInfo = {
  879. 'ins': 0,
  880. 'outs': 0
  881. }
  882. # @see CarlaParameterInfo
  883. PyCarlaParameterInfo = {
  884. 'name': "",
  885. 'symbol': "",
  886. 'unit': "",
  887. 'scalePointCount': 0,
  888. }
  889. # @see CarlaScalePointInfo
  890. PyCarlaScalePointInfo = {
  891. 'value': 0.0,
  892. 'label': ""
  893. }
  894. # @see CarlaTransportInfo
  895. PyCarlaTransportInfo = {
  896. "playing": False,
  897. "frame": 0,
  898. "bar": 0,
  899. "beat": 0,
  900. "tick": 0,
  901. "bpm": 0.0
  902. }
  903. # ------------------------------------------------------------------------------------------------------------
  904. # Set BINARY_NATIVE
  905. if HAIKU or LINUX or MACOS:
  906. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  907. elif WINDOWS:
  908. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  909. else:
  910. BINARY_NATIVE = BINARY_OTHER
  911. # ------------------------------------------------------------------------------------------------------------
  912. # Carla Host object (Meta)
  913. class CarlaHostMeta(object):
  914. #class CarlaHostMeta(object, metaclass=ABCMeta):
  915. def __init__(self):
  916. object.__init__(self)
  917. # info about this host object
  918. self.isControl = False
  919. self.isPlugin = False
  920. # settings
  921. self.processMode = ENGINE_PROCESS_MODE_CONTINUOUS_RACK
  922. self.transportMode = ENGINE_TRANSPORT_MODE_INTERNAL
  923. self.nextProcessMode = ENGINE_PROCESS_MODE_CONTINUOUS_RACK
  924. self.processModeForced = False
  925. # settings
  926. self.forceStereo = False
  927. self.preferPluginBridges = False
  928. self.preferUIBridges = False
  929. self.preventBadBehaviour = False
  930. self.uisAlwaysOnTop = False
  931. self.maxParameters = 0
  932. self.uiBridgesTimeout = 0
  933. # settings
  934. self.pathBinaries = ""
  935. self.pathResources = ""
  936. # Get how many engine drivers are available.
  937. @abstractmethod
  938. def get_engine_driver_count(self):
  939. raise NotImplementedError
  940. # Get an engine driver name.
  941. # @param index Driver index
  942. @abstractmethod
  943. def get_engine_driver_name(self, index):
  944. raise NotImplementedError
  945. # Get the device names of an engine driver.
  946. # @param index Driver index
  947. @abstractmethod
  948. def get_engine_driver_device_names(self, index):
  949. raise NotImplementedError
  950. # Get information about a device driver.
  951. # @param index Driver index
  952. # @param name Device name
  953. @abstractmethod
  954. def get_engine_driver_device_info(self, index, name):
  955. raise NotImplementedError
  956. # Initialize the engine.
  957. # Make sure to call carla_engine_idle() at regular intervals afterwards.
  958. # @param driverName Driver to use
  959. # @param clientName Engine master client name
  960. @abstractmethod
  961. def engine_init(self, driverName, clientName):
  962. raise NotImplementedError
  963. # Close the engine.
  964. # This function always closes the engine even if it returns false.
  965. # In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
  966. @abstractmethod
  967. def engine_close(self):
  968. raise NotImplementedError
  969. # Idle the engine.
  970. # Do not call this if the engine is not running.
  971. @abstractmethod
  972. def engine_idle(self):
  973. raise NotImplementedError
  974. # Check if the engine is running.
  975. @abstractmethod
  976. def is_engine_running(self):
  977. raise NotImplementedError
  978. # Tell the engine it's about to close.
  979. # This is used to prevent the engine thread(s) from reactivating.
  980. @abstractmethod
  981. def set_engine_about_to_close(self):
  982. raise NotImplementedError
  983. # Set the engine callback function.
  984. # @param func Callback function
  985. @abstractmethod
  986. def set_engine_callback(self, func):
  987. raise NotImplementedError
  988. # Set an engine option.
  989. # @param option Option
  990. # @param value Value as number
  991. # @param valueStr Value as string
  992. @abstractmethod
  993. def set_engine_option(self, option, value, valueStr):
  994. raise NotImplementedError
  995. # Set the file callback function.
  996. # @param func Callback function
  997. # @param ptr Callback pointer
  998. @abstractmethod
  999. def set_file_callback(self, func):
  1000. raise NotImplementedError
  1001. # Load a file of any type.
  1002. # This will try to load a generic file as a plugin,
  1003. # either by direct handling (GIG, SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
  1004. # @see carla_get_supported_file_extensions()
  1005. @abstractmethod
  1006. def load_file(self, filename):
  1007. raise NotImplementedError
  1008. # Load a Carla project file.
  1009. # @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
  1010. @abstractmethod
  1011. def load_project(self, filename):
  1012. raise NotImplementedError
  1013. # Save current project to a file.
  1014. @abstractmethod
  1015. def save_project(self, filename):
  1016. raise NotImplementedError
  1017. # Connect two patchbay ports.
  1018. # @param groupIdA Output group
  1019. # @param portIdA Output port
  1020. # @param groupIdB Input group
  1021. # @param portIdB Input port
  1022. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
  1023. @abstractmethod
  1024. def patchbay_connect(self, groupIdA, portIdA, groupIdB, portIdB):
  1025. raise NotImplementedError
  1026. # Disconnect two patchbay ports.
  1027. # @param connectionId Connection Id
  1028. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
  1029. @abstractmethod
  1030. def patchbay_disconnect(self, connectionId):
  1031. raise NotImplementedError
  1032. # Force the engine to resend all patchbay clients, ports and connections again.
  1033. # @param external Wherever to show external/hardware ports instead of internal ones.
  1034. # Only valid in patchbay engine mode, other modes will ignore this.
  1035. @abstractmethod
  1036. def patchbay_refresh(self, external):
  1037. raise NotImplementedError
  1038. # Start playback of the engine transport.
  1039. @abstractmethod
  1040. def transport_play(self):
  1041. raise NotImplementedError
  1042. # Pause the engine transport.
  1043. @abstractmethod
  1044. def transport_pause(self):
  1045. raise NotImplementedError
  1046. # Relocate the engine transport to a specific frame.
  1047. @abstractmethod
  1048. def transport_relocate(self, frame):
  1049. raise NotImplementedError
  1050. # Get the current transport frame.
  1051. @abstractmethod
  1052. def get_current_transport_frame(self):
  1053. raise NotImplementedError
  1054. # Get the engine transport information.
  1055. @abstractmethod
  1056. def get_transport_info(self):
  1057. raise NotImplementedError
  1058. # Current number of plugins loaded.
  1059. @abstractmethod
  1060. def get_current_plugin_count(self):
  1061. raise NotImplementedError
  1062. # Maximum number of loadable plugins allowed.
  1063. # Returns 0 if engine is not started.
  1064. @abstractmethod
  1065. def get_max_plugin_number(self):
  1066. raise NotImplementedError
  1067. # Add a new plugin.
  1068. # If you don't know the binary type use the BINARY_NATIVE macro.
  1069. # @param btype Binary type
  1070. # @param ptype Plugin type
  1071. # @param filename Filename, if applicable
  1072. # @param name Name of the plugin, can be NULL
  1073. # @param label Plugin label, if applicable
  1074. # @param uniqueId Plugin unique Id, if applicable
  1075. # @param extraPtr Extra pointer, defined per plugin type
  1076. @abstractmethod
  1077. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr):
  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):
  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]
  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):
  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)))
  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):
  2080. return self.sendMsgAndSetError(["add_plugin", btype, ptype, filename, name, label, uniqueId])
  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. # ------------------------------------------------------------------------------------------------------------