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

carla_backend.py 99KB

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