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

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