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.

3098 lines
96KB

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