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.

3913 lines
125KB

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