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.

carla_backend.py 65KB

11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034
  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 ctypes import *
  20. from os import environ
  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 all UI events in a single/main thread.
  163. PLUGIN_NEEDS_SINGLE_THREAD = 0x200
  164. # ------------------------------------------------------------------------------------------------------------
  165. # Plugin Options
  166. # Various plugin options.
  167. # @see carla_get_plugin_info() and carla_set_option()
  168. # Use constant/fixed-size audio buffers.
  169. PLUGIN_OPTION_FIXED_BUFFERS = 0x001
  170. # Force mono plugin as stereo.
  171. PLUGIN_OPTION_FORCE_STEREO = 0x002
  172. # Map MIDI programs to plugin programs.
  173. PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004
  174. # Use chunks to save and restore data.
  175. PLUGIN_OPTION_USE_CHUNKS = 0x008
  176. # Send MIDI control change events.
  177. PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010
  178. # Send MIDI channel pressure events.
  179. PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020
  180. # Send MIDI note after-touch events.
  181. PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040
  182. # Send MIDI pitch-bend events.
  183. PLUGIN_OPTION_SEND_PITCHBEND = 0x080
  184. # Send MIDI all-sounds/notes-off events, single note-offs otherwise.
  185. PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100
  186. # ------------------------------------------------------------------------------------------------------------
  187. # Parameter Hints
  188. # Various parameter hints.
  189. # @see CarlaPlugin::getParameterData() and carla_get_parameter_data()
  190. # Parameter value is boolean.
  191. PARAMETER_IS_BOOLEAN = 0x001
  192. # Parameter value is integer.
  193. PARAMETER_IS_INTEGER = 0x002
  194. # Parameter value is logarithmic.
  195. PARAMETER_IS_LOGARITHMIC = 0x004
  196. # Parameter is enabled.
  197. # It can be viewed, changed and stored.
  198. PARAMETER_IS_ENABLED = 0x010
  199. # Parameter is automable (real-time safe).
  200. PARAMETER_IS_AUTOMABLE = 0x020
  201. # Parameter is read-only.
  202. # It cannot be changed.
  203. PARAMETER_IS_READ_ONLY = 0x040
  204. # Parameter needs sample rate to work.
  205. # Value and ranges are multiplied by sample rate on usage and divided by sample rate on save.
  206. PARAMETER_USES_SAMPLERATE = 0x100
  207. # Parameter uses scale points to define internal values in a meaningful way.
  208. PARAMETER_USES_SCALEPOINTS = 0x200
  209. # Parameter uses custom text for displaying its value.
  210. # @see carla_get_parameter_text()
  211. PARAMETER_USES_CUSTOM_TEXT = 0x400
  212. # ------------------------------------------------------------------------------------------------------------
  213. # Patchbay Port Hints
  214. # Various patchbay port hints.
  215. # Patchbay port is input.
  216. # When this hint is not set, port is assumed to be output.
  217. PATCHBAY_PORT_IS_INPUT = 0x1
  218. # Patchbay port is of Audio type.
  219. PATCHBAY_PORT_TYPE_AUDIO = 0x2
  220. # Patchbay port is of CV type (Control Voltage).
  221. PATCHBAY_PORT_TYPE_CV = 0x4
  222. # Patchbay port is of MIDI type.
  223. PATCHBAY_PORT_TYPE_MIDI = 0x8
  224. # ------------------------------------------------------------------------------------------------------------
  225. # Custom Data Types
  226. # These types define how the value in the CustomData struct is stored.
  227. # @see CustomData.type
  228. # Boolean string type URI.
  229. # Only "true" and "false" are valid values.
  230. CUSTOM_DATA_TYPE_BOOLEAN = "http://kxstudio.sf.net/ns/carla/boolean"
  231. # Chunk type URI.
  232. CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"
  233. # String type URI.
  234. CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string"
  235. # ------------------------------------------------------------------------------------------------------------
  236. # Custom Data Keys
  237. # Pre-defined keys used internally in Carla.
  238. # @see CustomData.key
  239. # Plugin options key.
  240. CUSTOM_DATA_KEY_PLUGIN_OPTIONS = "CarlaPluginOptions"
  241. # UI position key.
  242. CUSTOM_DATA_KEY_UI_POSITION = "CarlaUiPosition"
  243. # UI size key.
  244. CUSTOM_DATA_KEY_UI_SIZE = "CarlaUiSize"
  245. # UI visible key.
  246. CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUiVisible"
  247. # ------------------------------------------------------------------------------------------------------------
  248. # Binary Type
  249. # The binary type of a plugin.
  250. # Null binary type.
  251. BINARY_NONE = 0
  252. # POSIX 32bit binary.
  253. BINARY_POSIX32 = 1
  254. # POSIX 64bit binary.
  255. BINARY_POSIX64 = 2
  256. # Windows 32bit binary.
  257. BINARY_WIN32 = 3
  258. # Windows 64bit binary.
  259. BINARY_WIN64 = 4
  260. # Other binary type.
  261. BINARY_OTHER = 5
  262. # ------------------------------------------------------------------------------------------------------------
  263. # Plugin Type
  264. # Plugin type.
  265. # Some files are handled as if they were plugins.
  266. # Null plugin type.
  267. PLUGIN_NONE = 0
  268. # Internal plugin.
  269. PLUGIN_INTERNAL = 1
  270. # LADSPA plugin.
  271. PLUGIN_LADSPA = 2
  272. # DSSI plugin.
  273. PLUGIN_DSSI = 3
  274. # LV2 plugin.
  275. PLUGIN_LV2 = 4
  276. # VST plugin.
  277. PLUGIN_VST = 5
  278. # VST3 plugin.
  279. PLUGIN_VST3 = 6
  280. # AU plugin.
  281. # @note MacOS only
  282. PLUGIN_AU = 7
  283. # GIG file.
  284. PLUGIN_GIG = 8
  285. # SF2 file (SoundFont).
  286. PLUGIN_SF2 = 9
  287. # SFZ file.
  288. PLUGIN_SFZ = 10
  289. # ------------------------------------------------------------------------------------------------------------
  290. # Plugin Category
  291. # Plugin category, which describes the functionality of a plugin.
  292. # Null plugin category.
  293. PLUGIN_CATEGORY_NONE = 0
  294. # A synthesizer or generator.
  295. PLUGIN_CATEGORY_SYNTH = 1
  296. # A delay or reverb.
  297. PLUGIN_CATEGORY_DELAY = 2
  298. # An equalizer.
  299. PLUGIN_CATEGORY_EQ = 3
  300. # A filter.
  301. PLUGIN_CATEGORY_FILTER = 4
  302. # A distortion plugin.
  303. PLUGIN_CATEGORY_DISTORTION = 5
  304. # A 'dynamic' plugin (amplifier, compressor, gate, etc).
  305. PLUGIN_CATEGORY_DYNAMICS = 6
  306. # A 'modulator' plugin (chorus, flanger, phaser, etc).
  307. PLUGIN_CATEGORY_MODULATOR = 7
  308. # An 'utility' plugin (analyzer, converter, mixer, etc).
  309. PLUGIN_CATEGORY_UTILITY = 8
  310. # Miscellaneous plugin (used to check if the plugin has a category).
  311. PLUGIN_CATEGORY_OTHER = 9
  312. # ------------------------------------------------------------------------------------------------------------
  313. # Parameter Type
  314. # Plugin parameter type.
  315. # Null parameter type.
  316. PARAMETER_UNKNOWN = 0
  317. # Input parameter.
  318. PARAMETER_INPUT = 1
  319. # Ouput parameter.
  320. PARAMETER_OUTPUT = 2
  321. # ------------------------------------------------------------------------------------------------------------
  322. # Internal Parameter Index
  323. # Special parameters used internally in Carla.
  324. # Plugins do not know about their existence.
  325. # Null parameter.
  326. PARAMETER_NULL = -1
  327. # Active parameter, boolean type.
  328. # Default is 'false'.
  329. PARAMETER_ACTIVE = -2
  330. # Dry/Wet parameter.
  331. # Range 0.0...1.0; default is 1.0.
  332. PARAMETER_DRYWET = -3
  333. # Volume parameter.
  334. # Range 0.0...1.27; default is 1.0.
  335. PARAMETER_VOLUME = -4
  336. # Stereo Balance-Left parameter.
  337. # Range -1.0...1.0; default is -1.0.
  338. PARAMETER_BALANCE_LEFT = -5
  339. # Stereo Balance-Right parameter.
  340. # Range -1.0...1.0; default is 1.0.
  341. PARAMETER_BALANCE_RIGHT = -6
  342. # Mono Panning parameter.
  343. # Range -1.0...1.0; default is 0.0.
  344. PARAMETER_PANNING = -7
  345. # MIDI Control channel, integer type.
  346. # Range -1...15 (-1 = off).
  347. PARAMETER_CTRL_CHANNEL = -8
  348. # Max value, defined only for convenience.
  349. PARAMETER_MAX = -9
  350. # ------------------------------------------------------------------------------------------------------------
  351. # Engine Callback Opcode
  352. # Engine callback opcodes.
  353. # Front-ends must never block indefinitely during a callback.
  354. # @see EngineCallbackFunc and carla_set_engine_callback()
  355. # Debug.
  356. # This opcode is undefined and used only for testing purposes.
  357. ENGINE_CALLBACK_DEBUG = 0
  358. # A plugin has been added.
  359. # @a pluginId Plugin Id
  360. # @a valueStr Plugin name
  361. ENGINE_CALLBACK_PLUGIN_ADDED = 1
  362. # A plugin has been removed.
  363. # @a pluginId Plugin Id
  364. ENGINE_CALLBACK_PLUGIN_REMOVED = 2
  365. # A plugin has been renamed.
  366. # @a pluginId Plugin Id
  367. # @a valueStr New plugin name
  368. ENGINE_CALLBACK_PLUGIN_RENAMED = 3
  369. # A plugin has become unavailable.
  370. # @a pluginId Plugin Id
  371. # @a valueStr Related error string
  372. ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4
  373. # A parameter value has changed.
  374. # @a pluginId Plugin Id
  375. # @a value1 Parameter index
  376. # @a value3 New parameter value
  377. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5
  378. # A parameter default has changed.
  379. # @a pluginId Plugin Id
  380. # @a value1 Parameter index
  381. # @a value3 New default value
  382. ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6
  383. # A parameter's MIDI CC has changed.
  384. # @a pluginId Plugin Id
  385. # @a value1 Parameter index
  386. # @a value2 New MIDI CC
  387. ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7
  388. # A parameter's MIDI channel has changed.
  389. # @a pluginId Plugin Id
  390. # @a value1 Parameter index
  391. # @a value2 New MIDI channel
  392. ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8
  393. # A plugin option has changed.
  394. # @a pluginId Plugin Id
  395. # @a value1 Option
  396. # @a value2 New on/off state (1 for on, 0 for off)
  397. # @see PluginOptions
  398. ENGINE_CALLBACK_OPTION_CHANGED = 9
  399. # The current program of a plugin has changed.
  400. # @a pluginId Plugin Id
  401. # @a value1 New program index
  402. ENGINE_CALLBACK_PROGRAM_CHANGED = 10
  403. # The current MIDI program of a plugin has changed.
  404. # @a pluginId Plugin Id
  405. # @a value1 New MIDI program index
  406. ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 11
  407. # A plugin's custom UI state has changed.
  408. # @a pluginId Plugin Id
  409. # @a value1 New state, as follows:
  410. # 0: UI is now hidden
  411. # 1: UI is now visible
  412. # -1: UI has crashed and should not be shown again
  413. ENGINE_CALLBACK_UI_STATE_CHANGED = 12
  414. # A note has been pressed.
  415. # @a pluginId Plugin Id
  416. # @a value1 Channel
  417. # @a value2 Note
  418. # @a value3 Velocity
  419. ENGINE_CALLBACK_NOTE_ON = 13
  420. # A note has been released.
  421. # @a pluginId Plugin Id
  422. # @a value1 Channel
  423. # @a value2 Note
  424. ENGINE_CALLBACK_NOTE_OFF = 14
  425. # A plugin needs update.
  426. # @a pluginId Plugin Id
  427. ENGINE_CALLBACK_UPDATE = 15
  428. # A plugin's data/information has changed.
  429. # @a pluginId Plugin Id
  430. ENGINE_CALLBACK_RELOAD_INFO = 16
  431. # A plugin's parameters have changed.
  432. # @a pluginId Plugin Id
  433. ENGINE_CALLBACK_RELOAD_PARAMETERS = 17
  434. # A plugin's programs have changed.
  435. # @a pluginId Plugin Id
  436. ENGINE_CALLBACK_RELOAD_PROGRAMS = 18
  437. # A plugin state has changed.
  438. # @a pluginId Plugin Id
  439. ENGINE_CALLBACK_RELOAD_ALL = 19
  440. # A patchbay client has been added.
  441. # @a pluginId Client Id
  442. # @a value1 Client icon
  443. # @a value2 Plugin Id (-1 if not a plugin)
  444. # @a valueStr Client name
  445. # @see PatchbayIcon
  446. ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 20
  447. # A patchbay client has been removed.
  448. # @a pluginId Client Id
  449. ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 21
  450. # A patchbay client has been renamed.
  451. # @a pluginId Client Id
  452. # @a valueStr New client name
  453. ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 22
  454. # A patchbay client data has changed.
  455. # @a pluginId Client Id
  456. # @a value1 New icon
  457. # @a value2 New plugin Id (-1 if not a plugin)
  458. # @see PatchbayIcon
  459. ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 23
  460. # A patchbay port has been added.
  461. # @a pluginId Client Id
  462. # @a value1 Port Id
  463. # @a value2 Port hints
  464. # @a valueStr Port name
  465. # @see PatchbayPortHints
  466. ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 24
  467. # A patchbay port has been removed.
  468. # @a pluginId Client Id
  469. # @a value1 Port Id
  470. ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 25
  471. # A patchbay port has been renamed.
  472. # @a pluginId Client Id
  473. # @a value1 Port Id
  474. # @a valueStr New port name
  475. ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 26
  476. # A patchbay connection has been added.
  477. # @a pluginId Connection Id
  478. # @a valueStr Out group, port plus in group and port, in "og:op:ig:ip" syntax.
  479. ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27
  480. # A patchbay connection has been removed.
  481. # @a pluginId Connection Id
  482. ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28
  483. # Engine started.
  484. # @a value1 Process mode
  485. # @a value2 Transport mode
  486. # @a valuestr Engine driver
  487. # @see EngineProcessMode
  488. # @see EngineTransportMode
  489. ENGINE_CALLBACK_ENGINE_STARTED = 29
  490. # Engine stopped.
  491. ENGINE_CALLBACK_ENGINE_STOPPED = 30
  492. # Engine process mode has changed.
  493. # @a value1 New process mode
  494. # @see EngineProcessMode
  495. ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31
  496. # Engine transport mode has changed.
  497. # @a value1 New transport mode
  498. # @see EngineTransportMode
  499. ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32
  500. # Engine buffer-size changed.
  501. # @a value1 New buffer size
  502. ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33
  503. # Engine sample-rate changed.
  504. # @a value3 New sample rate
  505. ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34
  506. # Idle frontend.
  507. # This is used by the engine during long operations that might block the frontend,
  508. # giving it the possibility to idle while the operation is still in place.
  509. ENGINE_CALLBACK_IDLE = 35
  510. # Show a message as information.
  511. # @a valueStr The message
  512. ENGINE_CALLBACK_INFO = 36
  513. # Show a message as an error.
  514. # @a valueStr The message
  515. ENGINE_CALLBACK_ERROR = 37
  516. # The engine has crashed or malfunctioned and will no longer work.
  517. ENGINE_CALLBACK_QUIT = 38
  518. # ------------------------------------------------------------------------------------------------------------
  519. # Engine Option
  520. # Engine options.
  521. # @see carla_set_engine_option()
  522. # Debug.
  523. # This option is undefined and used only for testing purposes.
  524. ENGINE_OPTION_DEBUG = 0
  525. # Set the engine processing mode.
  526. # Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_CONTINUOUS_RACK for all other OSes.
  527. # @see EngineProcessMode
  528. ENGINE_OPTION_PROCESS_MODE = 1
  529. # Set the engine transport mode.
  530. # Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes.
  531. # @see EngineTransportMode
  532. ENGINE_OPTION_TRANSPORT_MODE = 2
  533. # Force mono plugins as stereo, by running 2 instances at the same time.
  534. # Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK.
  535. # @note Not supported by all plugins
  536. # @see PLUGIN_OPTION_FORCE_STEREO
  537. ENGINE_OPTION_FORCE_STEREO = 3
  538. # Use plugin bridges whenever possible.
  539. # Default is no, EXPERIMENTAL.
  540. ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4
  541. # Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.
  542. # Default is yes.
  543. ENGINE_OPTION_PREFER_UI_BRIDGES = 5
  544. # Make custom plugin UIs always-on-top.
  545. # Default is yes.
  546. ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6
  547. # Maximum number of parameters allowed.
  548. # Default is MAX_DEFAULT_PARAMETERS.
  549. ENGINE_OPTION_MAX_PARAMETERS = 7
  550. # Timeout value for how much to wait for UI bridges to respond, in milliseconds.
  551. # Default is 4000 (4 seconds).
  552. ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8
  553. # Number of audio periods.
  554. # Default is 2.
  555. ENGINE_OPTION_AUDIO_NUM_PERIODS = 9
  556. # Audio buffer size.
  557. # Default is 512.
  558. ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10
  559. # Audio sample rate.
  560. # Default is 44100.
  561. ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11
  562. # Audio device (within a driver).
  563. # Default unset.
  564. ENGINE_OPTION_AUDIO_DEVICE = 12
  565. # Set data needed for NSM support.
  566. ENGINE_OPTION_NSM_INIT = 13
  567. # Set path to the binary files.
  568. # Default unset.
  569. # @note Must be set for plugin and UI bridges to work
  570. ENGINE_OPTION_PATH_BINARIES = 14
  571. # Set path to the resource files.
  572. # Default unset.
  573. # @note Must be set for some internal plugins to work
  574. ENGINE_OPTION_PATH_RESOURCES = 15
  575. # Set frontend winId, used to define as parent window for plugin UIs.
  576. ENGINE_OPTION_FRONTEND_WIN_ID = 16
  577. # ------------------------------------------------------------------------------------------------------------
  578. # Engine Process Mode
  579. # Engine process mode.
  580. # @see ENGINE_OPTION_PROCESS_MODE
  581. # Single client mode.
  582. # Inputs and outputs are added dynamically as needed by plugins.
  583. ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0
  584. # Multiple client mode.
  585. # It has 1 master client + 1 client per plugin.
  586. ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1
  587. # Single client, 'rack' mode.
  588. # Processes plugins in order of Id, with forced stereo always on.
  589. ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2
  590. # Single client, 'patchbay' mode.
  591. ENGINE_PROCESS_MODE_PATCHBAY = 3
  592. # Special mode, used in plugin-bridges only.
  593. ENGINE_PROCESS_MODE_BRIDGE = 4
  594. # ------------------------------------------------------------------------------------------------------------
  595. # Engine Transport Mode
  596. # Engine transport mode.
  597. # @see ENGINE_OPTION_TRANSPORT_MODE
  598. # Internal transport mode.
  599. ENGINE_TRANSPORT_MODE_INTERNAL = 0
  600. # Transport from JACK.
  601. # Only available if driver name is "JACK".
  602. ENGINE_TRANSPORT_MODE_JACK = 1
  603. # Transport from host, used when Carla is a plugin.
  604. ENGINE_TRANSPORT_MODE_PLUGIN = 2
  605. # Special mode, used in plugin-bridges only.
  606. ENGINE_TRANSPORT_MODE_BRIDGE = 3
  607. # ------------------------------------------------------------------------------------------------------------
  608. # File Callback Opcode
  609. # File callback opcodes.
  610. # Front-ends must always block-wait for user input.
  611. # @see FileCallbackFunc and carla_set_file_callback()
  612. # Debug.
  613. # This opcode is undefined and used only for testing purposes.
  614. FILE_CALLBACK_DEBUG = 0
  615. # Open file or folder.
  616. FILE_CALLBACK_OPEN = 1
  617. # Save file or folder.
  618. FILE_CALLBACK_SAVE = 2
  619. # ------------------------------------------------------------------------------------------------------------
  620. # Patchbay Icon
  621. # The icon of a patchbay client/group.
  622. # Generic application icon.
  623. # Used for all non-plugin clients that don't have a specific icon.
  624. PATCHBAY_ICON_APPLICATION = 0
  625. # Plugin icon.
  626. # Used for all plugin clients that don't have a specific icon.
  627. PATCHBAY_ICON_PLUGIN = 1
  628. # Hardware icon.
  629. # Used for hardware (audio or MIDI) clients.
  630. PATCHBAY_ICON_HARDWARE = 2
  631. # Carla icon.
  632. # Used for the main app.
  633. PATCHBAY_ICON_CARLA = 3
  634. # DISTRHO icon.
  635. # Used for DISTRHO based plugins.
  636. PATCHBAY_ICON_DISTRHO = 4
  637. # File icon.
  638. # Used for file type plugins (like GIG and SF2).
  639. PATCHBAY_ICON_FILE = 5
  640. # ------------------------------------------------------------------------------------------------------------
  641. # Carla Backend API (C stuff)
  642. # Engine callback function.
  643. # Front-ends must never block indefinitely during a callback.
  644. # @see EngineCallbackOpcode and carla_set_engine_callback()
  645. EngineCallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_float, c_char_p)
  646. # File callback function.
  647. # @see FileCallbackOpcode
  648. FileCallbackFunc = CFUNCTYPE(c_char_p, c_void_p, c_enum, c_bool, c_char_p, c_char_p)
  649. # Parameter data.
  650. class ParameterData(Structure):
  651. _fields_ = [
  652. # This parameter type.
  653. ("type", c_enum),
  654. # This parameter hints.
  655. # @see ParameterHints
  656. ("hints", c_uint),
  657. # Index as seen by Carla.
  658. ("index", c_int32),
  659. # Real index as seen by plugins.
  660. ("rindex", c_int32),
  661. # Currently mapped MIDI CC.
  662. # A value lower than 0 means invalid or unused.
  663. # Maximum allowed value is 95 (0x5F).
  664. ("midiCC", c_int16),
  665. # Currently mapped MIDI channel.
  666. # Counts from 0 to 15.
  667. ("midiChannel", c_uint8)
  668. ]
  669. # Parameter ranges.
  670. class ParameterRanges(Structure):
  671. _fields_ = [
  672. # Default value.
  673. ("def", c_float),
  674. # Minimum value.
  675. ("min", c_float),
  676. # Maximum value.
  677. ("max", c_float),
  678. # Regular, single step value.
  679. ("step", c_float),
  680. # Small step value.
  681. ("stepSmall", c_float),
  682. # Large step value.
  683. ("stepLarge", c_float)
  684. ]
  685. # MIDI Program data.
  686. class MidiProgramData(Structure):
  687. _fields_ = [
  688. # MIDI bank.
  689. ("bank", c_uint32),
  690. # MIDI program.
  691. ("program", c_uint32),
  692. # MIDI program name.
  693. ("name", c_char_p)
  694. ]
  695. # Custom data, used for saving key:value 'dictionaries'.
  696. class CustomData(Structure):
  697. _fields_ = [
  698. # Value type, in URI form.
  699. # @see CustomDataTypes
  700. ("type", c_char_p),
  701. # Key.
  702. # @see CustomDataKeys
  703. ("key", c_char_p),
  704. # Value.
  705. ("value", c_char_p)
  706. ]
  707. # Engine driver device information.
  708. class EngineDriverDeviceInfo(Structure):
  709. _fields_ = [
  710. # This driver device hints.
  711. # @see EngineDriverHints
  712. ("hints", c_uint),
  713. # Available buffer sizes.
  714. # Terminated with 0.
  715. ("bufferSizes", POINTER(c_uint32)),
  716. # Available sample rates.
  717. # Terminated with 0.0.
  718. ("sampleRates", POINTER(c_double))
  719. ]
  720. # ------------------------------------------------------------------------------------------------------------
  721. # Carla Backend API (Python compatible stuff)
  722. # @see ParameterData
  723. PyParameterData = {
  724. 'type': PARAMETER_UNKNOWN,
  725. 'hints': 0x0,
  726. 'index': PARAMETER_NULL,
  727. 'rindex': -1,
  728. 'midiCC': -1,
  729. 'midiChannel': 0
  730. }
  731. # @see ParameterRanges
  732. PyParameterRanges = {
  733. 'def': 0.0,
  734. 'min': 0.0,
  735. 'max': 1.0,
  736. 'step': 0.01,
  737. 'stepSmall': 0.0001,
  738. 'stepLarge': 0.1
  739. }
  740. # @see MidiProgramData
  741. PyMidiProgramData = {
  742. 'bank': 0,
  743. 'program': 0,
  744. 'name': None
  745. }
  746. # @see CustomData
  747. PyCustomData = {
  748. 'type': None,
  749. 'key': None,
  750. 'value': None
  751. }
  752. # @see EngineDriverDeviceInfo
  753. PyEngineDriverDeviceInfo = {
  754. 'hints': 0x0,
  755. 'bufferSizes': [],
  756. 'sampleRates': []
  757. }
  758. # ------------------------------------------------------------------------------------------------------------
  759. # Carla Host API (C stuff)
  760. # Information about a loaded plugin.
  761. # @see carla_get_plugin_info()
  762. class CarlaPluginInfo(Structure):
  763. _fields_ = [
  764. # Plugin type.
  765. ("type", c_enum),
  766. # Plugin category.
  767. ("category", c_enum),
  768. # Plugin hints.
  769. # @see PluginHints
  770. ("hints", c_uint),
  771. # Plugin options available for the user to change.
  772. # @see PluginOptions
  773. ("optionsAvailable", c_uint),
  774. # Plugin options currently enabled.
  775. # Some options are enabled but not available, which means they will always be on.
  776. # @see PluginOptions
  777. ("optionsEnabled", c_uint),
  778. # Plugin filename.
  779. # This can be the plugin binary or resource file.
  780. ("filename", c_char_p),
  781. # Plugin name.
  782. # This name is unique within a Carla instance.
  783. # @see carla_get_real_plugin_name()
  784. ("name", c_char_p),
  785. # Plugin label or URI.
  786. ("label", c_char_p),
  787. # Plugin author/maker.
  788. ("maker", c_char_p),
  789. # Plugin copyright/license.
  790. ("copyright", c_char_p),
  791. # Icon name for this plugin, in lowercase.
  792. # Default is "plugin".
  793. ("iconName", c_char_p),
  794. # Plugin unique Id.
  795. # This Id is dependant on the plugin type and may sometimes be 0.
  796. ("uniqueId", c_int64)
  797. ]
  798. # Information about an internal Carla plugin.
  799. # @see carla_get_internal_plugin_info()
  800. class CarlaNativePluginInfo(Structure):
  801. _fields_ = [
  802. # Plugin category.
  803. ("category", c_enum),
  804. # Plugin hints.
  805. # @see PluginHints
  806. ("hints", c_uint),
  807. # Number of audio inputs.
  808. ("audioIns", c_uint32),
  809. # Number of audio outputs.
  810. ("audioOuts", c_uint32),
  811. # Number of MIDI inputs.
  812. ("midiIns", c_uint32),
  813. # Number of MIDI outputs.
  814. ("midiOuts", c_uint32),
  815. # Number of input parameters.
  816. ("parameterIns", c_uint32),
  817. # Number of output parameters.
  818. ("parameterOuts", c_uint32),
  819. # Plugin name.
  820. ("name", c_char_p),
  821. # Plugin label.
  822. ("label", c_char_p),
  823. # Plugin author/maker.
  824. ("maker", c_char_p),
  825. # Plugin copyright/license.
  826. ("copyright", c_char_p)
  827. ]
  828. # Port count information, used for Audio and MIDI ports and parameters.
  829. # @see carla_get_audio_port_count_info()
  830. # @see carla_get_midi_port_count_info()
  831. # @see carla_get_parameter_count_info()
  832. class CarlaPortCountInfo(Structure):
  833. _fields_ = [
  834. # Number of inputs.
  835. ("ins", c_uint32),
  836. # Number of outputs.
  837. ("outs", c_uint32)
  838. ]
  839. # Parameter information.
  840. # @see carla_get_parameter_info()
  841. class CarlaParameterInfo(Structure):
  842. _fields_ = [
  843. # Parameter name.
  844. ("name", c_char_p),
  845. # Parameter symbol.
  846. ("symbol", c_char_p),
  847. # Parameter unit.
  848. ("unit", c_char_p),
  849. # Number of scale points.
  850. # @see CarlaScalePointInfo
  851. ("scalePointCount", c_uint32)
  852. ]
  853. # Parameter scale point information.
  854. # @see carla_get_parameter_scalepoint_info()
  855. class CarlaScalePointInfo(Structure):
  856. _fields_ = [
  857. # Scale point value.
  858. ("value", c_float),
  859. # Scale point label.
  860. ("label", c_char_p)
  861. ]
  862. # Transport information.
  863. # @see carla_get_transport_info()
  864. class CarlaTransportInfo(Structure):
  865. _fields_ = [
  866. # Wherever transport is playing.
  867. ("playing", c_bool),
  868. # Current transport frame.
  869. ("frame", c_uint64),
  870. # Bar
  871. ("bar", c_int32),
  872. # Beat
  873. ("beat", c_int32),
  874. # Tick
  875. ("tick", c_int32),
  876. # Beats per minute.
  877. ("bpm", c_double)
  878. ]
  879. # ------------------------------------------------------------------------------------------------------------
  880. # Carla Host API (Python compatible stuff)
  881. # @see CarlaPluginInfo
  882. PyCarlaPluginInfo = {
  883. 'type': PLUGIN_NONE,
  884. 'category': PLUGIN_CATEGORY_NONE,
  885. 'hints': 0x0,
  886. 'optionsAvailable': 0x0,
  887. 'optionsEnabled': 0x0,
  888. 'filename': None,
  889. 'name': None,
  890. 'label': None,
  891. 'maker': None,
  892. 'copyright': None,
  893. 'iconName': None,
  894. 'uniqueId': 0
  895. }
  896. # @see CarlaPortCountInfo
  897. PyCarlaPortCountInfo = {
  898. 'ins': 0,
  899. 'outs': 0
  900. }
  901. # @see CarlaParameterInfo
  902. PyCarlaParameterInfo = {
  903. 'name': None,
  904. 'symbol': None,
  905. 'unit': None,
  906. 'scalePointCount': 0,
  907. }
  908. # @see CarlaScalePointInfo
  909. PyCarlaScalePointInfo = {
  910. 'value': 0.0,
  911. 'label': None
  912. }
  913. # @see CarlaTransportInfo
  914. PyCarlaTransportInfo = {
  915. "playing": False,
  916. "frame": 0,
  917. "bar": 0,
  918. "beat": 0,
  919. "tick": 0,
  920. "bpm": 0.0
  921. }
  922. # ------------------------------------------------------------------------------------------------------------
  923. # Set BINARY_NATIVE
  924. if HAIKU or LINUX or MACOS:
  925. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  926. elif WINDOWS:
  927. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  928. else:
  929. BINARY_NATIVE = BINARY_OTHER
  930. # ------------------------------------------------------------------------------------------------------------
  931. # Python Host object (Control/Standalone)
  932. class Host(object):
  933. def __init__(self, libName):
  934. object.__init__(self)
  935. self._init(libName)
  936. # Get the complete license text of used third-party code and features.
  937. # Returned string is in basic html format.
  938. def get_complete_license_text(self):
  939. return charPtrToString(self.lib.carla_get_complete_license_text())
  940. # Get the juce version used in the current Carla build.
  941. def get_juce_version(self):
  942. return charPtrToString(self.lib.carla_get_juce_version())
  943. # Get all the supported file extensions in carla_load_file().
  944. # Returned string uses this syntax:
  945. # @code
  946. # "*.ext1;*.ext2;*.ext3"
  947. # @endcode
  948. def get_supported_file_extensions(self):
  949. return charPtrToString(self.lib.carla_get_supported_file_extensions())
  950. # Get how many engine drivers are available.
  951. def get_engine_driver_count(self):
  952. return int(self.lib.carla_get_engine_driver_count())
  953. # Get an engine driver name.
  954. # @param index Driver index
  955. def get_engine_driver_name(self, index):
  956. return charPtrToString(self.lib.carla_get_engine_driver_name(index))
  957. # Get the device names of an engine driver.
  958. # @param index Driver index
  959. def get_engine_driver_device_names(self, index):
  960. return charPtrPtrToStringList(self.lib.carla_get_engine_driver_device_names(index))
  961. # Get information about a device driver.
  962. # @param index Driver index
  963. # @param name Device name
  964. def get_engine_driver_device_info(self, index, name):
  965. return structToDict(self.lib.carla_get_engine_driver_device_info(index, name.encode("utf-8")).contents)
  966. # Get how many internal plugins are available.
  967. def get_internal_plugin_count(self):
  968. return int(self.lib.carla_get_internal_plugin_count())
  969. # Get information about an internal plugin.
  970. # @param index Internal plugin Id
  971. def get_internal_plugin_info(self, index):
  972. return structToDict(self.lib.carla_get_internal_plugin_info(index).contents)
  973. # Initialize the engine.
  974. # Make sure to call carla_engine_idle() at regular intervals afterwards.
  975. # @param driverName Driver to use
  976. # @param clientName Engine master client name
  977. def engine_init(self, driverName, clientName):
  978. return bool(self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8")))
  979. # Close the engine.
  980. # This function always closes the engine even if it returns false.
  981. # In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
  982. def engine_close(self):
  983. return bool(self.lib.carla_engine_close())
  984. # Idle the engine.
  985. # Do not call this if the engine is not running.
  986. def engine_idle(self):
  987. self.lib.carla_engine_idle()
  988. # Check if the engine is running.
  989. def is_engine_running(self):
  990. return bool(self.lib.carla_is_engine_running())
  991. # Tell the engine it's about to close.
  992. # This is used to prevent the engine thread(s) from reactivating.
  993. def set_engine_about_to_close(self):
  994. self.lib.carla_set_engine_about_to_close()
  995. # Set the engine callback function.
  996. # @param func Callback function
  997. def set_engine_callback(self, func):
  998. self._engineCallback = EngineCallbackFunc(func)
  999. self.lib.carla_set_engine_callback(self._engineCallback, None)
  1000. # Set an engine option.
  1001. # @param option Option
  1002. # @param value Value as number
  1003. # @param valueStr Value as string
  1004. def set_engine_option(self, option, value, valueStr):
  1005. self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))
  1006. # Set the file callback function.
  1007. # @param func Callback function
  1008. # @param ptr Callback pointer
  1009. def set_file_callback(self, func):
  1010. self._fileCallback = FileCallbackFunc(func)
  1011. self.lib.carla_set_file_callback(self._fileCallback, None)
  1012. # Load a file of any type.
  1013. # This will try to load a generic file as a plugin,
  1014. # either by direct handling (GIG, SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
  1015. # @see carla_get_supported_file_extensions()
  1016. def load_file(self, filename):
  1017. return bool(self.lib.carla_load_file(filename.encode("utf-8")))
  1018. # Load a Carla project file.
  1019. # @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
  1020. def load_project(self, filename):
  1021. return bool(self.lib.carla_load_project(filename.encode("utf-8")))
  1022. # Save current project to a file.
  1023. def save_project(self, filename):
  1024. return bool(self.lib.carla_save_project(filename.encode("utf-8")))
  1025. # Connect two patchbay ports.
  1026. # @param groupIdA Output group
  1027. # @param portIdA Output port
  1028. # @param groupIdB Input group
  1029. # @param portIdB Input port
  1030. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED
  1031. def patchbay_connect(self, groupIdA, portIdA, groupIdB, portIdB):
  1032. return bool(self.lib.carla_patchbay_connect(groupIdA, portIdA, groupIdB, portIdB))
  1033. # Disconnect two patchbay ports.
  1034. # @param connectionId Connection Id
  1035. # @see ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED
  1036. def patchbay_disconnect(self, connectionId):
  1037. return bool(self.lib.carla_patchbay_disconnect(connectionId))
  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. def patchbay_refresh(self, external):
  1042. return bool(self.lib.carla_patchbay_refresh(external))
  1043. # Start playback of the engine transport.
  1044. def transport_play(self):
  1045. self.lib.carla_transport_play()
  1046. # Pause the engine transport.
  1047. def transport_pause(self):
  1048. self.lib.carla_transport_pause()
  1049. # Relocate the engine transport to a specific frame.
  1050. def transport_relocate(self, frame):
  1051. self.lib.carla_transport_relocate(frame)
  1052. # Get the current transport frame.
  1053. def get_current_transport_frame(self):
  1054. return bool(self.lib.carla_get_current_transport_frame())
  1055. # Get the engine transport information.
  1056. def get_transport_info(self):
  1057. return structToDict(self.lib.carla_get_transport_info().contents)
  1058. # Add a new plugin.
  1059. # If you don't know the binary type use the BINARY_NATIVE macro.
  1060. # @param btype Binary type
  1061. # @param ptype Plugin type
  1062. # @param filename Filename, if applicable
  1063. # @param name Name of the plugin, can be NULL
  1064. # @param label Plugin label, if applicable
  1065. # @param uniqueId Plugin unique Id, if applicable
  1066. # @param extraPtr Extra pointer, defined per plugin type
  1067. def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr):
  1068. cfilename = filename.encode("utf-8") if filename else None
  1069. cname = name.encode("utf-8") if name else None
  1070. clabel = label.encode("utf-8") if label else None
  1071. return bool(self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, uniqueId, cast(extraPtr, c_void_p)))
  1072. # Remove a plugin.
  1073. # @param pluginId Plugin to remove.
  1074. def remove_plugin(self, pluginId):
  1075. return bool(self.lib.carla_remove_plugin(pluginId))
  1076. # Remove all plugins.
  1077. def remove_all_plugins(self):
  1078. return bool(self.lib.carla_remove_all_plugins())
  1079. # Rename a plugin.
  1080. # Returns the new name, or NULL if the operation failed.
  1081. # @param pluginId Plugin to rename
  1082. # @param newName New plugin name
  1083. def rename_plugin(self, pluginId, newName):
  1084. return charPtrToString(self.lib.carla_rename_plugin(pluginId, newName.encode("utf-8")))
  1085. # Clone a plugin.
  1086. # @param pluginId Plugin to clone
  1087. def clone_plugin(self, pluginId):
  1088. return bool(self.lib.carla_clone_plugin(pluginId))
  1089. # Prepare replace of a plugin.
  1090. # The next call to carla_add_plugin() will use this id, replacing the current plugin.
  1091. # @param pluginId Plugin to replace
  1092. # @note This function requires carla_add_plugin() to be called afterwards *as soon as possible*.
  1093. def replace_plugin(self, pluginId):
  1094. return bool(self.lib.carla_replace_plugin(pluginId))
  1095. # Switch two plugins positions.
  1096. # @param pluginIdA Plugin A
  1097. # @param pluginIdB Plugin B
  1098. def switch_plugins(self, pluginIdA, pluginIdB):
  1099. return bool(self.lib.carla_switch_plugins(pluginIdA, pluginIdB))
  1100. # Load a plugin state.
  1101. # @param pluginId Plugin
  1102. # @param filename Path to plugin state
  1103. # @see carla_save_plugin_state()
  1104. def load_plugin_state(self, pluginId, filename):
  1105. return bool(self.lib.carla_load_plugin_state(pluginId, filename.encode("utf-8")))
  1106. # Save a plugin state.
  1107. # @param pluginId Plugin
  1108. # @param filename Path to plugin state
  1109. # @see carla_load_plugin_state()
  1110. def save_plugin_state(self, pluginId, filename):
  1111. return bool(self.lib.carla_save_plugin_state(pluginId, filename.encode("utf-8")))
  1112. # Get information from a plugin.
  1113. # @param pluginId Plugin
  1114. def get_plugin_info(self, pluginId):
  1115. return structToDict(self.lib.carla_get_plugin_info(pluginId).contents)
  1116. # Get audio port count information from a plugin.
  1117. # @param pluginId Plugin
  1118. def get_audio_port_count_info(self, pluginId):
  1119. return structToDict(self.lib.carla_get_audio_port_count_info(pluginId).contents)
  1120. # Get MIDI port count information from a plugin.
  1121. # @param pluginId Plugin
  1122. def get_midi_port_count_info(self, pluginId):
  1123. return structToDict(self.lib.carla_get_midi_port_count_info(pluginId).contents)
  1124. # Get parameter count information from a plugin.
  1125. # @param pluginId Plugin
  1126. def get_parameter_count_info(self, pluginId):
  1127. return structToDict(self.lib.carla_get_parameter_count_info(pluginId).contents)
  1128. # Get parameter information from a plugin.
  1129. # @param pluginId Plugin
  1130. # @param parameterId Parameter index
  1131. # @see carla_get_parameter_count()
  1132. def get_parameter_info(self, pluginId, parameterId):
  1133. return structToDict(self.lib.carla_get_parameter_info(pluginId, parameterId).contents)
  1134. # Get parameter scale point information from a plugin.
  1135. # @param pluginId Plugin
  1136. # @param parameterId Parameter index
  1137. # @param scalePointId Parameter scale-point index
  1138. # @see CarlaParameterInfo::scalePointCount
  1139. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  1140. return structToDict(self.lib.carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId).contents)
  1141. # Get a plugin's parameter data.
  1142. # @param pluginId Plugin
  1143. # @param parameterId Parameter index
  1144. # @see carla_get_parameter_count()
  1145. def get_parameter_data(self, pluginId, parameterId):
  1146. return structToDict(self.lib.carla_get_parameter_data(pluginId, parameterId).contents)
  1147. # Get a plugin's parameter ranges.
  1148. # @param pluginId Plugin
  1149. # @param parameterId Parameter index
  1150. # @see carla_get_parameter_count()
  1151. def get_parameter_ranges(self, pluginId, parameterId):
  1152. return structToDict(self.lib.carla_get_parameter_ranges(pluginId, parameterId).contents)
  1153. # Get a plugin's MIDI program data.
  1154. # @param pluginId Plugin
  1155. # @param midiProgramId MIDI Program index
  1156. # @see carla_get_midi_program_count()
  1157. def get_midi_program_data(self, pluginId, midiProgramId):
  1158. return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents)
  1159. # Get a plugin's custom data.
  1160. # @param pluginId Plugin
  1161. # @param customDataId Custom data index
  1162. # @see carla_get_custom_data_count()
  1163. def get_custom_data(self, pluginId, customDataId):
  1164. return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents)
  1165. # Get a plugin's chunk data.
  1166. # @param pluginId Plugin
  1167. # @see PLUGIN_OPTION_USE_CHUNKS
  1168. def get_chunk_data(self, pluginId):
  1169. return charPtrToString(self.lib.carla_get_chunk_data(pluginId))
  1170. # Get how many parameters a plugin has.
  1171. # @param pluginId Plugin
  1172. def get_parameter_count(self, pluginId):
  1173. return int(self.lib.carla_get_parameter_count(pluginId))
  1174. # Get how many programs a plugin has.
  1175. # @param pluginId Plugin
  1176. # @see carla_get_program_name()
  1177. def get_program_count(self, pluginId):
  1178. return int(self.lib.carla_get_program_count(pluginId))
  1179. # Get how many MIDI programs a plugin has.
  1180. # @param pluginId Plugin
  1181. # @see carla_get_midi_program_name() and carla_get_midi_program_data()
  1182. def get_midi_program_count(self, pluginId):
  1183. return int(self.lib.carla_get_midi_program_count(pluginId))
  1184. # Get how many custom data sets a plugin has.
  1185. # @param pluginId Plugin
  1186. # @see carla_get_custom_data()
  1187. def get_custom_data_count(self, pluginId):
  1188. return int(self.lib.carla_get_custom_data_count(pluginId))
  1189. # Get a plugin's parameter text (custom display of internal values).
  1190. # @param pluginId Plugin
  1191. # @param parameterId Parameter index
  1192. # @see PARAMETER_USES_CUSTOM_TEXT
  1193. def get_parameter_text(self, pluginId, parameterId):
  1194. return charPtrToString(self.lib.carla_get_parameter_text(pluginId, parameterId))
  1195. # Get a plugin's program name.
  1196. # @param pluginId Plugin
  1197. # @param programId Program index
  1198. # @see carla_get_program_count()
  1199. def get_program_name(self, pluginId, programId):
  1200. return charPtrToString(self.lib.carla_get_program_name(pluginId, programId))
  1201. # Get a plugin's MIDI program name.
  1202. # @param pluginId Plugin
  1203. # @param midiProgramId MIDI Program index
  1204. # @see carla_get_midi_program_count()
  1205. def get_midi_program_name(self, pluginId, midiProgramId):
  1206. return charPtrToString(self.lib.carla_get_midi_program_name(pluginId, midiProgramId))
  1207. # Get a plugin's real name.
  1208. # This is the name the plugin uses to identify itself; may not be unique.
  1209. # @param pluginId Plugin
  1210. def get_real_plugin_name(self, pluginId):
  1211. return charPtrToString(self.lib.carla_get_real_plugin_name(pluginId))
  1212. # Get a plugin's program index.
  1213. # @param pluginId Plugin
  1214. def get_current_program_index(self, pluginId):
  1215. return int(self.lib.carla_get_current_program_index(pluginId))
  1216. # Get a plugin's midi program index.
  1217. # @param pluginId Plugin
  1218. def get_current_midi_program_index(self, pluginId):
  1219. return int(self.lib.carla_get_current_midi_program_index(pluginId))
  1220. # Get a plugin's default parameter value.
  1221. # @param pluginId Plugin
  1222. # @param parameterId Parameter index
  1223. def get_default_parameter_value(self, pluginId, parameterId):
  1224. return float(self.lib.carla_get_default_parameter_value(pluginId, parameterId))
  1225. # Get a plugin's current parameter value.
  1226. # @param pluginId Plugin
  1227. # @param parameterId Parameter index
  1228. def get_current_parameter_value(self, pluginId, parameterId):
  1229. return float(self.lib.carla_get_current_parameter_value(pluginId, parameterId))
  1230. # Get a plugin's internal parameter value.
  1231. # @param pluginId Plugin
  1232. # @param parameterId Parameter index, maybe be negative
  1233. # @see InternalParameterIndex
  1234. def get_internal_parameter_value(self, pluginId, parameterId):
  1235. return float(self.lib.carla_get_internal_parameter_value(pluginId, parameterId))
  1236. # Get a plugin's input peak value.
  1237. # @param pluginId Plugin
  1238. # @param isLeft Wherever to get the left/mono value, otherwise right.
  1239. def get_input_peak_value(self, pluginId, isLeft):
  1240. return float(self.lib.carla_get_input_peak_value(pluginId, isLeft))
  1241. # Get a plugin's output peak value.
  1242. # @param pluginId Plugin
  1243. # @param isLeft Wherever to get the left/mono value, otherwise right.
  1244. def get_output_peak_value(self, pluginId, isLeft):
  1245. return float(self.lib.carla_get_output_peak_value(pluginId, isLeft))
  1246. # Enable a plugin's option.
  1247. # @param pluginId Plugin
  1248. # @param option An option from PluginOptions
  1249. # @param yesNo New enabled state
  1250. def set_option(self, pluginId, option, yesNo):
  1251. self.lib.carla_set_option(pluginId, option, yesNo)
  1252. # Enable or disable a plugin.
  1253. # @param pluginId Plugin
  1254. # @param onOff New active state
  1255. def set_active(self, pluginId, onOff):
  1256. self.lib.carla_set_active(pluginId, onOff)
  1257. # Change a plugin's internal dry/wet.
  1258. # @param pluginId Plugin
  1259. # @param value New dry/wet value
  1260. def set_drywet(self, pluginId, value):
  1261. self.lib.carla_set_drywet(pluginId, value)
  1262. # Change a plugin's internal volume.
  1263. # @param pluginId Plugin
  1264. # @param value New volume
  1265. def set_volume(self, pluginId, value):
  1266. self.lib.carla_set_volume(pluginId, value)
  1267. # Change a plugin's internal stereo balance, left channel.
  1268. # @param pluginId Plugin
  1269. # @param value New value
  1270. def set_balance_left(self, pluginId, value):
  1271. self.lib.carla_set_balance_left(pluginId, value)
  1272. # Change a plugin's internal stereo balance, right channel.
  1273. # @param pluginId Plugin
  1274. # @param value New value
  1275. def set_balance_right(self, pluginId, value):
  1276. self.lib.carla_set_balance_right(pluginId, value)
  1277. # Change a plugin's internal mono panning value.
  1278. # @param pluginId Plugin
  1279. # @param value New value
  1280. def set_panning(self, pluginId, value):
  1281. self.lib.carla_set_panning(pluginId, value)
  1282. # Change a plugin's internal control channel.
  1283. # @param pluginId Plugin
  1284. # @param channel New channel
  1285. def set_ctrl_channel(self, pluginId, channel):
  1286. self.lib.carla_set_ctrl_channel(pluginId, channel)
  1287. # Change a plugin's parameter value.
  1288. # @param pluginId Plugin
  1289. # @param parameterId Parameter index
  1290. # @param value New value
  1291. def set_parameter_value(self, pluginId, parameterId, value):
  1292. self.lib.carla_set_parameter_value(pluginId, parameterId, value)
  1293. # Change a plugin's parameter MIDI cc.
  1294. # @param pluginId Plugin
  1295. # @param parameterId Parameter index
  1296. # @param cc New MIDI cc
  1297. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  1298. self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel)
  1299. # Change a plugin's parameter MIDI channel.
  1300. # @param pluginId Plugin
  1301. # @param parameterId Parameter index
  1302. # @param channel New MIDI channel
  1303. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  1304. self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc)
  1305. # Change a plugin's current program.
  1306. # @param pluginId Plugin
  1307. # @param programId New program
  1308. def set_program(self, pluginId, programId):
  1309. self.lib.carla_set_program(pluginId, programId)
  1310. # Change a plugin's current MIDI program.
  1311. # @param pluginId Plugin
  1312. # @param midiProgramId New value
  1313. def set_midi_program(self, pluginId, midiProgramId):
  1314. self.lib.carla_set_midi_program(pluginId, midiProgramId)
  1315. # Set a plugin's custom data set.
  1316. # @param pluginId Plugin
  1317. # @param type Type
  1318. # @param key Key
  1319. # @param value New value
  1320. # @see CustomDataTypes and CustomDataKeys
  1321. def set_custom_data(self, pluginId, type_, key, value):
  1322. self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8"))
  1323. # Set a plugin's chunk data.
  1324. # @param pluginId Plugin
  1325. # @param chunkData New chunk data
  1326. # @see PLUGIN_OPTION_USE_CHUNKS and carla_get_chunk_data()
  1327. def set_chunk_data(self, pluginId, chunkData):
  1328. self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8"))
  1329. # Tell a plugin to prepare for save.
  1330. # This should be called before saving custom data sets.
  1331. # @param pluginId Plugin
  1332. def prepare_for_save(self, pluginId):
  1333. self.lib.carla_prepare_for_save(pluginId)
  1334. # Reset all plugin's parameters.
  1335. # @param pluginId Plugin
  1336. def reset_parameters(self, pluginId):
  1337. self.lib.carla_reset_parameters(pluginId)
  1338. # Randomize all plugin's parameters.
  1339. # @param pluginId Plugin
  1340. def randomize_parameters(self, pluginId):
  1341. self.lib.carla_randomize_parameters(pluginId)
  1342. # Send a single note of a plugin.
  1343. # If velocity is 0, note-off is sent; note-on otherwise.
  1344. # @param pluginId Plugin
  1345. # @param channel Note channel
  1346. # @param note Note pitch
  1347. # @param velocity Note velocity
  1348. def send_midi_note(self, pluginId, channel, note, velocity):
  1349. self.lib.carla_send_midi_note(pluginId, channel, note, velocity)
  1350. # Tell a plugin to show its own custom UI.
  1351. # @param pluginId Plugin
  1352. # @param yesNo New UI state, visible or not
  1353. # @see PLUGIN_HAS_CUSTOM_UI
  1354. def show_custom_ui(self, pluginId, yesNo):
  1355. self.lib.carla_show_custom_ui(pluginId, yesNo)
  1356. # Get the current engine buffer size.
  1357. def get_buffer_size(self):
  1358. return int(self.lib.carla_get_buffer_size())
  1359. # Get the current engine sample rate.
  1360. def get_sample_rate(self):
  1361. return float(self.lib.carla_get_sample_rate())
  1362. # Get the last error.
  1363. def get_last_error(self):
  1364. return charPtrToString(self.lib.carla_get_last_error())
  1365. # Get the current engine OSC URL (TCP).
  1366. def get_host_osc_url_tcp(self):
  1367. return charPtrToString(self.lib.carla_get_host_osc_url_tcp())
  1368. # Get the current engine OSC URL (UDP).
  1369. def get_host_osc_url_udp(self):
  1370. return charPtrToString(self.lib.carla_get_host_osc_url_udp())
  1371. # extra
  1372. def setenv(self, key, value):
  1373. environ[key] = value
  1374. if WINDOWS:
  1375. keyvalue = "%s=%s" % (key, value)
  1376. self.msvcrt._putenv(keyvalue.encode("utf-8"))
  1377. # extra
  1378. def unsetenv(self, key):
  1379. environ.pop(key)
  1380. if WINDOWS:
  1381. keyrm = "%s=" % key
  1382. self.msvcrt._putenv(keyrm.encode("utf-8"))
  1383. def _init(self, libName):
  1384. self.lib = cdll.LoadLibrary(libName)
  1385. self.lib.carla_get_complete_license_text.argtypes = None
  1386. self.lib.carla_get_complete_license_text.restype = c_char_p
  1387. self.lib.carla_get_juce_version.argtypes = None
  1388. self.lib.carla_get_juce_version.restype = c_char_p
  1389. self.lib.carla_get_supported_file_extensions.argtypes = None
  1390. self.lib.carla_get_supported_file_extensions.restype = c_char_p
  1391. self.lib.carla_get_engine_driver_count.argtypes = None
  1392. self.lib.carla_get_engine_driver_count.restype = c_uint
  1393. self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
  1394. self.lib.carla_get_engine_driver_name.restype = c_char_p
  1395. self.lib.carla_get_engine_driver_device_names.argtypes = [c_uint]
  1396. self.lib.carla_get_engine_driver_device_names.restype = POINTER(c_char_p)
  1397. self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p]
  1398. self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo)
  1399. self.lib.carla_get_internal_plugin_count.argtypes = None
  1400. self.lib.carla_get_internal_plugin_count.restype = c_uint
  1401. self.lib.carla_get_internal_plugin_info.argtypes = [c_uint]
  1402. self.lib.carla_get_internal_plugin_info.restype = POINTER(CarlaNativePluginInfo)
  1403. self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p]
  1404. self.lib.carla_engine_init.restype = c_bool
  1405. self.lib.carla_engine_close.argtypes = None
  1406. self.lib.carla_engine_close.restype = c_bool
  1407. self.lib.carla_engine_idle.argtypes = None
  1408. self.lib.carla_engine_idle.restype = None
  1409. self.lib.carla_is_engine_running.argtypes = None
  1410. self.lib.carla_is_engine_running.restype = c_bool
  1411. self.lib.carla_set_engine_about_to_close.argtypes = None
  1412. self.lib.carla_set_engine_about_to_close.restype = None
  1413. self.lib.carla_set_engine_callback.argtypes = [EngineCallbackFunc, c_void_p]
  1414. self.lib.carla_set_engine_callback.restype = None
  1415. self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
  1416. self.lib.carla_set_engine_option.restype = None
  1417. self.lib.carla_set_file_callback.argtypes = [FileCallbackFunc, c_void_p]
  1418. self.lib.carla_set_file_callback.restype = None
  1419. self.lib.carla_load_file.argtypes = [c_char_p]
  1420. self.lib.carla_load_file.restype = c_bool
  1421. self.lib.carla_load_project.argtypes = [c_char_p]
  1422. self.lib.carla_load_project.restype = c_bool
  1423. self.lib.carla_save_project.argtypes = [c_char_p]
  1424. self.lib.carla_save_project.restype = c_bool
  1425. self.lib.carla_patchbay_connect.argtypes = [c_uint, c_uint, c_uint, c_uint]
  1426. self.lib.carla_patchbay_connect.restype = c_bool
  1427. self.lib.carla_patchbay_disconnect.argtypes = [c_uint]
  1428. self.lib.carla_patchbay_disconnect.restype = c_bool
  1429. self.lib.carla_patchbay_refresh.argtypes = [c_bool]
  1430. self.lib.carla_patchbay_refresh.restype = c_bool
  1431. self.lib.carla_transport_play.argtypes = None
  1432. self.lib.carla_transport_play.restype = None
  1433. self.lib.carla_transport_pause.argtypes = None
  1434. self.lib.carla_transport_pause.restype = None
  1435. self.lib.carla_transport_relocate.argtypes = [c_uint64]
  1436. self.lib.carla_transport_relocate.restype = None
  1437. self.lib.carla_get_current_transport_frame.argtypes = None
  1438. self.lib.carla_get_current_transport_frame.restype = c_uint64
  1439. self.lib.carla_get_transport_info.argtypes = None
  1440. self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)
  1441. self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_int64, c_void_p]
  1442. self.lib.carla_add_plugin.restype = c_bool
  1443. self.lib.carla_remove_plugin.argtypes = [c_uint]
  1444. self.lib.carla_remove_plugin.restype = c_bool
  1445. self.lib.carla_remove_all_plugins.argtypes = None
  1446. self.lib.carla_remove_all_plugins.restype = c_bool
  1447. self.lib.carla_rename_plugin.argtypes = [c_uint, c_char_p]
  1448. self.lib.carla_rename_plugin.restype = c_char_p
  1449. self.lib.carla_clone_plugin.argtypes = [c_uint]
  1450. self.lib.carla_clone_plugin.restype = c_bool
  1451. self.lib.carla_replace_plugin.argtypes = [c_uint]
  1452. self.lib.carla_replace_plugin.restype = c_bool
  1453. self.lib.carla_switch_plugins.argtypes = [c_uint, c_uint]
  1454. self.lib.carla_switch_plugins.restype = c_bool
  1455. self.lib.carla_load_plugin_state.argtypes = [c_uint, c_char_p]
  1456. self.lib.carla_load_plugin_state.restype = c_bool
  1457. self.lib.carla_save_plugin_state.argtypes = [c_uint, c_char_p]
  1458. self.lib.carla_save_plugin_state.restype = c_bool
  1459. self.lib.carla_get_plugin_info.argtypes = [c_uint]
  1460. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  1461. self.lib.carla_get_audio_port_count_info.argtypes = [c_uint]
  1462. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1463. self.lib.carla_get_midi_port_count_info.argtypes = [c_uint]
  1464. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  1465. self.lib.carla_get_parameter_count_info.argtypes = [c_uint]
  1466. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  1467. self.lib.carla_get_parameter_info.argtypes = [c_uint, c_uint32]
  1468. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  1469. self.lib.carla_get_parameter_scalepoint_info.argtypes = [c_uint, c_uint32, c_uint32]
  1470. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  1471. self.lib.carla_get_parameter_data.argtypes = [c_uint, c_uint32]
  1472. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  1473. self.lib.carla_get_parameter_ranges.argtypes = [c_uint, c_uint32]
  1474. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  1475. self.lib.carla_get_midi_program_data.argtypes = [c_uint, c_uint32]
  1476. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  1477. self.lib.carla_get_custom_data.argtypes = [c_uint, c_uint32]
  1478. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  1479. self.lib.carla_get_chunk_data.argtypes = [c_uint]
  1480. self.lib.carla_get_chunk_data.restype = c_char_p
  1481. self.lib.carla_get_parameter_count.argtypes = [c_uint]
  1482. self.lib.carla_get_parameter_count.restype = c_uint32
  1483. self.lib.carla_get_program_count.argtypes = [c_uint]
  1484. self.lib.carla_get_program_count.restype = c_uint32
  1485. self.lib.carla_get_midi_program_count.argtypes = [c_uint]
  1486. self.lib.carla_get_midi_program_count.restype = c_uint32
  1487. self.lib.carla_get_custom_data_count.argtypes = [c_uint]
  1488. self.lib.carla_get_custom_data_count.restype = c_uint32
  1489. self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32]
  1490. self.lib.carla_get_parameter_text.restype = c_char_p
  1491. self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32]
  1492. self.lib.carla_get_program_name.restype = c_char_p
  1493. self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32]
  1494. self.lib.carla_get_midi_program_name.restype = c_char_p
  1495. self.lib.carla_get_real_plugin_name.argtypes = [c_uint]
  1496. self.lib.carla_get_real_plugin_name.restype = c_char_p
  1497. self.lib.carla_get_current_program_index.argtypes = [c_uint]
  1498. self.lib.carla_get_current_program_index.restype = c_int32
  1499. self.lib.carla_get_current_midi_program_index.argtypes = [c_uint]
  1500. self.lib.carla_get_current_midi_program_index.restype = c_int32
  1501. self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32]
  1502. self.lib.carla_get_default_parameter_value.restype = c_float
  1503. self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
  1504. self.lib.carla_get_current_parameter_value.restype = c_float
  1505. self.lib.carla_get_internal_parameter_value.argtypes = [c_uint, c_int32]
  1506. self.lib.carla_get_internal_parameter_value.restype = c_float
  1507. self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_bool]
  1508. self.lib.carla_get_input_peak_value.restype = c_float
  1509. self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_bool]
  1510. self.lib.carla_get_output_peak_value.restype = c_float
  1511. self.lib.carla_set_option.argtypes = [c_uint, c_uint, c_bool]
  1512. self.lib.carla_set_option.restype = None
  1513. self.lib.carla_set_active.argtypes = [c_uint, c_bool]
  1514. self.lib.carla_set_active.restype = None
  1515. self.lib.carla_set_drywet.argtypes = [c_uint, c_float]
  1516. self.lib.carla_set_drywet.restype = None
  1517. self.lib.carla_set_volume.argtypes = [c_uint, c_float]
  1518. self.lib.carla_set_volume.restype = None
  1519. self.lib.carla_set_balance_left.argtypes = [c_uint, c_float]
  1520. self.lib.carla_set_balance_left.restype = None
  1521. self.lib.carla_set_balance_right.argtypes = [c_uint, c_float]
  1522. self.lib.carla_set_balance_right.restype = None
  1523. self.lib.carla_set_panning.argtypes = [c_uint, c_float]
  1524. self.lib.carla_set_panning.restype = None
  1525. self.lib.carla_set_ctrl_channel.argtypes = [c_uint, c_int8]
  1526. self.lib.carla_set_ctrl_channel.restype = None
  1527. self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float]
  1528. self.lib.carla_set_parameter_value.restype = None
  1529. self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8]
  1530. self.lib.carla_set_parameter_midi_channel.restype = None
  1531. self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16]
  1532. self.lib.carla_set_parameter_midi_cc.restype = None
  1533. self.lib.carla_set_program.argtypes = [c_uint, c_uint32]
  1534. self.lib.carla_set_program.restype = None
  1535. self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32]
  1536. self.lib.carla_set_midi_program.restype = None
  1537. self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p]
  1538. self.lib.carla_set_custom_data.restype = None
  1539. self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p]
  1540. self.lib.carla_set_chunk_data.restype = None
  1541. self.lib.carla_prepare_for_save.argtypes = [c_uint]
  1542. self.lib.carla_prepare_for_save.restype = None
  1543. self.lib.carla_reset_parameters.argtypes = [c_uint]
  1544. self.lib.carla_reset_parameters.restype = None
  1545. self.lib.carla_randomize_parameters.argtypes = [c_uint]
  1546. self.lib.carla_randomize_parameters.restype = None
  1547. self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8]
  1548. self.lib.carla_send_midi_note.restype = None
  1549. self.lib.carla_show_custom_ui.argtypes = [c_uint, c_bool]
  1550. self.lib.carla_show_custom_ui.restype = None
  1551. self.lib.carla_get_buffer_size.argtypes = None
  1552. self.lib.carla_get_buffer_size.restype = c_uint32
  1553. self.lib.carla_get_sample_rate.argtypes = None
  1554. self.lib.carla_get_sample_rate.restype = c_double
  1555. self.lib.carla_get_last_error.argtypes = None
  1556. self.lib.carla_get_last_error.restype = c_char_p
  1557. self.lib.carla_get_host_osc_url_tcp.argtypes = None
  1558. self.lib.carla_get_host_osc_url_tcp.restype = c_char_p
  1559. self.lib.carla_get_host_osc_url_udp.argtypes = None
  1560. self.lib.carla_get_host_osc_url_udp.restype = c_char_p
  1561. if WINDOWS:
  1562. self.msvcrt = cdll.msvcrt
  1563. self.msvcrt._putenv.argtypes = [c_char_p]
  1564. self.msvcrt._putenv.restype = None
  1565. else:
  1566. self.msvcrt = None