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

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