Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

carla_backend.py 102KB

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