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

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