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.

3127 lines
98KB

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