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

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