Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3635 lines
115KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla Backend code
  4. # Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. from abc import ABCMeta, abstractmethod
  20. from ctypes import *
  21. from platform import architecture
  22. from 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 frontend winId, used to define as parent window for plugin UIs.
  658. ENGINE_OPTION_FRONTEND_WIN_ID = 20
  659. # Set path to wine executable.
  660. ENGINE_OPTION_WINE_EXECUTABLE = 21
  661. # Enable automatic wineprefix detection.
  662. ENGINE_OPTION_WINE_AUTO_PREFIX = 22
  663. # Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set.
  664. ENGINE_OPTION_WINE_FALLBACK_PREFIX = 23
  665. # Enable realtime priority for Wine application and server threads.
  666. ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 24
  667. # Base realtime priority for Wine threads.
  668. ENGINE_OPTION_WINE_BASE_RT_PRIO = 25
  669. # Wine server realtime priority.
  670. ENGINE_OPTION_WINE_SERVER_RT_PRIO = 26
  671. # Capture console output into debug callbacks
  672. ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 27
  673. # ------------------------------------------------------------------------------------------------------------
  674. # Engine Process Mode
  675. # Engine process mode.
  676. # @see ENGINE_OPTION_PROCESS_MODE
  677. # Single client mode.
  678. # Inputs and outputs are added dynamically as needed by plugins.
  679. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0
  680. # Multiple client mode.
  681. # It has 1 master client + 1 client per plugin.
  682. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1
  683. # Single client, 'rack' mode.
  684. # Processes plugins in order of Id, with forced stereo always on.
  685. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2
  686. # Single client, 'patchbay' mode.
  687. ENGINE_PROCESS_MODE_PATCHBAY = 3
  688. # Special mode, used in plugin-bridges only.
  689. ENGINE_PROCESS_MODE_BRIDGE = 4
  690. # ------------------------------------------------------------------------------------------------------------
  691. # Engine Transport Mode
  692. # Engine transport mode.
  693. # @see ENGINE_OPTION_TRANSPORT_MODE
  694. # No transport.
  695. ENGINE_TRANSPORT_MODE_DISABLED = 0
  696. # Internal transport mode.
  697. ENGINE_TRANSPORT_MODE_INTERNAL = 1
  698. # Transport from JACK.
  699. # Only available if driver name is "JACK".
  700. ENGINE_TRANSPORT_MODE_JACK = 2
  701. # Transport from host, used when Carla is a plugin.
  702. ENGINE_TRANSPORT_MODE_PLUGIN = 3
  703. # Special mode, used in plugin-bridges only.
  704. ENGINE_TRANSPORT_MODE_BRIDGE = 4
  705. # ------------------------------------------------------------------------------------------------------------
  706. # File Callback Opcode
  707. # File callback opcodes.
  708. # Front-ends must always block-wait for user input.
  709. # @see FileCallbackFunc and carla_set_file_callback()
  710. # Debug.
  711. # This opcode is undefined and used only for testing purposes.
  712. FILE_CALLBACK_DEBUG = 0
  713. # Open file or folder.
  714. FILE_CALLBACK_OPEN = 1
  715. # Save file or folder.
  716. FILE_CALLBACK_SAVE = 2
  717. # ------------------------------------------------------------------------------------------------------------
  718. # Patchbay Icon
  719. # The icon of a patchbay client/group.
  720. # Generic application icon.
  721. # Used for all non-plugin clients that don't have a specific icon.
  722. PATCHBAY_ICON_APPLICATION = 0
  723. # Plugin icon.
  724. # Used for all plugin clients that don't have a specific icon.
  725. PATCHBAY_ICON_PLUGIN = 1
  726. # Hardware icon.
  727. # Used for hardware (audio or MIDI) clients.
  728. PATCHBAY_ICON_HARDWARE = 2
  729. # Carla icon.
  730. # Used for the main app.
  731. PATCHBAY_ICON_CARLA = 3
  732. # DISTRHO icon.
  733. # Used for DISTRHO based plugins.
  734. PATCHBAY_ICON_DISTRHO = 4
  735. # File icon.
  736. # Used for file type plugins (like SF2 and SFZ).
  737. PATCHBAY_ICON_FILE = 5
  738. # ------------------------------------------------------------------------------------------------------------
  739. # Carla Backend API (C stuff)
  740. # Engine callback function.
  741. # Front-ends must never block indefinitely during a callback.
  742. # @see EngineCallbackOpcode and carla_set_engine_callback()
  743. EngineCallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_int, c_float, c_char_p)
  744. # File callback function.
  745. # @see FileCallbackOpcode
  746. FileCallbackFunc = CFUNCTYPE(c_char_p, c_void_p, c_enum, c_bool, c_char_p, c_char_p)
  747. # Parameter data.
  748. class ParameterData(Structure):
  749. _fields_ = [
  750. # This parameter type.
  751. ("type", c_enum),
  752. # This parameter hints.
  753. # @see ParameterHints
  754. ("hints", c_uint),
  755. # Index as seen by Carla.
  756. ("index", c_int32),
  757. # Real index as seen by plugins.
  758. ("rindex", c_int32),
  759. # Currently mapped MIDI CC.
  760. # A value lower than 0 means invalid or unused.
  761. # Maximum allowed value is 119 (0x77).
  762. ("midiCC", c_int16),
  763. # Currently mapped MIDI channel.
  764. # Counts from 0 to 15.
  765. ("midiChannel", c_uint8)
  766. ]
  767. # Parameter ranges.
  768. class ParameterRanges(Structure):
  769. _fields_ = [
  770. # Default value.
  771. ("def", c_float),
  772. # Minimum value.
  773. ("min", c_float),
  774. # Maximum value.
  775. ("max", c_float),
  776. # Regular, single step value.
  777. ("step", c_float),
  778. # Small step value.
  779. ("stepSmall", c_float),
  780. # Large step value.
  781. ("stepLarge", c_float)
  782. ]
  783. # MIDI Program data.
  784. class MidiProgramData(Structure):
  785. _fields_ = [
  786. # MIDI bank.
  787. ("bank", c_uint32),
  788. # MIDI program.
  789. ("program", c_uint32),
  790. # MIDI program name.
  791. ("name", c_char_p)
  792. ]
  793. # Custom data, used for saving key:value 'dictionaries'.
  794. class CustomData(Structure):
  795. _fields_ = [
  796. # Value type, in URI form.
  797. # @see CustomDataTypes
  798. ("type", c_char_p),
  799. # Key.
  800. # @see CustomDataKeys
  801. ("key", c_char_p),
  802. # Value.
  803. ("value", c_char_p)
  804. ]
  805. # Engine driver device information.
  806. class EngineDriverDeviceInfo(Structure):
  807. _fields_ = [
  808. # This driver device hints.
  809. # @see EngineDriverHints
  810. ("hints", c_uint),
  811. # Available buffer sizes.
  812. # Terminated with 0.
  813. ("bufferSizes", POINTER(c_uint32)),
  814. # Available sample rates.
  815. # Terminated with 0.0.
  816. ("sampleRates", POINTER(c_double))
  817. ]
  818. # ------------------------------------------------------------------------------------------------------------
  819. # Carla Backend API (Python compatible stuff)
  820. # @see ParameterData
  821. PyParameterData = {
  822. 'type': PARAMETER_UNKNOWN,
  823. 'hints': 0x0,
  824. 'index': PARAMETER_NULL,
  825. 'rindex': -1,
  826. 'midiCC': -1,
  827. 'midiChannel': 0
  828. }
  829. # @see ParameterRanges
  830. PyParameterRanges = {
  831. 'def': 0.0,
  832. 'min': 0.0,
  833. 'max': 1.0,
  834. 'step': 0.01,
  835. 'stepSmall': 0.0001,
  836. 'stepLarge': 0.1
  837. }
  838. # @see MidiProgramData
  839. PyMidiProgramData = {
  840. 'bank': 0,
  841. 'program': 0,
  842. 'name': None
  843. }
  844. # @see CustomData
  845. PyCustomData = {
  846. 'type': None,
  847. 'key': None,
  848. 'value': None
  849. }
  850. # @see EngineDriverDeviceInfo
  851. PyEngineDriverDeviceInfo = {
  852. 'hints': 0x0,
  853. 'bufferSizes': [],
  854. 'sampleRates': []
  855. }
  856. # ------------------------------------------------------------------------------------------------------------
  857. # Carla Host API (C stuff)
  858. # Information about a loaded plugin.
  859. # @see carla_get_plugin_info()
  860. class CarlaPluginInfo(Structure):
  861. _fields_ = [
  862. # Plugin type.
  863. ("type", c_enum),
  864. # Plugin category.
  865. ("category", c_enum),
  866. # Plugin hints.
  867. # @see PluginHints
  868. ("hints", c_uint),
  869. # Plugin options available for the user to change.
  870. # @see PluginOptions
  871. ("optionsAvailable", c_uint),
  872. # Plugin options currently enabled.
  873. # Some options are enabled but not available, which means they will always be on.
  874. # @see PluginOptions
  875. ("optionsEnabled", c_uint),
  876. # Plugin filename.
  877. # This can be the plugin binary or resource file.
  878. ("filename", c_char_p),
  879. # Plugin name.
  880. # This name is unique within a Carla instance.
  881. # @see carla_get_real_plugin_name()
  882. ("name", c_char_p),
  883. # Plugin label or URI.
  884. ("label", c_char_p),
  885. # Plugin author/maker.
  886. ("maker", c_char_p),
  887. # Plugin copyright/license.
  888. ("copyright", c_char_p),
  889. # Icon name for this plugin, in lowercase.
  890. # Default is "plugin".
  891. ("iconName", c_char_p),
  892. # Plugin unique Id.
  893. # This Id is dependant on the plugin type and may sometimes be 0.
  894. ("uniqueId", c_int64)
  895. ]
  896. # Port count information, used for Audio and MIDI ports and parameters.
  897. # @see carla_get_audio_port_count_info()
  898. # @see carla_get_midi_port_count_info()
  899. # @see carla_get_parameter_count_info()
  900. class CarlaPortCountInfo(Structure):
  901. _fields_ = [
  902. # Number of inputs.
  903. ("ins", c_uint32),
  904. # Number of outputs.
  905. ("outs", c_uint32)
  906. ]
  907. # Parameter information.
  908. # @see carla_get_parameter_info()
  909. class CarlaParameterInfo(Structure):
  910. _fields_ = [
  911. # Parameter name.
  912. ("name", c_char_p),
  913. # Parameter symbol.
  914. ("symbol", c_char_p),
  915. # Parameter unit.
  916. ("unit", c_char_p),
  917. # Number of scale points.
  918. # @see CarlaScalePointInfo
  919. ("scalePointCount", c_uint32)
  920. ]
  921. # Parameter scale point information.
  922. # @see carla_get_parameter_scalepoint_info()
  923. class CarlaScalePointInfo(Structure):
  924. _fields_ = [
  925. # Scale point value.
  926. ("value", c_float),
  927. # Scale point label.
  928. ("label", c_char_p)
  929. ]
  930. # Transport information.
  931. # @see carla_get_transport_info()
  932. class CarlaTransportInfo(Structure):
  933. _fields_ = [
  934. # Wherever transport is playing.
  935. ("playing", c_bool),
  936. # Current transport frame.
  937. ("frame", c_uint64),
  938. # Bar
  939. ("bar", c_int32),
  940. # Beat
  941. ("beat", c_int32),
  942. # Tick
  943. ("tick", c_int32),
  944. # Beats per minute.
  945. ("bpm", c_double)
  946. ]
  947. # Runtime engine information.
  948. class CarlaRuntimeEngineInfo(Structure):
  949. _fields_ = [
  950. # DSP load.
  951. ("load", c_float),
  952. # Number of xruns.
  953. ("xruns", c_uint32)
  954. ]
  955. # Image data for LV2 inline display API.
  956. # raw image pixmap format is ARGB32,
  957. class CarlaInlineDisplayImageSurface(Structure):
  958. _fields_ = [
  959. ("data", POINTER(c_ubyte)),
  960. ("width", c_int),
  961. ("height", c_int),
  962. ("stride", c_int)
  963. ]
  964. # ------------------------------------------------------------------------------------------------------------
  965. # Carla Host API (Python compatible stuff)
  966. # @see CarlaPluginInfo
  967. PyCarlaPluginInfo = {
  968. 'type': PLUGIN_NONE,
  969. 'category': PLUGIN_CATEGORY_NONE,
  970. 'hints': 0x0,
  971. 'optionsAvailable': 0x0,
  972. 'optionsEnabled': 0x0,
  973. 'filename': "",
  974. 'name': "",
  975. 'label': "",
  976. 'maker': "",
  977. 'copyright': "",
  978. 'iconName': "",
  979. 'uniqueId': 0
  980. }
  981. # @see CarlaPortCountInfo
  982. PyCarlaPortCountInfo = {
  983. 'ins': 0,
  984. 'outs': 0
  985. }
  986. # @see CarlaParameterInfo
  987. PyCarlaParameterInfo = {
  988. 'name': "",
  989. 'symbol': "",
  990. 'unit': "",
  991. 'scalePointCount': 0,
  992. }
  993. # @see CarlaScalePointInfo
  994. PyCarlaScalePointInfo = {
  995. 'value': 0.0,
  996. 'label': ""
  997. }
  998. # @see CarlaTransportInfo
  999. PyCarlaTransportInfo = {
  1000. "playing": False,
  1001. "frame": 0,
  1002. "bar": 0,
  1003. "beat": 0,
  1004. "tick": 0,
  1005. "bpm": 0.0
  1006. }
  1007. # @see CarlaRuntimeEngineInfo
  1008. PyCarlaRuntimeEngineInfo = {
  1009. "load": 0.0,
  1010. "xruns": 0
  1011. }
  1012. # ------------------------------------------------------------------------------------------------------------
  1013. # Set BINARY_NATIVE
  1014. if WINDOWS:
  1015. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  1016. else:
  1017. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  1018. # ------------------------------------------------------------------------------------------------------------
  1019. # Carla Host object (Meta)
  1020. class CarlaHostMeta(object):
  1021. #class CarlaHostMeta(object, metaclass=ABCMeta):
  1022. def __init__(self):
  1023. object.__init__(self)
  1024. # info about this host object
  1025. self.isControl = False
  1026. self.isPlugin = False
  1027. self.isRemote = False
  1028. self.nsmOK = False
  1029. # settings
  1030. self.processMode = ENGINE_PROCESS_MODE_PATCHBAY
  1031. self.transportMode = ENGINE_TRANSPORT_MODE_INTERNAL
  1032. self.transportExtra = ""
  1033. self.nextProcessMode = self.processMode
  1034. self.processModeForced = False
  1035. self.audioDriverForced = None
  1036. # settings
  1037. self.experimental = False
  1038. self.exportLV2 = False
  1039. self.forceStereo = False
  1040. self.manageUIs = False
  1041. self.maxParameters = 0
  1042. self.preferPluginBridges = False
  1043. self.preferUIBridges = False
  1044. self.preventBadBehaviour = False
  1045. self.showLogs = False
  1046. self.showPluginBridges = False
  1047. self.showWineBridges = False
  1048. self.uiBridgesTimeout = 0
  1049. self.uisAlwaysOnTop = False
  1050. # settings
  1051. self.pathBinaries = ""
  1052. self.pathResources = ""
  1053. # Get how many engine drivers are available.
  1054. @abstractmethod
  1055. def get_engine_driver_count(self):
  1056. raise NotImplementedError
  1057. # Get an engine driver name.
  1058. # @param index Driver index
  1059. @abstractmethod
  1060. def get_engine_driver_name(self, index):
  1061. raise NotImplementedError
  1062. # Get the device names of an engine driver.
  1063. # @param index Driver index
  1064. @abstractmethod
  1065. def get_engine_driver_device_names(self, index):
  1066. raise NotImplementedError
  1067. # Get information about a device driver.
  1068. # @param index Driver index
  1069. # @param name Device name
  1070. @abstractmethod
  1071. def get_engine_driver_device_info(self, index, name):
  1072. raise NotImplementedError
  1073. # Initialize the engine.
  1074. # Make sure to call carla_engine_idle() at regular intervals afterwards.
  1075. # @param driverName Driver to use
  1076. # @param clientName Engine master client name
  1077. @abstractmethod
  1078. def engine_init(self, driverName, clientName):
  1079. raise NotImplementedError
  1080. # Close the engine.
  1081. # This function always closes the engine even if it returns false.
  1082. # In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
  1083. @abstractmethod
  1084. def engine_close(self):
  1085. raise NotImplementedError
  1086. # Idle the engine.
  1087. # Do not call this if the engine is not running.
  1088. @abstractmethod
  1089. def engine_idle(self):
  1090. raise NotImplementedError
  1091. # Check if the engine is running.
  1092. @abstractmethod
  1093. def is_engine_running(self):
  1094. raise NotImplementedError
  1095. # Get information about the currently running engine.
  1096. @abstractmethod
  1097. def get_runtime_engine_info(self):
  1098. raise NotImplementedError
  1099. # Clear the xrun count on the engine, so that the next time carla_get_runtime_engine_info() is called, it returns 0.
  1100. @abstractmethod
  1101. def clear_engine_xruns(self):
  1102. raise NotImplementedError
  1103. # Tell the engine to stop the current cancelable action.
  1104. # @see ENGINE_CALLBACK_CANCELABLE_ACTION
  1105. @abstractmethod
  1106. def cancel_engine_action(self):
  1107. raise NotImplementedError
  1108. # Tell the engine it's about to close.
  1109. # This is used to prevent the engine thread(s) from reactivating.
  1110. @abstractmethod
  1111. def set_engine_about_to_close(self):
  1112. raise NotImplementedError
  1113. # Set the engine callback function.
  1114. # @param func Callback function
  1115. @abstractmethod
  1116. def set_engine_callback(self, func):
  1117. raise NotImplementedError
  1118. # Set an engine option.
  1119. # @param option Option
  1120. # @param value Value as number
  1121. # @param valueStr Value as string
  1122. @abstractmethod
  1123. def set_engine_option(self, option, value, valueStr):
  1124. raise NotImplementedError
  1125. # Set the file callback function.
  1126. # @param func Callback function
  1127. # @param ptr Callback pointer
  1128. @abstractmethod
  1129. def set_file_callback(self, func):
  1130. raise NotImplementedError
  1131. # Load a file of any type.
  1132. # This will try to load a generic file as a plugin,
  1133. # either by direct handling (SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
  1134. # @see carla_get_supported_file_extensions()
  1135. @abstractmethod
  1136. def load_file(self, filename):
  1137. raise NotImplementedError
  1138. # Load a Carla project file.
  1139. # @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
  1140. @abstractmethod
  1141. def load_project(self, filename):
  1142. raise NotImplementedError
  1143. # Save current project to a file.
  1144. @abstractmethod
  1145. def save_project(self, filename):
  1146. raise NotImplementedError
  1147. # Clear the currently set project filename.
  1148. @abstractmethod
  1149. def clear_project_filename(self):
  1150. raise NotImplementedError
  1151. # Connect two patchbay ports.
  1152. # @param groupIdA Output group
  1153. # @param portIdA Output port
  1154. # @param groupIdB Input group
  1155. # @param portIdB Input port
  1156. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
  1157. @abstractmethod
  1158. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  1159. raise NotImplementedError
  1160. # Disconnect two patchbay ports.
  1161. # @param connectionId Connection Id
  1162. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
  1163. @abstractmethod
  1164. def patchbay_disconnect(self, external, connectionId):
  1165. raise NotImplementedError
  1166. # Force the engine to resend all patchbay clients, ports and connections again.
  1167. # @param external Wherever to show external/hardware ports instead of internal ones.
  1168. # Only valid in patchbay engine mode, other modes will ignore this.
  1169. @abstractmethod
  1170. def patchbay_refresh(self, external):
  1171. raise NotImplementedError
  1172. # Start playback of the engine transport.
  1173. @abstractmethod
  1174. def transport_play(self):
  1175. raise NotImplementedError
  1176. # Pause the engine transport.
  1177. @abstractmethod
  1178. def transport_pause(self):
  1179. raise NotImplementedError
  1180. # Pause the engine transport.
  1181. @abstractmethod
  1182. def transport_bpm(self, bpm):
  1183. raise NotImplementedError
  1184. # Relocate the engine transport to a specific frame.
  1185. @abstractmethod
  1186. def transport_relocate(self, frame):
  1187. raise NotImplementedError
  1188. # Get the current transport frame.
  1189. @abstractmethod
  1190. def get_current_transport_frame(self):
  1191. raise NotImplementedError
  1192. # Get the engine transport information.
  1193. @abstractmethod
  1194. def get_transport_info(self):
  1195. raise NotImplementedError
  1196. # Current number of plugins loaded.
  1197. @abstractmethod
  1198. def get_current_plugin_count(self):
  1199. raise NotImplementedError
  1200. # Maximum number of loadable plugins allowed.
  1201. # Returns 0 if engine is not started.
  1202. @abstractmethod
  1203. def get_max_plugin_number(self):
  1204. raise NotImplementedError
  1205. # Add a new plugin.
  1206. # If you don't know the binary type use the BINARY_NATIVE macro.
  1207. # @param btype Binary type
  1208. # @param ptype Plugin type
  1209. # @param filename Filename, if applicable
  1210. # @param name Name of the plugin, can be NULL
  1211. # @param label Plugin label, if applicable
  1212. # @param uniqueId Plugin unique Id, if applicable
  1213. # @param extraPtr Extra pointer, defined per plugin type
  1214. # @param options Initial plugin options
  1215. @abstractmethod
  1216. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  1217. raise NotImplementedError
  1218. # Remove a plugin.
  1219. # @param pluginId Plugin to remove.
  1220. @abstractmethod
  1221. def remove_plugin(self, pluginId):
  1222. raise NotImplementedError
  1223. # Remove all plugins.
  1224. @abstractmethod
  1225. def remove_all_plugins(self):
  1226. raise NotImplementedError
  1227. # Rename a plugin.
  1228. # Returns the new name, or NULL if the operation failed.
  1229. # @param pluginId Plugin to rename
  1230. # @param newName New plugin name
  1231. @abstractmethod
  1232. def rename_plugin(self, pluginId, newName):
  1233. raise NotImplementedError
  1234. # Clone a plugin.
  1235. # @param pluginId Plugin to clone
  1236. @abstractmethod
  1237. def clone_plugin(self, pluginId):
  1238. raise NotImplementedError
  1239. # Prepare replace of a plugin.
  1240. # The next call to carla_add_plugin() will use this id, replacing the current plugin.
  1241. # @param pluginId Plugin to replace
  1242. # @note This function requires carla_add_plugin() to be called afterwards *as soon as possible*.
  1243. @abstractmethod
  1244. def replace_plugin(self, pluginId):
  1245. raise NotImplementedError
  1246. # Switch two plugins positions.
  1247. # @param pluginIdA Plugin A
  1248. # @param pluginIdB Plugin B
  1249. @abstractmethod
  1250. def switch_plugins(self, pluginIdA, pluginIdB):
  1251. raise NotImplementedError
  1252. # Load a plugin state.
  1253. # @param pluginId Plugin
  1254. # @param filename Path to plugin state
  1255. # @see carla_save_plugin_state()
  1256. @abstractmethod
  1257. def load_plugin_state(self, pluginId, filename):
  1258. raise NotImplementedError
  1259. # Save a plugin state.
  1260. # @param pluginId Plugin
  1261. # @param filename Path to plugin state
  1262. # @see carla_load_plugin_state()
  1263. @abstractmethod
  1264. def save_plugin_state(self, pluginId, filename):
  1265. raise NotImplementedError
  1266. # Export plugin as LV2.
  1267. # @param pluginId Plugin
  1268. # @param lv2path Path to lv2 plugin folder
  1269. def export_plugin_lv2(self, pluginId, lv2path):
  1270. raise NotImplementedError
  1271. # Get information from a plugin.
  1272. # @param pluginId Plugin
  1273. @abstractmethod
  1274. def get_plugin_info(self, pluginId):
  1275. raise NotImplementedError
  1276. # Get audio port count information from a plugin.
  1277. # @param pluginId Plugin
  1278. @abstractmethod
  1279. def get_audio_port_count_info(self, pluginId):
  1280. raise NotImplementedError
  1281. # Get MIDI port count information from a plugin.
  1282. # @param pluginId Plugin
  1283. @abstractmethod
  1284. def get_midi_port_count_info(self, pluginId):
  1285. raise NotImplementedError
  1286. # Get parameter count information from a plugin.
  1287. # @param pluginId Plugin
  1288. @abstractmethod
  1289. def get_parameter_count_info(self, pluginId):
  1290. raise NotImplementedError
  1291. # Get parameter information from a plugin.
  1292. # @param pluginId Plugin
  1293. # @param parameterId Parameter index
  1294. # @see carla_get_parameter_count()
  1295. @abstractmethod
  1296. def get_parameter_info(self, pluginId, parameterId):
  1297. raise NotImplementedError
  1298. # Get parameter scale point information from a plugin.
  1299. # @param pluginId Plugin
  1300. # @param parameterId Parameter index
  1301. # @param scalePointId Parameter scale-point index
  1302. # @see CarlaParameterInfo::scalePointCount
  1303. @abstractmethod
  1304. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  1305. raise NotImplementedError
  1306. # Get a plugin's parameter data.
  1307. # @param pluginId Plugin
  1308. # @param parameterId Parameter index
  1309. # @see carla_get_parameter_count()
  1310. @abstractmethod
  1311. def get_parameter_data(self, pluginId, parameterId):
  1312. raise NotImplementedError
  1313. # Get a plugin's parameter ranges.
  1314. # @param pluginId Plugin
  1315. # @param parameterId Parameter index
  1316. # @see carla_get_parameter_count()
  1317. @abstractmethod
  1318. def get_parameter_ranges(self, pluginId, parameterId):
  1319. raise NotImplementedError
  1320. # Get a plugin's MIDI program data.
  1321. # @param pluginId Plugin
  1322. # @param midiProgramId MIDI Program index
  1323. # @see carla_get_midi_program_count()
  1324. @abstractmethod
  1325. def get_midi_program_data(self, pluginId, midiProgramId):
  1326. raise NotImplementedError
  1327. # Get a plugin's custom data, using index.
  1328. # @param pluginId Plugin
  1329. # @param customDataId Custom data index
  1330. # @see carla_get_custom_data_count()
  1331. @abstractmethod
  1332. def get_custom_data(self, pluginId, customDataId):
  1333. raise NotImplementedError
  1334. # Get a plugin's custom data value, using type and key.
  1335. # @param pluginId Plugin
  1336. # @param type Custom data type
  1337. # @param key Custom data key
  1338. # @see carla_get_custom_data_count()
  1339. @abstractmethod
  1340. def get_custom_data_value(self, pluginId, type_, key):
  1341. raise NotImplementedError
  1342. # Get a plugin's chunk data.
  1343. # @param pluginId Plugin
  1344. # @see PLUGIN_OPTION_USE_CHUNKS
  1345. @abstractmethod
  1346. def get_chunk_data(self, pluginId):
  1347. raise NotImplementedError
  1348. # Get how many parameters a plugin has.
  1349. # @param pluginId Plugin
  1350. @abstractmethod
  1351. def get_parameter_count(self, pluginId):
  1352. raise NotImplementedError
  1353. # Get how many programs a plugin has.
  1354. # @param pluginId Plugin
  1355. # @see carla_get_program_name()
  1356. @abstractmethod
  1357. def get_program_count(self, pluginId):
  1358. raise NotImplementedError
  1359. # Get how many MIDI programs a plugin has.
  1360. # @param pluginId Plugin
  1361. # @see carla_get_midi_program_name() and carla_get_midi_program_data()
  1362. @abstractmethod
  1363. def get_midi_program_count(self, pluginId):
  1364. raise NotImplementedError
  1365. # Get how many custom data sets a plugin has.
  1366. # @param pluginId Plugin
  1367. # @see carla_get_custom_data()
  1368. @abstractmethod
  1369. def get_custom_data_count(self, pluginId):
  1370. raise NotImplementedError
  1371. # Get a plugin's parameter text (custom display of internal values).
  1372. # @param pluginId Plugin
  1373. # @param parameterId Parameter index
  1374. # @see PARAMETER_USES_CUSTOM_TEXT
  1375. @abstractmethod
  1376. def get_parameter_text(self, pluginId, parameterId):
  1377. raise NotImplementedError
  1378. # Get a plugin's program name.
  1379. # @param pluginId Plugin
  1380. # @param programId Program index
  1381. # @see carla_get_program_count()
  1382. @abstractmethod
  1383. def get_program_name(self, pluginId, programId):
  1384. raise NotImplementedError
  1385. # Get a plugin's MIDI program name.
  1386. # @param pluginId Plugin
  1387. # @param midiProgramId MIDI Program index
  1388. # @see carla_get_midi_program_count()
  1389. @abstractmethod
  1390. def get_midi_program_name(self, pluginId, midiProgramId):
  1391. raise NotImplementedError
  1392. # Get a plugin's real name.
  1393. # This is the name the plugin uses to identify itself; may not be unique.
  1394. # @param pluginId Plugin
  1395. @abstractmethod
  1396. def get_real_plugin_name(self, pluginId):
  1397. raise NotImplementedError
  1398. # Get a plugin's program index.
  1399. # @param pluginId Plugin
  1400. @abstractmethod
  1401. def get_current_program_index(self, pluginId):
  1402. raise NotImplementedError
  1403. # Get a plugin's midi program index.
  1404. # @param pluginId Plugin
  1405. @abstractmethod
  1406. def get_current_midi_program_index(self, pluginId):
  1407. raise NotImplementedError
  1408. # Get a plugin's default parameter value.
  1409. # @param pluginId Plugin
  1410. # @param parameterId Parameter index
  1411. @abstractmethod
  1412. def get_default_parameter_value(self, pluginId, parameterId):
  1413. raise NotImplementedError
  1414. # Get a plugin's current parameter value.
  1415. # @param pluginId Plugin
  1416. # @param parameterId Parameter index
  1417. @abstractmethod
  1418. def get_current_parameter_value(self, pluginId, parameterId):
  1419. raise NotImplementedError
  1420. # Get a plugin's internal parameter value.
  1421. # @param pluginId Plugin
  1422. # @param parameterId Parameter index, maybe be negative
  1423. # @see InternalParameterIndex
  1424. @abstractmethod
  1425. def get_internal_parameter_value(self, pluginId, parameterId):
  1426. raise NotImplementedError
  1427. # Get a plugin's input peak value.
  1428. # @param pluginId Plugin
  1429. # @param isLeft Wherever to get the left/mono value, otherwise right.
  1430. @abstractmethod
  1431. def get_input_peak_value(self, pluginId, isLeft):
  1432. raise NotImplementedError
  1433. # Get a plugin's output peak value.
  1434. # @param pluginId Plugin
  1435. # @param isLeft Wherever to get the left/mono value, otherwise right.
  1436. @abstractmethod
  1437. def get_output_peak_value(self, pluginId, isLeft):
  1438. raise NotImplementedError
  1439. # Render a plugin's inline display.
  1440. # @param pluginId Plugin
  1441. @abstractmethod
  1442. def render_inline_display(self, pluginId, width, height):
  1443. raise NotImplementedError
  1444. # Enable a plugin's option.
  1445. # @param pluginId Plugin
  1446. # @param option An option from PluginOptions
  1447. # @param yesNo New enabled state
  1448. @abstractmethod
  1449. def set_option(self, pluginId, option, yesNo):
  1450. raise NotImplementedError
  1451. # Enable or disable a plugin.
  1452. # @param pluginId Plugin
  1453. # @param onOff New active state
  1454. @abstractmethod
  1455. def set_active(self, pluginId, onOff):
  1456. raise NotImplementedError
  1457. # Change a plugin's internal dry/wet.
  1458. # @param pluginId Plugin
  1459. # @param value New dry/wet value
  1460. @abstractmethod
  1461. def set_drywet(self, pluginId, value):
  1462. raise NotImplementedError
  1463. # Change a plugin's internal volume.
  1464. # @param pluginId Plugin
  1465. # @param value New volume
  1466. @abstractmethod
  1467. def set_volume(self, pluginId, value):
  1468. raise NotImplementedError
  1469. # Change a plugin's internal stereo balance, left channel.
  1470. # @param pluginId Plugin
  1471. # @param value New value
  1472. @abstractmethod
  1473. def set_balance_left(self, pluginId, value):
  1474. raise NotImplementedError
  1475. # Change a plugin's internal stereo balance, right channel.
  1476. # @param pluginId Plugin
  1477. # @param value New value
  1478. @abstractmethod
  1479. def set_balance_right(self, pluginId, value):
  1480. raise NotImplementedError
  1481. # Change a plugin's internal mono panning value.
  1482. # @param pluginId Plugin
  1483. # @param value New value
  1484. @abstractmethod
  1485. def set_panning(self, pluginId, value):
  1486. raise NotImplementedError
  1487. # Change a plugin's internal control channel.
  1488. # @param pluginId Plugin
  1489. # @param channel New channel
  1490. @abstractmethod
  1491. def set_ctrl_channel(self, pluginId, channel):
  1492. raise NotImplementedError
  1493. # Change a plugin's parameter value.
  1494. # @param pluginId Plugin
  1495. # @param parameterId Parameter index
  1496. # @param value New value
  1497. @abstractmethod
  1498. def set_parameter_value(self, pluginId, parameterId, value):
  1499. raise NotImplementedError
  1500. # Change a plugin's parameter MIDI cc.
  1501. # @param pluginId Plugin
  1502. # @param parameterId Parameter index
  1503. # @param cc New MIDI cc
  1504. @abstractmethod
  1505. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  1506. raise NotImplementedError
  1507. # Change a plugin's parameter MIDI channel.
  1508. # @param pluginId Plugin
  1509. # @param parameterId Parameter index
  1510. # @param channel New MIDI channel
  1511. @abstractmethod
  1512. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  1513. raise NotImplementedError
  1514. # Change a plugin's parameter in drag/touch mode state.
  1515. # Usually happens from a UI when the user is moving a parameter with a mouse or similar input.
  1516. # @param pluginId Plugin
  1517. # @param parameterId Parameter index
  1518. # @param touch New state
  1519. @abstractmethod
  1520. def set_parameter_touch(self, pluginId, parameterId, touch):
  1521. raise NotImplementedError
  1522. # Change a plugin's current program.
  1523. # @param pluginId Plugin
  1524. # @param programId New program
  1525. @abstractmethod
  1526. def set_program(self, pluginId, programId):
  1527. raise NotImplementedError
  1528. # Change a plugin's current MIDI program.
  1529. # @param pluginId Plugin
  1530. # @param midiProgramId New value
  1531. @abstractmethod
  1532. def set_midi_program(self, pluginId, midiProgramId):
  1533. raise NotImplementedError
  1534. # Set a plugin's custom data set.
  1535. # @param pluginId Plugin
  1536. # @param type Type
  1537. # @param key Key
  1538. # @param value New value
  1539. # @see CustomDataTypes and CustomDataKeys
  1540. @abstractmethod
  1541. def set_custom_data(self, pluginId, type_, key, value):
  1542. raise NotImplementedError
  1543. # Set a plugin's chunk data.
  1544. # @param pluginId Plugin
  1545. # @param chunkData New chunk data
  1546. # @see PLUGIN_OPTION_USE_CHUNKS and carla_get_chunk_data()
  1547. @abstractmethod
  1548. def set_chunk_data(self, pluginId, chunkData):
  1549. raise NotImplementedError
  1550. # Tell a plugin to prepare for save.
  1551. # This should be called before saving custom data sets.
  1552. # @param pluginId Plugin
  1553. @abstractmethod
  1554. def prepare_for_save(self, pluginId):
  1555. raise NotImplementedError
  1556. # Reset all plugin's parameters.
  1557. # @param pluginId Plugin
  1558. @abstractmethod
  1559. def reset_parameters(self, pluginId):
  1560. raise NotImplementedError
  1561. # Randomize all plugin's parameters.
  1562. # @param pluginId Plugin
  1563. @abstractmethod
  1564. def randomize_parameters(self, pluginId):
  1565. raise NotImplementedError
  1566. # Send a single note of a plugin.
  1567. # If velocity is 0, note-off is sent; note-on otherwise.
  1568. # @param pluginId Plugin
  1569. # @param channel Note channel
  1570. # @param note Note pitch
  1571. # @param velocity Note velocity
  1572. @abstractmethod
  1573. def send_midi_note(self, pluginId, channel, note, velocity):
  1574. raise NotImplementedError
  1575. # Tell a plugin to show its own custom UI.
  1576. # @param pluginId Plugin
  1577. # @param yesNo New UI state, visible or not
  1578. # @see PLUGIN_HAS_CUSTOM_UI
  1579. @abstractmethod
  1580. def show_custom_ui(self, pluginId, yesNo):
  1581. raise NotImplementedError
  1582. # Get the current engine buffer size.
  1583. @abstractmethod
  1584. def get_buffer_size(self):
  1585. raise NotImplementedError
  1586. # Get the current engine sample rate.
  1587. @abstractmethod
  1588. def get_sample_rate(self):
  1589. raise NotImplementedError
  1590. # Get the last error.
  1591. @abstractmethod
  1592. def get_last_error(self):
  1593. raise NotImplementedError
  1594. # Get the current engine OSC URL (TCP).
  1595. @abstractmethod
  1596. def get_host_osc_url_tcp(self):
  1597. raise NotImplementedError
  1598. # Get the current engine OSC URL (UDP).
  1599. @abstractmethod
  1600. def get_host_osc_url_udp(self):
  1601. raise NotImplementedError
  1602. # Initialize NSM (that is, announce ourselves to it).
  1603. # Must be called as early as possible in the program's lifecycle.
  1604. # Returns true if NSM is available and initialized correctly.
  1605. @abstractmethod
  1606. def nsm_init(self, pid, executableName):
  1607. raise NotImplementedError
  1608. # Respond to an NSM callback.
  1609. @abstractmethod
  1610. def nsm_ready(self, opcode):
  1611. raise NotImplementedError
  1612. # ------------------------------------------------------------------------------------------------------------
  1613. # Carla Host object (dummy/null, does nothing)
  1614. class CarlaHostNull(CarlaHostMeta):
  1615. def __init__(self):
  1616. CarlaHostMeta.__init__(self)
  1617. self.fEngineCallback = None
  1618. self.fFileCallback = None
  1619. self.fEngineRunning = False
  1620. def get_engine_driver_count(self):
  1621. return 0
  1622. def get_engine_driver_name(self, index):
  1623. return ""
  1624. def get_engine_driver_device_names(self, index):
  1625. return []
  1626. def get_engine_driver_device_info(self, index, name):
  1627. return PyEngineDriverDeviceInfo
  1628. def engine_init(self, driverName, clientName):
  1629. self.fEngineRunning = True
  1630. if self.fEngineCallback is not None:
  1631. self.fEngineCallback(None,
  1632. ENGINE_CALLBACK_ENGINE_STARTED,
  1633. 0,
  1634. self.processMode,
  1635. self.transportMode,
  1636. 0, 0.0,
  1637. driverName)
  1638. return True
  1639. def engine_close(self):
  1640. self.fEngineRunning = False
  1641. if self.fEngineCallback is not None:
  1642. self.fEngineCallback(None, ENGINE_CALLBACK_ENGINE_STOPPED, 0, 0, 0, 0, 0.0, "")
  1643. return True
  1644. def engine_idle(self):
  1645. return
  1646. def is_engine_running(self):
  1647. return self.fEngineRunning
  1648. def get_runtime_engine_info(self):
  1649. return PyCarlaRuntimeEngineInfo
  1650. def clear_engine_xruns(self):
  1651. return
  1652. def cancel_engine_action(self):
  1653. return
  1654. def set_engine_about_to_close(self):
  1655. return True
  1656. def set_engine_callback(self, func):
  1657. self.fEngineCallback = func
  1658. def set_engine_option(self, option, value, valueStr):
  1659. return
  1660. def set_file_callback(self, func):
  1661. self.fFileCallback = func
  1662. def load_file(self, filename):
  1663. return False
  1664. def load_project(self, filename):
  1665. return False
  1666. def save_project(self, filename):
  1667. return False
  1668. def clear_project_filename(self):
  1669. return
  1670. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  1671. return False
  1672. def patchbay_disconnect(self, external, connectionId):
  1673. return False
  1674. def patchbay_refresh(self, external):
  1675. return False
  1676. def transport_play(self):
  1677. return
  1678. def transport_pause(self):
  1679. return
  1680. def transport_bpm(self, bpm):
  1681. return
  1682. def transport_relocate(self, frame):
  1683. return
  1684. def get_current_transport_frame(self):
  1685. return 0
  1686. def get_transport_info(self):
  1687. return PyCarlaTransportInfo
  1688. def get_current_plugin_count(self):
  1689. return 0
  1690. def get_max_plugin_number(self):
  1691. return 0
  1692. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  1693. return False
  1694. def remove_plugin(self, pluginId):
  1695. return False
  1696. def remove_all_plugins(self):
  1697. return False
  1698. def rename_plugin(self, pluginId, newName):
  1699. return False
  1700. def clone_plugin(self, pluginId):
  1701. return False
  1702. def replace_plugin(self, pluginId):
  1703. return False
  1704. def switch_plugins(self, pluginIdA, pluginIdB):
  1705. return False
  1706. def load_plugin_state(self, pluginId, filename):
  1707. return False
  1708. def save_plugin_state(self, pluginId, filename):
  1709. return False
  1710. def export_plugin_lv2(self, pluginId, lv2path):
  1711. return False
  1712. def get_plugin_info(self, pluginId):
  1713. return PyCarlaPluginInfo
  1714. def get_audio_port_count_info(self, pluginId):
  1715. return PyCarlaPortCountInfo
  1716. def get_midi_port_count_info(self, pluginId):
  1717. return PyCarlaPortCountInfo
  1718. def get_parameter_count_info(self, pluginId):
  1719. return PyCarlaPortCountInfo
  1720. def get_parameter_info(self, pluginId, parameterId):
  1721. return PyCarlaParameterInfo
  1722. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  1723. return PyCarlaScalePointInfo
  1724. def get_parameter_data(self, pluginId, parameterId):
  1725. return PyParameterData
  1726. def get_parameter_ranges(self, pluginId, parameterId):
  1727. return PyParameterRanges
  1728. def get_midi_program_data(self, pluginId, midiProgramId):
  1729. return PyMidiProgramData
  1730. def get_custom_data(self, pluginId, customDataId):
  1731. return PyCustomData
  1732. def get_custom_data_value(self, pluginId, type_, key):
  1733. return ""
  1734. def get_chunk_data(self, pluginId):
  1735. return ""
  1736. def get_parameter_count(self, pluginId):
  1737. return 0
  1738. def get_program_count(self, pluginId):
  1739. return 0
  1740. def get_midi_program_count(self, pluginId):
  1741. return 0
  1742. def get_custom_data_count(self, pluginId):
  1743. return 0
  1744. def get_parameter_text(self, pluginId, parameterId):
  1745. return ""
  1746. def get_program_name(self, pluginId, programId):
  1747. return ""
  1748. def get_midi_program_name(self, pluginId, midiProgramId):
  1749. return ""
  1750. def get_real_plugin_name(self, pluginId):
  1751. return ""
  1752. def get_current_program_index(self, pluginId):
  1753. return 0
  1754. def get_current_midi_program_index(self, pluginId):
  1755. return 0
  1756. def get_default_parameter_value(self, pluginId, parameterId):
  1757. return 0.0
  1758. def get_current_parameter_value(self, pluginId, parameterId):
  1759. return 0.0
  1760. def get_internal_parameter_value(self, pluginId, parameterId):
  1761. return 0.0
  1762. def get_input_peak_value(self, pluginId, isLeft):
  1763. return 0.0
  1764. def get_output_peak_value(self, pluginId, isLeft):
  1765. return 0.0
  1766. def render_inline_display(self, pluginId, width, height):
  1767. return None
  1768. def set_option(self, pluginId, option, yesNo):
  1769. return
  1770. def set_active(self, pluginId, onOff):
  1771. return
  1772. def set_drywet(self, pluginId, value):
  1773. return
  1774. def set_volume(self, pluginId, value):
  1775. return
  1776. def set_balance_left(self, pluginId, value):
  1777. return
  1778. def set_balance_right(self, pluginId, value):
  1779. return
  1780. def set_panning(self, pluginId, value):
  1781. return
  1782. def set_ctrl_channel(self, pluginId, channel):
  1783. return
  1784. def set_parameter_value(self, pluginId, parameterId, value):
  1785. return
  1786. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  1787. return
  1788. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  1789. return
  1790. def set_parameter_touch(self, pluginId, parameterId, touch):
  1791. return
  1792. def set_program(self, pluginId, programId):
  1793. return
  1794. def set_midi_program(self, pluginId, midiProgramId):
  1795. return
  1796. def set_custom_data(self, pluginId, type_, key, value):
  1797. return
  1798. def set_chunk_data(self, pluginId, chunkData):
  1799. return
  1800. def prepare_for_save(self, pluginId):
  1801. return
  1802. def reset_parameters(self, pluginId):
  1803. return
  1804. def randomize_parameters(self, pluginId):
  1805. return
  1806. def send_midi_note(self, pluginId, channel, note, velocity):
  1807. return
  1808. def show_custom_ui(self, pluginId, yesNo):
  1809. return
  1810. def get_buffer_size(self):
  1811. return 0
  1812. def get_sample_rate(self):
  1813. return 0.0
  1814. def get_last_error(self):
  1815. return ""
  1816. def get_host_osc_url_tcp(self):
  1817. return ""
  1818. def get_host_osc_url_udp(self):
  1819. return ""
  1820. def nsm_init(self, pid, executableName):
  1821. return False
  1822. def nsm_ready(self, opcode):
  1823. return
  1824. # ------------------------------------------------------------------------------------------------------------
  1825. # Carla Host object using a DLL
  1826. class CarlaHostDLL(CarlaHostMeta):
  1827. def __init__(self, libName, loadGlobal):
  1828. CarlaHostMeta.__init__(self)
  1829. # info about this host object
  1830. self.isPlugin = False
  1831. self.lib = CDLL(libName, RTLD_GLOBAL if loadGlobal else RTLD_LOCAL)
  1832. self.lib.carla_get_engine_driver_count.argtypes = None
  1833. self.lib.carla_get_engine_driver_count.restype = c_uint
  1834. self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
  1835. self.lib.carla_get_engine_driver_name.restype = c_char_p
  1836. self.lib.carla_get_engine_driver_device_names.argtypes = [c_uint]
  1837. self.lib.carla_get_engine_driver_device_names.restype = POINTER(c_char_p)
  1838. self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p]
  1839. self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo)
  1840. self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p]
  1841. self.lib.carla_engine_init.restype = c_bool
  1842. self.lib.carla_engine_close.argtypes = None
  1843. self.lib.carla_engine_close.restype = c_bool
  1844. self.lib.carla_engine_idle.argtypes = None
  1845. self.lib.carla_engine_idle.restype = None
  1846. self.lib.carla_is_engine_running.argtypes = None
  1847. self.lib.carla_is_engine_running.restype = c_bool
  1848. self.lib.carla_get_runtime_engine_info.argtypes = None
  1849. self.lib.carla_get_runtime_engine_info.restype = POINTER(CarlaRuntimeEngineInfo)
  1850. self.lib.carla_clear_engine_xruns.argtypes = None
  1851. self.lib.carla_clear_engine_xruns.restype = None
  1852. self.lib.carla_cancel_engine_action.argtypes = None
  1853. self.lib.carla_cancel_engine_action.restype = None
  1854. self.lib.carla_set_engine_about_to_close.argtypes = None
  1855. self.lib.carla_set_engine_about_to_close.restype = c_bool
  1856. self.lib.carla_set_engine_callback.argtypes = [EngineCallbackFunc, c_void_p]
  1857. self.lib.carla_set_engine_callback.restype = None
  1858. self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
  1859. self.lib.carla_set_engine_option.restype = None
  1860. self.lib.carla_set_file_callback.argtypes = [FileCallbackFunc, c_void_p]
  1861. self.lib.carla_set_file_callback.restype = None
  1862. self.lib.carla_load_file.argtypes = [c_char_p]
  1863. self.lib.carla_load_file.restype = c_bool
  1864. self.lib.carla_load_project.argtypes = [c_char_p]
  1865. self.lib.carla_load_project.restype = c_bool
  1866. self.lib.carla_save_project.argtypes = [c_char_p]
  1867. self.lib.carla_save_project.restype = c_bool
  1868. self.lib.carla_clear_project_filename.argtypes = None
  1869. self.lib.carla_clear_project_filename.restype = None
  1870. self.lib.carla_patchbay_connect.argtypes = [c_bool, c_uint, c_uint, c_uint, c_uint]
  1871. self.lib.carla_patchbay_connect.restype = c_bool
  1872. self.lib.carla_patchbay_disconnect.argtypes = [c_bool, c_uint]
  1873. self.lib.carla_patchbay_disconnect.restype = c_bool
  1874. self.lib.carla_patchbay_refresh.argtypes = [c_bool]
  1875. self.lib.carla_patchbay_refresh.restype = c_bool
  1876. self.lib.carla_transport_play.argtypes = None
  1877. self.lib.carla_transport_play.restype = None
  1878. self.lib.carla_transport_pause.argtypes = None
  1879. self.lib.carla_transport_pause.restype = None
  1880. self.lib.carla_transport_bpm.argtypes = [c_double]
  1881. self.lib.carla_transport_bpm.restype = None
  1882. self.lib.carla_transport_relocate.argtypes = [c_uint64]
  1883. self.lib.carla_transport_relocate.restype = None
  1884. self.lib.carla_get_current_transport_frame.argtypes = None
  1885. self.lib.carla_get_current_transport_frame.restype = c_uint64
  1886. self.lib.carla_get_transport_info.argtypes = None
  1887. self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)
  1888. self.lib.carla_get_current_plugin_count.argtypes = None
  1889. self.lib.carla_get_current_plugin_count.restype = c_uint32
  1890. self.lib.carla_get_max_plugin_number.argtypes = None
  1891. self.lib.carla_get_max_plugin_number.restype = c_uint32
  1892. self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_int64, c_void_p, c_uint]
  1893. self.lib.carla_add_plugin.restype = c_bool
  1894. self.lib.carla_remove_plugin.argtypes = [c_uint]
  1895. self.lib.carla_remove_plugin.restype = c_bool
  1896. self.lib.carla_remove_all_plugins.argtypes = None
  1897. self.lib.carla_remove_all_plugins.restype = c_bool
  1898. self.lib.carla_rename_plugin.argtypes = [c_uint, c_char_p]
  1899. self.lib.carla_rename_plugin.restype = c_bool
  1900. self.lib.carla_clone_plugin.argtypes = [c_uint]
  1901. self.lib.carla_clone_plugin.restype = c_bool
  1902. self.lib.carla_replace_plugin.argtypes = [c_uint]
  1903. self.lib.carla_replace_plugin.restype = c_bool
  1904. self.lib.carla_switch_plugins.argtypes = [c_uint, c_uint]
  1905. self.lib.carla_switch_plugins.restype = c_bool
  1906. self.lib.carla_load_plugin_state.argtypes = [c_uint, c_char_p]
  1907. self.lib.carla_load_plugin_state.restype = c_bool
  1908. self.lib.carla_save_plugin_state.argtypes = [c_uint, c_char_p]
  1909. self.lib.carla_save_plugin_state.restype = c_bool
  1910. self.lib.carla_export_plugin_lv2.argtypes = [c_uint, c_char_p]
  1911. self.lib.carla_export_plugin_lv2.restype = c_bool
  1912. self.lib.carla_get_plugin_info.argtypes = [c_uint]
  1913. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  1914. self.lib.carla_get_audio_port_count_info.argtypes = [c_uint]
  1915. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1916. self.lib.carla_get_midi_port_count_info.argtypes = [c_uint]
  1917. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1918. self.lib.carla_get_parameter_count_info.argtypes = [c_uint]
  1919. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  1920. self.lib.carla_get_parameter_info.argtypes = [c_uint, c_uint32]
  1921. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  1922. self.lib.carla_get_parameter_scalepoint_info.argtypes = [c_uint, c_uint32, c_uint32]
  1923. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  1924. self.lib.carla_get_parameter_data.argtypes = [c_uint, c_uint32]
  1925. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  1926. self.lib.carla_get_parameter_ranges.argtypes = [c_uint, c_uint32]
  1927. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  1928. self.lib.carla_get_midi_program_data.argtypes = [c_uint, c_uint32]
  1929. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  1930. self.lib.carla_get_custom_data.argtypes = [c_uint, c_uint32]
  1931. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  1932. self.lib.carla_get_custom_data_value.argtypes = [c_uint, c_char_p, c_char_p]
  1933. self.lib.carla_get_custom_data_value.restype = c_char_p
  1934. self.lib.carla_get_chunk_data.argtypes = [c_uint]
  1935. self.lib.carla_get_chunk_data.restype = c_char_p
  1936. self.lib.carla_get_parameter_count.argtypes = [c_uint]
  1937. self.lib.carla_get_parameter_count.restype = c_uint32
  1938. self.lib.carla_get_program_count.argtypes = [c_uint]
  1939. self.lib.carla_get_program_count.restype = c_uint32
  1940. self.lib.carla_get_midi_program_count.argtypes = [c_uint]
  1941. self.lib.carla_get_midi_program_count.restype = c_uint32
  1942. self.lib.carla_get_custom_data_count.argtypes = [c_uint]
  1943. self.lib.carla_get_custom_data_count.restype = c_uint32
  1944. self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32]
  1945. self.lib.carla_get_parameter_text.restype = c_char_p
  1946. self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32]
  1947. self.lib.carla_get_program_name.restype = c_char_p
  1948. self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32]
  1949. self.lib.carla_get_midi_program_name.restype = c_char_p
  1950. self.lib.carla_get_real_plugin_name.argtypes = [c_uint]
  1951. self.lib.carla_get_real_plugin_name.restype = c_char_p
  1952. self.lib.carla_get_current_program_index.argtypes = [c_uint]
  1953. self.lib.carla_get_current_program_index.restype = c_int32
  1954. self.lib.carla_get_current_midi_program_index.argtypes = [c_uint]
  1955. self.lib.carla_get_current_midi_program_index.restype = c_int32
  1956. self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32]
  1957. self.lib.carla_get_default_parameter_value.restype = c_float
  1958. self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
  1959. self.lib.carla_get_current_parameter_value.restype = c_float
  1960. self.lib.carla_get_internal_parameter_value.argtypes = [c_uint, c_int32]
  1961. self.lib.carla_get_internal_parameter_value.restype = c_float
  1962. self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_bool]
  1963. self.lib.carla_get_input_peak_value.restype = c_float
  1964. self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_bool]
  1965. self.lib.carla_get_output_peak_value.restype = c_float
  1966. self.lib.carla_render_inline_display.argtypes = [c_uint, c_uint, c_uint]
  1967. self.lib.carla_render_inline_display.restype = POINTER(CarlaInlineDisplayImageSurface)
  1968. self.lib.carla_set_option.argtypes = [c_uint, c_uint, c_bool]
  1969. self.lib.carla_set_option.restype = None
  1970. self.lib.carla_set_active.argtypes = [c_uint, c_bool]
  1971. self.lib.carla_set_active.restype = None
  1972. self.lib.carla_set_drywet.argtypes = [c_uint, c_float]
  1973. self.lib.carla_set_drywet.restype = None
  1974. self.lib.carla_set_volume.argtypes = [c_uint, c_float]
  1975. self.lib.carla_set_volume.restype = None
  1976. self.lib.carla_set_balance_left.argtypes = [c_uint, c_float]
  1977. self.lib.carla_set_balance_left.restype = None
  1978. self.lib.carla_set_balance_right.argtypes = [c_uint, c_float]
  1979. self.lib.carla_set_balance_right.restype = None
  1980. self.lib.carla_set_panning.argtypes = [c_uint, c_float]
  1981. self.lib.carla_set_panning.restype = None
  1982. self.lib.carla_set_ctrl_channel.argtypes = [c_uint, c_int8]
  1983. self.lib.carla_set_ctrl_channel.restype = None
  1984. self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float]
  1985. self.lib.carla_set_parameter_value.restype = None
  1986. self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8]
  1987. self.lib.carla_set_parameter_midi_channel.restype = None
  1988. self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16]
  1989. self.lib.carla_set_parameter_midi_cc.restype = None
  1990. self.lib.carla_set_parameter_touch.argtypes = [c_uint, c_uint32, c_bool]
  1991. self.lib.carla_set_parameter_touch.restype = None
  1992. self.lib.carla_set_program.argtypes = [c_uint, c_uint32]
  1993. self.lib.carla_set_program.restype = None
  1994. self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32]
  1995. self.lib.carla_set_midi_program.restype = None
  1996. self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p]
  1997. self.lib.carla_set_custom_data.restype = None
  1998. self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p]
  1999. self.lib.carla_set_chunk_data.restype = None
  2000. self.lib.carla_prepare_for_save.argtypes = [c_uint]
  2001. self.lib.carla_prepare_for_save.restype = None
  2002. self.lib.carla_reset_parameters.argtypes = [c_uint]
  2003. self.lib.carla_reset_parameters.restype = None
  2004. self.lib.carla_randomize_parameters.argtypes = [c_uint]
  2005. self.lib.carla_randomize_parameters.restype = None
  2006. self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8]
  2007. self.lib.carla_send_midi_note.restype = None
  2008. self.lib.carla_show_custom_ui.argtypes = [c_uint, c_bool]
  2009. self.lib.carla_show_custom_ui.restype = None
  2010. self.lib.carla_get_buffer_size.argtypes = None
  2011. self.lib.carla_get_buffer_size.restype = c_uint32
  2012. self.lib.carla_get_sample_rate.argtypes = None
  2013. self.lib.carla_get_sample_rate.restype = c_double
  2014. self.lib.carla_get_last_error.argtypes = None
  2015. self.lib.carla_get_last_error.restype = c_char_p
  2016. self.lib.carla_get_host_osc_url_tcp.argtypes = None
  2017. self.lib.carla_get_host_osc_url_tcp.restype = c_char_p
  2018. self.lib.carla_get_host_osc_url_udp.argtypes = None
  2019. self.lib.carla_get_host_osc_url_udp.restype = c_char_p
  2020. self.lib.carla_nsm_init.argtypes = [c_int, c_char_p]
  2021. self.lib.carla_nsm_init.restype = c_bool
  2022. self.lib.carla_nsm_ready.argtypes = [c_int]
  2023. self.lib.carla_nsm_ready.restype = None
  2024. # --------------------------------------------------------------------------------------------------------
  2025. def get_engine_driver_count(self):
  2026. return int(self.lib.carla_get_engine_driver_count())
  2027. def get_engine_driver_name(self, index):
  2028. return charPtrToString(self.lib.carla_get_engine_driver_name(index))
  2029. def get_engine_driver_device_names(self, index):
  2030. return charPtrPtrToStringList(self.lib.carla_get_engine_driver_device_names(index))
  2031. def get_engine_driver_device_info(self, index, name):
  2032. return structToDict(self.lib.carla_get_engine_driver_device_info(index, name.encode("utf-8")).contents)
  2033. def engine_init(self, driverName, clientName):
  2034. return bool(self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8")))
  2035. def engine_close(self):
  2036. return bool(self.lib.carla_engine_close())
  2037. def engine_idle(self):
  2038. self.lib.carla_engine_idle()
  2039. def is_engine_running(self):
  2040. return bool(self.lib.carla_is_engine_running())
  2041. def get_runtime_engine_info(self):
  2042. return structToDict(self.lib.carla_get_runtime_engine_info().contents)
  2043. def clear_engine_xruns(self):
  2044. return self.lib.carla_clear_engine_xruns()
  2045. def cancel_engine_action(self):
  2046. return self.lib.carla_cancel_engine_action()
  2047. def set_engine_about_to_close(self):
  2048. return bool(self.lib.carla_set_engine_about_to_close())
  2049. def set_engine_callback(self, func):
  2050. self._engineCallback = EngineCallbackFunc(func)
  2051. self.lib.carla_set_engine_callback(self._engineCallback, None)
  2052. def set_engine_option(self, option, value, valueStr):
  2053. self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))
  2054. def set_file_callback(self, func):
  2055. self._fileCallback = FileCallbackFunc(func)
  2056. self.lib.carla_set_file_callback(self._fileCallback, None)
  2057. def load_file(self, filename):
  2058. return bool(self.lib.carla_load_file(filename.encode("utf-8")))
  2059. def load_project(self, filename):
  2060. return bool(self.lib.carla_load_project(filename.encode("utf-8")))
  2061. def save_project(self, filename):
  2062. return bool(self.lib.carla_save_project(filename.encode("utf-8")))
  2063. def clear_project_filename(self):
  2064. self.lib.carla_clear_project_filename()
  2065. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  2066. return bool(self.lib.carla_patchbay_connect(external, groupIdA, portIdA, groupIdB, portIdB))
  2067. def patchbay_disconnect(self, external, connectionId):
  2068. return bool(self.lib.carla_patchbay_disconnect(external, connectionId))
  2069. def patchbay_refresh(self, external):
  2070. return bool(self.lib.carla_patchbay_refresh(external))
  2071. def transport_play(self):
  2072. self.lib.carla_transport_play()
  2073. def transport_pause(self):
  2074. self.lib.carla_transport_pause()
  2075. def transport_bpm(self, bpm):
  2076. self.lib.carla_transport_bpm(bpm)
  2077. def transport_relocate(self, frame):
  2078. self.lib.carla_transport_relocate(frame)
  2079. def get_current_transport_frame(self):
  2080. return int(self.lib.carla_get_current_transport_frame())
  2081. def get_transport_info(self):
  2082. return structToDict(self.lib.carla_get_transport_info().contents)
  2083. def get_current_plugin_count(self):
  2084. return int(self.lib.carla_get_current_plugin_count())
  2085. def get_max_plugin_number(self):
  2086. return int(self.lib.carla_get_max_plugin_number())
  2087. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  2088. cfilename = filename.encode("utf-8") if filename else None
  2089. cname = name.encode("utf-8") if name else None
  2090. clabel = label.encode("utf-8") if label else None
  2091. return bool(self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, uniqueId, cast(extraPtr, c_void_p), options))
  2092. def remove_plugin(self, pluginId):
  2093. return bool(self.lib.carla_remove_plugin(pluginId))
  2094. def remove_all_plugins(self):
  2095. return bool(self.lib.carla_remove_all_plugins())
  2096. def rename_plugin(self, pluginId, newName):
  2097. return bool(self.lib.carla_rename_plugin(pluginId, newName.encode("utf-8")))
  2098. def clone_plugin(self, pluginId):
  2099. return bool(self.lib.carla_clone_plugin(pluginId))
  2100. def replace_plugin(self, pluginId):
  2101. return bool(self.lib.carla_replace_plugin(pluginId))
  2102. def switch_plugins(self, pluginIdA, pluginIdB):
  2103. return bool(self.lib.carla_switch_plugins(pluginIdA, pluginIdB))
  2104. def load_plugin_state(self, pluginId, filename):
  2105. return bool(self.lib.carla_load_plugin_state(pluginId, filename.encode("utf-8")))
  2106. def save_plugin_state(self, pluginId, filename):
  2107. return bool(self.lib.carla_save_plugin_state(pluginId, filename.encode("utf-8")))
  2108. def export_plugin_lv2(self, pluginId, lv2path):
  2109. return bool(self.lib.carla_export_plugin_lv2(pluginId, lv2path.encode("utf-8")))
  2110. def get_plugin_info(self, pluginId):
  2111. return structToDict(self.lib.carla_get_plugin_info(pluginId).contents)
  2112. def get_audio_port_count_info(self, pluginId):
  2113. return structToDict(self.lib.carla_get_audio_port_count_info(pluginId).contents)
  2114. def get_midi_port_count_info(self, pluginId):
  2115. return structToDict(self.lib.carla_get_midi_port_count_info(pluginId).contents)
  2116. def get_parameter_count_info(self, pluginId):
  2117. return structToDict(self.lib.carla_get_parameter_count_info(pluginId).contents)
  2118. def get_parameter_info(self, pluginId, parameterId):
  2119. return structToDict(self.lib.carla_get_parameter_info(pluginId, parameterId).contents)
  2120. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  2121. return structToDict(self.lib.carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId).contents)
  2122. def get_parameter_data(self, pluginId, parameterId):
  2123. return structToDict(self.lib.carla_get_parameter_data(pluginId, parameterId).contents)
  2124. def get_parameter_ranges(self, pluginId, parameterId):
  2125. return structToDict(self.lib.carla_get_parameter_ranges(pluginId, parameterId).contents)
  2126. def get_midi_program_data(self, pluginId, midiProgramId):
  2127. return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents)
  2128. def get_custom_data(self, pluginId, customDataId):
  2129. return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents)
  2130. def get_custom_data_value(self, pluginId, type_, key):
  2131. return charPtrToString(self.lib.carla_get_custom_data_value(pluginId, type_.encode("utf-8"), key.encode("utf-8")))
  2132. def get_chunk_data(self, pluginId):
  2133. return charPtrToString(self.lib.carla_get_chunk_data(pluginId))
  2134. def get_parameter_count(self, pluginId):
  2135. return int(self.lib.carla_get_parameter_count(pluginId))
  2136. def get_program_count(self, pluginId):
  2137. return int(self.lib.carla_get_program_count(pluginId))
  2138. def get_midi_program_count(self, pluginId):
  2139. return int(self.lib.carla_get_midi_program_count(pluginId))
  2140. def get_custom_data_count(self, pluginId):
  2141. return int(self.lib.carla_get_custom_data_count(pluginId))
  2142. def get_parameter_text(self, pluginId, parameterId):
  2143. return charPtrToString(self.lib.carla_get_parameter_text(pluginId, parameterId))
  2144. def get_program_name(self, pluginId, programId):
  2145. return charPtrToString(self.lib.carla_get_program_name(pluginId, programId))
  2146. def get_midi_program_name(self, pluginId, midiProgramId):
  2147. return charPtrToString(self.lib.carla_get_midi_program_name(pluginId, midiProgramId))
  2148. def get_real_plugin_name(self, pluginId):
  2149. return charPtrToString(self.lib.carla_get_real_plugin_name(pluginId))
  2150. def get_current_program_index(self, pluginId):
  2151. return int(self.lib.carla_get_current_program_index(pluginId))
  2152. def get_current_midi_program_index(self, pluginId):
  2153. return int(self.lib.carla_get_current_midi_program_index(pluginId))
  2154. def get_default_parameter_value(self, pluginId, parameterId):
  2155. return float(self.lib.carla_get_default_parameter_value(pluginId, parameterId))
  2156. def get_current_parameter_value(self, pluginId, parameterId):
  2157. return float(self.lib.carla_get_current_parameter_value(pluginId, parameterId))
  2158. def get_internal_parameter_value(self, pluginId, parameterId):
  2159. return float(self.lib.carla_get_internal_parameter_value(pluginId, parameterId))
  2160. def get_input_peak_value(self, pluginId, isLeft):
  2161. return float(self.lib.carla_get_input_peak_value(pluginId, isLeft))
  2162. def get_output_peak_value(self, pluginId, isLeft):
  2163. return float(self.lib.carla_get_output_peak_value(pluginId, isLeft))
  2164. def render_inline_display(self, pluginId, width, height):
  2165. ptr = self.lib.carla_render_inline_display(pluginId, width, height)
  2166. if not ptr or not ptr.contents:
  2167. return None
  2168. contents = ptr.contents
  2169. datalen = contents.height * contents.stride
  2170. unpacked = tuple(contents.data[i] for i in range(datalen))
  2171. packed = pack("%iB" % datalen, *unpacked)
  2172. data = {
  2173. 'data': voidptr(packed),
  2174. 'width': contents.width,
  2175. 'height': contents.height,
  2176. 'stride': contents.stride,
  2177. }
  2178. return data
  2179. def set_option(self, pluginId, option, yesNo):
  2180. self.lib.carla_set_option(pluginId, option, yesNo)
  2181. def set_active(self, pluginId, onOff):
  2182. self.lib.carla_set_active(pluginId, onOff)
  2183. def set_drywet(self, pluginId, value):
  2184. self.lib.carla_set_drywet(pluginId, value)
  2185. def set_volume(self, pluginId, value):
  2186. self.lib.carla_set_volume(pluginId, value)
  2187. def set_balance_left(self, pluginId, value):
  2188. self.lib.carla_set_balance_left(pluginId, value)
  2189. def set_balance_right(self, pluginId, value):
  2190. self.lib.carla_set_balance_right(pluginId, value)
  2191. def set_panning(self, pluginId, value):
  2192. self.lib.carla_set_panning(pluginId, value)
  2193. def set_ctrl_channel(self, pluginId, channel):
  2194. self.lib.carla_set_ctrl_channel(pluginId, channel)
  2195. def set_parameter_value(self, pluginId, parameterId, value):
  2196. self.lib.carla_set_parameter_value(pluginId, parameterId, value)
  2197. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  2198. self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel)
  2199. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  2200. self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc)
  2201. def set_parameter_touch(self, pluginId, parameterId, touch):
  2202. self.lib.carla_set_parameter_touch(pluginId, parameterId, touch)
  2203. def set_program(self, pluginId, programId):
  2204. self.lib.carla_set_program(pluginId, programId)
  2205. def set_midi_program(self, pluginId, midiProgramId):
  2206. self.lib.carla_set_midi_program(pluginId, midiProgramId)
  2207. def set_custom_data(self, pluginId, type_, key, value):
  2208. self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8"))
  2209. def set_chunk_data(self, pluginId, chunkData):
  2210. self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8"))
  2211. def prepare_for_save(self, pluginId):
  2212. self.lib.carla_prepare_for_save(pluginId)
  2213. def reset_parameters(self, pluginId):
  2214. self.lib.carla_reset_parameters(pluginId)
  2215. def randomize_parameters(self, pluginId):
  2216. self.lib.carla_randomize_parameters(pluginId)
  2217. def send_midi_note(self, pluginId, channel, note, velocity):
  2218. self.lib.carla_send_midi_note(pluginId, channel, note, velocity)
  2219. def show_custom_ui(self, pluginId, yesNo):
  2220. self.lib.carla_show_custom_ui(pluginId, yesNo)
  2221. def get_buffer_size(self):
  2222. return int(self.lib.carla_get_buffer_size())
  2223. def get_sample_rate(self):
  2224. return float(self.lib.carla_get_sample_rate())
  2225. def get_last_error(self):
  2226. return charPtrToString(self.lib.carla_get_last_error())
  2227. def get_host_osc_url_tcp(self):
  2228. return charPtrToString(self.lib.carla_get_host_osc_url_tcp())
  2229. def get_host_osc_url_udp(self):
  2230. return charPtrToString(self.lib.carla_get_host_osc_url_udp())
  2231. def nsm_init(self, pid, executableName):
  2232. return bool(self.lib.carla_nsm_init(pid, executableName.encode("utf-8")))
  2233. def nsm_ready(self, opcode):
  2234. self.lib.carla_nsm_ready(opcode)
  2235. # ------------------------------------------------------------------------------------------------------------
  2236. # Helper object for CarlaHostPlugin
  2237. class PluginStoreInfo(object):
  2238. def __init__(self):
  2239. self.clear()
  2240. def clear(self):
  2241. self.pluginInfo = PyCarlaPluginInfo.copy()
  2242. self.pluginRealName = ""
  2243. self.internalValues = [0.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0]
  2244. self.audioCountInfo = PyCarlaPortCountInfo.copy()
  2245. self.midiCountInfo = PyCarlaPortCountInfo.copy()
  2246. self.parameterCount = 0
  2247. self.parameterCountInfo = PyCarlaPortCountInfo.copy()
  2248. self.parameterInfo = []
  2249. self.parameterData = []
  2250. self.parameterRanges = []
  2251. self.parameterValues = []
  2252. self.programCount = 0
  2253. self.programCurrent = -1
  2254. self.programNames = []
  2255. self.midiProgramCount = 0
  2256. self.midiProgramCurrent = -1
  2257. self.midiProgramData = []
  2258. self.customDataCount = 0
  2259. self.customData = []
  2260. self.peaks = [0.0, 0.0, 0.0, 0.0]
  2261. # ------------------------------------------------------------------------------------------------------------
  2262. # Carla Host object for plugins (using pipes)
  2263. class CarlaHostPlugin(CarlaHostMeta):
  2264. #class CarlaHostPlugin(CarlaHostMeta, metaclass=ABCMeta):
  2265. def __init__(self):
  2266. CarlaHostMeta.__init__(self)
  2267. # info about this host object
  2268. self.isPlugin = True
  2269. self.processModeForced = True
  2270. # text data to return when requested
  2271. self.fMaxPluginNumber = 0
  2272. self.fLastError = ""
  2273. # plugin info
  2274. self.fPluginsInfo = {}
  2275. self.fFallbackPluginInfo = PluginStoreInfo()
  2276. # runtime engine info
  2277. self.fRuntimeEngineInfo = {
  2278. "load": 0.0,
  2279. "xruns": 0
  2280. }
  2281. # transport info
  2282. self.fTransportInfo = {
  2283. "playing": False,
  2284. "frame": 0,
  2285. "bar": 0,
  2286. "beat": 0,
  2287. "tick": 0,
  2288. "bpm": 0.0
  2289. }
  2290. # some other vars
  2291. self.fBufferSize = 0
  2292. self.fSampleRate = 0.0
  2293. self.fOscTCP = ""
  2294. self.fOscUDP = ""
  2295. # --------------------------------------------------------------------------------------------------------
  2296. # Needs to be reimplemented
  2297. @abstractmethod
  2298. def sendMsg(self, lines):
  2299. raise NotImplementedError
  2300. # internal, sets error if sendMsg failed
  2301. def sendMsgAndSetError(self, lines):
  2302. if self.sendMsg(lines):
  2303. return True
  2304. self.fLastError = "Communication error with backend"
  2305. return False
  2306. # --------------------------------------------------------------------------------------------------------
  2307. def get_engine_driver_count(self):
  2308. return 1
  2309. def get_engine_driver_name(self, index):
  2310. return "Plugin"
  2311. def get_engine_driver_device_names(self, index):
  2312. return []
  2313. def get_engine_driver_device_info(self, index, name):
  2314. return PyEngineDriverDeviceInfo
  2315. def get_runtime_engine_info(self):
  2316. return self.fRuntimeEngineInfo
  2317. def clear_engine_xruns(self):
  2318. self.sendMsg(["clear_engine_xruns"])
  2319. def cancel_engine_action(self):
  2320. self.sendMsg(["cancel_engine_action"])
  2321. def set_engine_callback(self, func):
  2322. return # TODO
  2323. def set_engine_option(self, option, value, valueStr):
  2324. self.sendMsg(["set_engine_option", option, int(value), valueStr])
  2325. def set_file_callback(self, func):
  2326. return # TODO
  2327. def load_file(self, filename):
  2328. return self.sendMsgAndSetError(["load_file", filename])
  2329. def load_project(self, filename):
  2330. return self.sendMsgAndSetError(["load_project", filename])
  2331. def save_project(self, filename):
  2332. return self.sendMsgAndSetError(["save_project", filename])
  2333. def clear_project_filename(self):
  2334. return self.sendMsgAndSetError(["clear_project_filename"])
  2335. def patchbay_connect(self, external, groupIdA, portIdA, groupIdB, portIdB):
  2336. return self.sendMsgAndSetError(["patchbay_connect", external, groupIdA, portIdA, groupIdB, portIdB])
  2337. def patchbay_disconnect(self, external, connectionId):
  2338. return self.sendMsgAndSetError(["patchbay_disconnect", external, connectionId])
  2339. def patchbay_refresh(self, external):
  2340. return self.sendMsgAndSetError(["patchbay_refresh", external])
  2341. def transport_play(self):
  2342. self.sendMsg(["transport_play"])
  2343. def transport_pause(self):
  2344. self.sendMsg(["transport_pause"])
  2345. def transport_bpm(self, bpm):
  2346. self.sendMsg(["transport_bpm", bpm])
  2347. def transport_relocate(self, frame):
  2348. self.sendMsg(["transport_relocate", frame])
  2349. def get_current_transport_frame(self):
  2350. return self.fTransportInfo['frame']
  2351. def get_transport_info(self):
  2352. return self.fTransportInfo
  2353. def get_current_plugin_count(self):
  2354. return len(self.fPluginsInfo)
  2355. def get_max_plugin_number(self):
  2356. return self.fMaxPluginNumber
  2357. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options):
  2358. return self.sendMsgAndSetError(["add_plugin",
  2359. btype, ptype,
  2360. filename or "(null)",
  2361. name or "(null)",
  2362. label, uniqueId, options])
  2363. def remove_plugin(self, pluginId):
  2364. return self.sendMsgAndSetError(["remove_plugin", pluginId])
  2365. def remove_all_plugins(self):
  2366. return self.sendMsgAndSetError(["remove_all_plugins"])
  2367. def rename_plugin(self, pluginId, newName):
  2368. return self.sendMsgAndSetError(["rename_plugin", pluginId, newName])
  2369. def clone_plugin(self, pluginId):
  2370. return self.sendMsgAndSetError(["clone_plugin", pluginId])
  2371. def replace_plugin(self, pluginId):
  2372. return self.sendMsgAndSetError(["replace_plugin", pluginId])
  2373. def switch_plugins(self, pluginIdA, pluginIdB):
  2374. ret = self.sendMsgAndSetError(["switch_plugins", pluginIdA, pluginIdB])
  2375. if ret:
  2376. self._switchPlugins(pluginIdA, pluginIdB)
  2377. return ret
  2378. def load_plugin_state(self, pluginId, filename):
  2379. return self.sendMsgAndSetError(["load_plugin_state", pluginId, filename])
  2380. def save_plugin_state(self, pluginId, filename):
  2381. return self.sendMsgAndSetError(["save_plugin_state", pluginId, filename])
  2382. def export_plugin_lv2(self, pluginId, lv2path):
  2383. self.fLastError = "Operation unavailable in plugin version"
  2384. return False
  2385. def get_plugin_info(self, pluginId):
  2386. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).pluginInfo
  2387. def get_audio_port_count_info(self, pluginId):
  2388. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).audioCountInfo
  2389. def get_midi_port_count_info(self, pluginId):
  2390. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).midiCountInfo
  2391. def get_parameter_count_info(self, pluginId):
  2392. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterCountInfo
  2393. def get_parameter_info(self, pluginId, parameterId):
  2394. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterInfo[parameterId]
  2395. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  2396. return PyCarlaScalePointInfo
  2397. def get_parameter_data(self, pluginId, parameterId):
  2398. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterData[parameterId]
  2399. def get_parameter_ranges(self, pluginId, parameterId):
  2400. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterRanges[parameterId]
  2401. def get_midi_program_data(self, pluginId, midiProgramId):
  2402. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).midiProgramData[midiProgramId]
  2403. def get_custom_data(self, pluginId, customDataId):
  2404. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).customData[customDataId]
  2405. def get_custom_data_value(self, pluginId, type_, key):
  2406. plugin = self.fPluginsInfo.get(pluginId, None)
  2407. if plugin is None:
  2408. return ""
  2409. for customData in plugin.customData:
  2410. if customData['type'] == type_ and customData['key'] == key:
  2411. return customData['value']
  2412. return ""
  2413. def get_chunk_data(self, pluginId):
  2414. return ""
  2415. def get_parameter_count(self, pluginId):
  2416. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).parameterCount
  2417. def get_program_count(self, pluginId):
  2418. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).programCount
  2419. def get_midi_program_count(self, pluginId):
  2420. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).midiProgramCount
  2421. def get_custom_data_count(self, pluginId):
  2422. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).customDataCount
  2423. def get_parameter_text(self, pluginId, parameterId):
  2424. return ""
  2425. def get_program_name(self, pluginId, programId):
  2426. return self.fPluginsInfo[pluginId].programNames[programId]
  2427. def get_midi_program_name(self, pluginId, midiProgramId):
  2428. return self.fPluginsInfo[pluginId].midiProgramData[midiProgramId]['label']
  2429. def get_real_plugin_name(self, pluginId):
  2430. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).pluginRealName
  2431. def get_current_program_index(self, pluginId):
  2432. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).programCurrent
  2433. def get_current_midi_program_index(self, pluginId):
  2434. return self.fPluginsInfo.get(pluginId, self.fFallbackPluginInfo).midiProgramCurrent
  2435. def get_default_parameter_value(self, pluginId, parameterId):
  2436. return self.fPluginsInfo[pluginId].parameterRanges[parameterId]['def']
  2437. def get_current_parameter_value(self, pluginId, parameterId):
  2438. return self.fPluginsInfo[pluginId].parameterValues[parameterId]
  2439. def get_internal_parameter_value(self, pluginId, parameterId):
  2440. if parameterId == PARAMETER_NULL or parameterId <= PARAMETER_MAX:
  2441. return 0.0
  2442. if parameterId < 0:
  2443. return self.fPluginsInfo[pluginId].internalValues[abs(parameterId)-2]
  2444. return self.fPluginsInfo[pluginId].parameterValues[parameterId]
  2445. def get_input_peak_value(self, pluginId, isLeft):
  2446. return self.fPluginsInfo[pluginId].peaks[0 if isLeft else 1]
  2447. def get_output_peak_value(self, pluginId, isLeft):
  2448. return self.fPluginsInfo[pluginId].peaks[2 if isLeft else 3]
  2449. def render_inline_display(self, pluginId, width, height):
  2450. return None
  2451. def set_option(self, pluginId, option, yesNo):
  2452. self.sendMsg(["set_option", pluginId, option, yesNo])
  2453. def set_active(self, pluginId, onOff):
  2454. self.sendMsg(["set_active", pluginId, onOff])
  2455. self.fPluginsInfo[pluginId].internalValues[0] = 1.0 if onOff else 0.0
  2456. def set_drywet(self, pluginId, value):
  2457. self.sendMsg(["set_drywet", pluginId, value])
  2458. self.fPluginsInfo[pluginId].internalValues[1] = value
  2459. def set_volume(self, pluginId, value):
  2460. self.sendMsg(["set_volume", pluginId, value])
  2461. self.fPluginsInfo[pluginId].internalValues[2] = value
  2462. def set_balance_left(self, pluginId, value):
  2463. self.sendMsg(["set_balance_left", pluginId, value])
  2464. self.fPluginsInfo[pluginId].internalValues[3] = value
  2465. def set_balance_right(self, pluginId, value):
  2466. self.sendMsg(["set_balance_right", pluginId, value])
  2467. self.fPluginsInfo[pluginId].internalValues[4] = value
  2468. def set_panning(self, pluginId, value):
  2469. self.sendMsg(["set_panning", pluginId, value])
  2470. self.fPluginsInfo[pluginId].internalValues[5] = value
  2471. def set_ctrl_channel(self, pluginId, channel):
  2472. self.sendMsg(["set_ctrl_channel", pluginId, channel])
  2473. self.fPluginsInfo[pluginId].internalValues[6] = float(channel)
  2474. def set_parameter_value(self, pluginId, parameterId, value):
  2475. self.sendMsg(["set_parameter_value", pluginId, parameterId, value])
  2476. self.fPluginsInfo[pluginId].parameterValues[parameterId] = value
  2477. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  2478. self.sendMsg(["set_parameter_midi_channel", pluginId, parameterId, channel])
  2479. self.fPluginsInfo[pluginId].parameterData[parameterId]['midiCC'] = channel
  2480. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  2481. self.sendMsg(["set_parameter_midi_cc", pluginId, parameterId, cc])
  2482. self.fPluginsInfo[pluginId].parameterData[parameterId]['midiCC'] = cc
  2483. def set_parameter_touch(self, pluginId, parameterId, touch):
  2484. self.sendMsg(["set_parameter_touch", pluginId, parameterId, touch])
  2485. def set_program(self, pluginId, programId):
  2486. self.sendMsg(["set_program", pluginId, programId])
  2487. self.fPluginsInfo[pluginId].programCurrent = programId
  2488. def set_midi_program(self, pluginId, midiProgramId):
  2489. self.sendMsg(["set_midi_program", pluginId, midiProgramId])
  2490. self.fPluginsInfo[pluginId].midiProgramCurrent = midiProgramId
  2491. def set_custom_data(self, pluginId, type_, key, value):
  2492. self.sendMsg(["set_custom_data", pluginId, type_, key, value])
  2493. for cdata in self.fPluginsInfo[pluginId].customData:
  2494. if cdata['type'] != type_:
  2495. continue
  2496. if cdata['key'] != key:
  2497. continue
  2498. cdata['value'] = value
  2499. break
  2500. def set_chunk_data(self, pluginId, chunkData):
  2501. self.sendMsg(["set_chunk_data", pluginId, chunkData])
  2502. def prepare_for_save(self, pluginId):
  2503. self.sendMsg(["prepare_for_save", pluginId])
  2504. def reset_parameters(self, pluginId):
  2505. self.sendMsg(["reset_parameters", pluginId])
  2506. def randomize_parameters(self, pluginId):
  2507. self.sendMsg(["randomize_parameters", pluginId])
  2508. def send_midi_note(self, pluginId, channel, note, velocity):
  2509. self.sendMsg(["send_midi_note", pluginId, channel, note, velocity])
  2510. def show_custom_ui(self, pluginId, yesNo):
  2511. self.sendMsg(["show_custom_ui", pluginId, yesNo])
  2512. def get_buffer_size(self):
  2513. return self.fBufferSize
  2514. def get_sample_rate(self):
  2515. return self.fSampleRate
  2516. def get_last_error(self):
  2517. return self.fLastError
  2518. def get_host_osc_url_tcp(self):
  2519. return self.fOscTCP
  2520. def get_host_osc_url_udp(self):
  2521. return self.fOscUDP
  2522. # --------------------------------------------------------------------------------------------------------
  2523. def _set_runtime_info(self, load, xruns):
  2524. self.fRuntimeEngineInfo = {
  2525. "load": load,
  2526. "xruns": xruns
  2527. }
  2528. def _set_transport(self, playing, frame, bar, beat, tick, bpm):
  2529. self.fTransportInfo = {
  2530. "playing": playing,
  2531. "frame": frame,
  2532. "bar": bar,
  2533. "beat": beat,
  2534. "tick": tick,
  2535. "bpm": bpm
  2536. }
  2537. def _add(self, pluginId):
  2538. self.fPluginsInfo[pluginId] = PluginStoreInfo()
  2539. def _allocateAsNeeded(self, pluginId):
  2540. if pluginId < len(self.fPluginsInfo):
  2541. return
  2542. for id in range(len(self.fPluginsInfo), pluginId+1):
  2543. self.fPluginsInfo[id] = PluginStoreInfo()
  2544. def _set_pluginInfo(self, pluginId, info):
  2545. plugin = self.fPluginsInfo.get(pluginId, None)
  2546. if plugin is None:
  2547. print("_set_pluginInfo failed for", pluginId)
  2548. return
  2549. plugin.pluginInfo = info
  2550. def _set_pluginInfoUpdate(self, pluginId, info):
  2551. plugin = self.fPluginsInfo.get(pluginId, None)
  2552. if plugin is None:
  2553. print("_set_pluginInfoUpdate failed for", pluginId)
  2554. return
  2555. plugin.pluginInfo.update(info)
  2556. def _set_pluginName(self, pluginId, name):
  2557. plugin = self.fPluginsInfo.get(pluginId, None)
  2558. if plugin is None:
  2559. print("_set_pluginName failed for", pluginId)
  2560. return
  2561. plugin.pluginInfo['name'] = name
  2562. def _set_pluginRealName(self, pluginId, realName):
  2563. plugin = self.fPluginsInfo.get(pluginId, None)
  2564. if plugin is None:
  2565. print("_set_pluginRealName failed for", pluginId)
  2566. return
  2567. plugin.pluginRealName = realName
  2568. def _set_internalValue(self, pluginId, paramIndex, value):
  2569. pluginInfo = self.fPluginsInfo.get(pluginId, None)
  2570. if pluginInfo is None:
  2571. print("_set_internalValue failed for", pluginId)
  2572. return
  2573. if PARAMETER_NULL > paramIndex > PARAMETER_MAX:
  2574. pluginInfo.internalValues[abs(paramIndex)-2] = float(value)
  2575. else:
  2576. print("_set_internalValue failed for", pluginId, "with param", paramIndex)
  2577. def _set_audioCountInfo(self, pluginId, info):
  2578. plugin = self.fPluginsInfo.get(pluginId, None)
  2579. if plugin is None:
  2580. print("_set_audioCountInfo failed for", pluginId)
  2581. return
  2582. plugin.audioCountInfo = info
  2583. def _set_midiCountInfo(self, pluginId, info):
  2584. plugin = self.fPluginsInfo.get(pluginId, None)
  2585. if plugin is None:
  2586. print("_set_midiCountInfo failed for", pluginId)
  2587. return
  2588. plugin.midiCountInfo = info
  2589. def _set_parameterCountInfo(self, pluginId, count, info):
  2590. plugin = self.fPluginsInfo.get(pluginId, None)
  2591. if plugin is None:
  2592. print("_set_parameterCountInfo failed for", pluginId)
  2593. return
  2594. plugin.parameterCount = count
  2595. plugin.parameterCountInfo = info
  2596. # clear
  2597. plugin.parameterInfo = []
  2598. plugin.parameterData = []
  2599. plugin.parameterRanges = []
  2600. plugin.parameterValues = []
  2601. # add placeholders
  2602. for x in range(count):
  2603. plugin.parameterInfo.append(PyCarlaParameterInfo.copy())
  2604. plugin.parameterData.append(PyParameterData.copy())
  2605. plugin.parameterRanges.append(PyParameterRanges.copy())
  2606. plugin.parameterValues.append(0.0)
  2607. def _set_programCount(self, pluginId, count):
  2608. plugin = self.fPluginsInfo.get(pluginId, None)
  2609. if plugin is None:
  2610. print("_set_internalValue failed for", pluginId)
  2611. return
  2612. plugin.programCount = count
  2613. plugin.programNames = ["" for x in range(count)]
  2614. def _set_midiProgramCount(self, pluginId, count):
  2615. plugin = self.fPluginsInfo.get(pluginId, None)
  2616. if plugin is None:
  2617. print("_set_internalValue failed for", pluginId)
  2618. return
  2619. plugin.midiProgramCount = count
  2620. plugin.midiProgramData = [PyMidiProgramData.copy() for x in range(count)]
  2621. def _set_customDataCount(self, pluginId, count):
  2622. plugin = self.fPluginsInfo.get(pluginId, None)
  2623. if plugin is None:
  2624. print("_set_internalValue failed for", pluginId)
  2625. return
  2626. plugin.customDataCount = count
  2627. plugin.customData = [PyCustomData.copy() for x in range(count)]
  2628. def _set_parameterInfo(self, pluginId, paramIndex, info):
  2629. plugin = self.fPluginsInfo.get(pluginId, None)
  2630. if plugin is None:
  2631. print("_set_parameterInfo failed for", pluginId)
  2632. return
  2633. if paramIndex < plugin.parameterCount:
  2634. plugin.parameterInfo[paramIndex] = info
  2635. else:
  2636. print("_set_parameterInfo failed for", pluginId, "and index", paramIndex)
  2637. def _set_parameterData(self, pluginId, paramIndex, data):
  2638. plugin = self.fPluginsInfo.get(pluginId, None)
  2639. if plugin is None:
  2640. print("_set_parameterData failed for", pluginId)
  2641. return
  2642. if paramIndex < plugin.parameterCount:
  2643. plugin.parameterData[paramIndex] = data
  2644. else:
  2645. print("_set_parameterData failed for", pluginId, "and index", paramIndex)
  2646. def _set_parameterRanges(self, pluginId, paramIndex, ranges):
  2647. plugin = self.fPluginsInfo.get(pluginId, None)
  2648. if plugin is None:
  2649. print("_set_parameterRanges failed for", pluginId)
  2650. return
  2651. if paramIndex < plugin.parameterCount:
  2652. plugin.parameterRanges[paramIndex] = ranges
  2653. else:
  2654. print("_set_parameterRanges failed for", pluginId, "and index", paramIndex)
  2655. def _set_parameterRangesUpdate(self, pluginId, paramIndex, ranges):
  2656. plugin = self.fPluginsInfo.get(pluginId, None)
  2657. if plugin is None:
  2658. print("_set_parameterRangesUpdate failed for", pluginId)
  2659. return
  2660. if paramIndex < plugin.parameterCount:
  2661. plugin.parameterRanges[paramIndex].update(ranges)
  2662. else:
  2663. print("_set_parameterRangesUpdate failed for", pluginId, "and index", paramIndex)
  2664. def _set_parameterValue(self, pluginId, paramIndex, value):
  2665. plugin = self.fPluginsInfo.get(pluginId, None)
  2666. if plugin is None:
  2667. print("_set_parameterValue failed for", pluginId)
  2668. return
  2669. if paramIndex < plugin.parameterCount:
  2670. plugin.parameterValues[paramIndex] = value
  2671. else:
  2672. print("_set_parameterValue failed for", pluginId, "and index", paramIndex)
  2673. def _set_parameterDefault(self, pluginId, paramIndex, value):
  2674. plugin = self.fPluginsInfo.get(pluginId, None)
  2675. if plugin is None:
  2676. print("_set_parameterDefault failed for", pluginId)
  2677. return
  2678. if paramIndex < plugin.parameterCount:
  2679. plugin.parameterRanges[paramIndex]['def'] = value
  2680. else:
  2681. print("_set_parameterDefault failed for", pluginId, "and index", paramIndex)
  2682. def _set_parameterMidiChannel(self, pluginId, paramIndex, channel):
  2683. plugin = self.fPluginsInfo.get(pluginId, None)
  2684. if plugin is None:
  2685. print("_set_parameterMidiChannel failed for", pluginId)
  2686. return
  2687. if paramIndex < plugin.parameterCount:
  2688. plugin.parameterData[paramIndex]['midiChannel'] = channel
  2689. else:
  2690. print("_set_parameterMidiChannel failed for", pluginId, "and index", paramIndex)
  2691. def _set_parameterMidiCC(self, pluginId, paramIndex, cc):
  2692. plugin = self.fPluginsInfo.get(pluginId, None)
  2693. if plugin is None:
  2694. print("_set_parameterMidiCC failed for", pluginId)
  2695. return
  2696. if paramIndex < plugin.parameterCount:
  2697. plugin.parameterData[paramIndex]['midiCC'] = cc
  2698. else:
  2699. print("_set_parameterMidiCC failed for", pluginId, "and index", paramIndex)
  2700. def _set_currentProgram(self, pluginId, pIndex):
  2701. plugin = self.fPluginsInfo.get(pluginId, None)
  2702. if plugin is None:
  2703. print("_set_currentProgram failed for", pluginId)
  2704. return
  2705. plugin.programCurrent = pIndex
  2706. def _set_currentMidiProgram(self, pluginId, mpIndex):
  2707. plugin = self.fPluginsInfo.get(pluginId, None)
  2708. if plugin is None:
  2709. print("_set_currentMidiProgram failed for", pluginId)
  2710. return
  2711. plugin.midiProgramCurrent = mpIndex
  2712. def _set_programName(self, pluginId, pIndex, name):
  2713. plugin = self.fPluginsInfo.get(pluginId, None)
  2714. if plugin is None:
  2715. print("_set_programName failed for", pluginId)
  2716. return
  2717. if pIndex < plugin.programCount:
  2718. plugin.programNames[pIndex] = name
  2719. else:
  2720. print("_set_programName failed for", pluginId, "and index", pIndex)
  2721. def _set_midiProgramData(self, pluginId, mpIndex, data):
  2722. plugin = self.fPluginsInfo.get(pluginId, None)
  2723. if plugin is None:
  2724. print("_set_midiProgramData failed for", pluginId)
  2725. return
  2726. if mpIndex < plugin.midiProgramCount:
  2727. plugin.midiProgramData[mpIndex] = data
  2728. else:
  2729. print("_set_midiProgramData failed for", pluginId, "and index", mpIndex)
  2730. def _set_customData(self, pluginId, cdIndex, data):
  2731. plugin = self.fPluginsInfo.get(pluginId, None)
  2732. if plugin is None:
  2733. print("_set_customData failed for", pluginId)
  2734. return
  2735. if cdIndex < plugin.customDataCount:
  2736. plugin.customData[cdIndex] = data
  2737. else:
  2738. print("_set_customData failed for", pluginId, "and index", cdIndex)
  2739. def _set_peaks(self, pluginId, in1, in2, out1, out2):
  2740. pluginInfo = self.fPluginsInfo.get(pluginId, None)
  2741. if pluginInfo is not None:
  2742. pluginInfo.peaks = [in1, in2, out1, out2]
  2743. def _switchPlugins(self, pluginIdA, pluginIdB):
  2744. tmp = self.fPluginsInfo[pluginIdA]
  2745. self.fPluginsInfo[pluginIdA] = self.fPluginsInfo[pluginIdB]
  2746. self.fPluginsInfo[pluginIdB] = tmp
  2747. def _setViaCallback(self, action, pluginId, value1, value2, value3, valuef, valueStr):
  2748. if action == ENGINE_CALLBACK_ENGINE_STARTED:
  2749. self._allocateAsNeeded(pluginId)
  2750. self.fBufferSize = value3
  2751. self.fSampleRate = valuef
  2752. elif ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  2753. self.fBufferSize = value1
  2754. elif ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  2755. self.fSampleRate = valuef
  2756. elif action == ENGINE_CALLBACK_PLUGIN_RENAMED:
  2757. self._set_pluginName(pluginId, valueStr)
  2758. elif action == ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  2759. if value1 < 0:
  2760. self._set_internalValue(pluginId, value1, valuef)
  2761. else:
  2762. self._set_parameterValue(pluginId, value1, valuef)
  2763. elif action == ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  2764. self._set_parameterDefault(pluginId, value1, valuef)
  2765. elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED:
  2766. self._set_parameterMidiCC(pluginId, value1, value2)
  2767. elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  2768. self._set_parameterMidiChannel(pluginId, value1, value2)
  2769. elif action == ENGINE_CALLBACK_PROGRAM_CHANGED:
  2770. self._set_currentProgram(pluginId, value1)
  2771. elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  2772. self._set_currentMidiProgram(pluginId, value1)
  2773. # ------------------------------------------------------------------------------------------------------------