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.

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