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.

3143 lines
99KB

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