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.

3635 lines
115KB

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