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

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