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.

3794 lines
121KB

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