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 63KB

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