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.

3151 lines
99KB

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