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.

4011 lines
131KB

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