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.

3675 lines
117KB

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