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

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