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_shared.py 132KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Common Carla code
  4. # Copyright (C) 2011-2013 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 GPL.txt file
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. import os
  20. import json
  21. import platform
  22. import sys
  23. from codecs import open as codecopen
  24. from copy import deepcopy
  25. #from decimal import Decimal
  26. from subprocess import Popen, PIPE
  27. from PyQt4.QtCore import pyqtSlot, qWarning, Qt, QByteArray, QSettings, QThread, QTimer, SIGNAL, SLOT
  28. from PyQt4.QtGui import QColor, QCursor, QDialog, QIcon, QFileDialog, QFontMetrics, QFrame, QMenu
  29. from PyQt4.QtGui import QMessageBox, QPainter, QPainterPath, QTableWidgetItem, QVBoxLayout, QWidget
  30. #from PyQt4.QtGui import QGraphicsScene, QInputDialog, QLinearGradient,
  31. #from PyQt4.QtXml import QDomDocument
  32. # ------------------------------------------------------------------------------------------------------------
  33. # Imports (Custom)
  34. import ui_carla_about
  35. import ui_carla_database
  36. import ui_carla_edit
  37. import ui_carla_parameter
  38. import ui_carla_plugin
  39. import ui_carla_refresh
  40. # ------------------------------------------------------------------------------------------------------------
  41. # Try Import LADSPA-RDF
  42. try:
  43. import ladspa_rdf
  44. haveLRDF = True
  45. except:
  46. print("LRDF Support not available (LADSPA-RDF will be disabled)")
  47. haveLRDF = False
  48. # ------------------------------------------------------------------------------------------------------------
  49. # Try Import Signal
  50. try:
  51. from signal import signal, SIGINT, SIGTERM, SIGUSR1
  52. haveSignal = True
  53. except:
  54. haveSignal = False
  55. # ------------------------------------------------------------------------------------------------------------
  56. # Set Platform
  57. if sys.platform == "darwin":
  58. from PyQt4.QtGui import qt_mac_set_menubar_icons
  59. qt_mac_set_menubar_icons(False)
  60. HAIKU = False
  61. LINUX = False
  62. MACOS = True
  63. WINDOWS = False
  64. elif "haiku" in sys.platform:
  65. HAIKU = True
  66. LINUX = False
  67. MACOS = False
  68. WINDOWS = False
  69. elif "linux" in sys.platform:
  70. HAIKU = False
  71. LINUX = True
  72. MACOS = False
  73. WINDOWS = False
  74. elif sys.platform in ("win32", "win64", "cygwin"):
  75. WINDIR = os.getenv("WINDIR")
  76. HAIKU = False
  77. LINUX = False
  78. MACOS = False
  79. WINDOWS = True
  80. else:
  81. HAIKU = False
  82. LINUX = False
  83. MACOS = False
  84. WINDOWS = False
  85. # ------------------------------------------------------------------------------------------------------------
  86. # Set Version
  87. VERSION = "0.5.0"
  88. # ------------------------------------------------------------------------------------------------------------
  89. # Set TMP
  90. TMP = os.getenv("TMP")
  91. if TMP is None:
  92. if WINDOWS:
  93. qWarning("TMP variable not set")
  94. TMP = os.path.join(WINDIR, "temp")
  95. else:
  96. TMP = "/tmp"
  97. # ------------------------------------------------------------------------------------------------------------
  98. # Set HOME
  99. HOME = os.getenv("HOME")
  100. if HOME is None:
  101. HOME = os.path.expanduser("~")
  102. if LINUX or MACOS:
  103. qWarning("HOME variable not set")
  104. if not os.path.exists(HOME):
  105. qWarning("HOME does not exist")
  106. HOME = TMP
  107. # ------------------------------------------------------------------------------------------------------------
  108. # Set PATH
  109. PATH = os.getenv("PATH")
  110. if PATH is None:
  111. qWarning("PATH variable not set")
  112. if MACOS:
  113. PATH = ("/opt/local/bin", "/usr/local/bin", "/usr/bin", "/bin")
  114. elif WINDOWS:
  115. PATH = (os.path.join(WINDIR, "system32"), WINDIR)
  116. else:
  117. PATH = ("/usr/local/bin", "/usr/bin", "/bin")
  118. else:
  119. PATH = PATH.split(os.pathsep)
  120. # ------------------------------------------------------------------------------------------------------------
  121. # 64bit check
  122. kIs64bit = bool(platform.architecture()[0] == "64bit" and sys.maxsize > 2**32)
  123. # ------------------------------------------------------------------------------------------------
  124. # Backend defines
  125. MAX_DEFAULT_PLUGINS = 99
  126. MAX_RACK_PLUGINS = 16
  127. MAX_PATCHBAY_PLUGINS = 999
  128. MAX_DEFAULT_PARAMETERS = 200
  129. # Plugin Hints
  130. PLUGIN_IS_BRIDGE = 0x001
  131. PLUGIN_IS_RTSAFE = 0x002
  132. PLUGIN_IS_SYNTH = 0x004
  133. PLUGIN_HAS_GUI = 0x010
  134. PLUGIN_HAS_SINGLE_THREAD = 0x020
  135. PLUGIN_CAN_DRYWET = 0x100
  136. PLUGIN_CAN_VOLUME = 0x200
  137. PLUGIN_CAN_BALANCE = 0x400
  138. PLUGIN_CAN_PANNING = 0x800
  139. # Plugin Options
  140. PLUGIN_OPTION_FIXED_BUFFER = 0x001
  141. PLUGIN_OPTION_FORCE_STEREO = 0x002
  142. PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004
  143. PLUGIN_OPTION_USE_CHUNKS = 0x008
  144. PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010
  145. PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020
  146. PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040
  147. PLUGIN_OPTION_SEND_PITCHBEND = 0x080
  148. PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100
  149. # Parameter Hints
  150. PARAMETER_IS_BOOLEAN = 0x01
  151. PARAMETER_IS_INTEGER = 0x02
  152. PARAMETER_IS_LOGARITHMIC = 0x04
  153. PARAMETER_IS_ENABLED = 0x08
  154. PARAMETER_IS_AUTOMABLE = 0x10
  155. PARAMETER_USES_SAMPLERATE = 0x20
  156. PARAMETER_USES_SCALEPOINTS = 0x40
  157. PARAMETER_USES_CUSTOM_TEXT = 0x80
  158. # Custom Data types
  159. CUSTOM_DATA_INVALID = None
  160. CUSTOM_DATA_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"
  161. CUSTOM_DATA_STRING = "http://kxstudio.sf.net/ns/carla/string"
  162. # Binary Type
  163. BINARY_NONE = 0
  164. BINARY_POSIX32 = 1
  165. BINARY_POSIX64 = 2
  166. BINARY_WIN32 = 3
  167. BINARY_WIN64 = 4
  168. BINARY_OTHER = 5
  169. # Plugin Type
  170. PLUGIN_NONE = 0
  171. PLUGIN_INTERNAL = 1
  172. PLUGIN_LADSPA = 2
  173. PLUGIN_DSSI = 3
  174. PLUGIN_LV2 = 4
  175. PLUGIN_VST = 5
  176. PLUGIN_GIG = 6
  177. PLUGIN_SF2 = 7
  178. PLUGIN_SFZ = 8
  179. # Plugin Category
  180. PLUGIN_CATEGORY_NONE = 0
  181. PLUGIN_CATEGORY_SYNTH = 1
  182. PLUGIN_CATEGORY_DELAY = 2 # also Reverb
  183. PLUGIN_CATEGORY_EQ = 3
  184. PLUGIN_CATEGORY_FILTER = 4
  185. PLUGIN_CATEGORY_DYNAMICS = 5 # Amplifier, Compressor, Gate
  186. PLUGIN_CATEGORY_MODULATOR = 6 # Chorus, Flanger, Phaser
  187. PLUGIN_CATEGORY_UTILITY = 7 # Analyzer, Converter, Mixer
  188. PLUGIN_CATEGORY_OTHER = 8 # used to check if a plugin has a category
  189. # Parameter Type
  190. PARAMETER_UNKNOWN = 0
  191. PARAMETER_INPUT = 1
  192. PARAMETER_OUTPUT = 2
  193. PARAMETER_LATENCY = 3
  194. PARAMETER_SAMPLE_RATE = 4
  195. PARAMETER_LV2_FREEWHEEL = 5
  196. PARAMETER_LV2_TIME = 6
  197. # Internal Parameters Index
  198. PARAMETER_NULL = -1
  199. PARAMETER_ACTIVE = -2
  200. PARAMETER_DRYWET = -3
  201. PARAMETER_VOLUME = -4
  202. PARAMETER_BALANCE_LEFT = -5
  203. PARAMETER_BALANCE_RIGHT = -6
  204. PARAMETER_PANNING = -7
  205. PARAMETER_CTRL_CHANNEL = -8
  206. PARAMETER_MAX = -9
  207. # Options Type
  208. OPTION_PROCESS_NAME = 0
  209. OPTION_PROCESS_MODE = 1
  210. OPTION_TRANSPORT_MODE = 2
  211. OPTION_FORCE_STEREO = 3
  212. OPTION_PREFER_PLUGIN_BRIDGES = 4
  213. OPTION_PREFER_UI_BRIDGES = 5
  214. OPTION_USE_DSSI_VST_CHUNKS = 6
  215. OPTION_MAX_PARAMETERS = 7
  216. OPTION_OSC_UI_TIMEOUT = 8
  217. OPTION_PREFERRED_BUFFER_SIZE = 9
  218. OPTION_PREFERRED_SAMPLE_RATE = 10
  219. OPTION_PATH_BRIDGE_NATIVE = 11
  220. OPTION_PATH_BRIDGE_POSIX32 = 12
  221. OPTION_PATH_BRIDGE_POSIX64 = 13
  222. OPTION_PATH_BRIDGE_WIN32 = 14
  223. OPTION_PATH_BRIDGE_WIN64 = 15
  224. OPTION_PATH_BRIDGE_LV2_GTK2 = 16
  225. OPTION_PATH_BRIDGE_LV2_GTK3 = 17
  226. OPTION_PATH_BRIDGE_LV2_QT4 = 18
  227. OPTION_PATH_BRIDGE_LV2_QT5 = 19
  228. OPTION_PATH_BRIDGE_LV2_COCOA = 20
  229. OPTION_PATH_BRIDGE_LV2_WINDOWS = 21
  230. OPTION_PATH_BRIDGE_LV2_X11 = 22
  231. OPTION_PATH_BRIDGE_VST_COCOA = 23
  232. OPTION_PATH_BRIDGE_VST_HWND = 24
  233. OPTION_PATH_BRIDGE_VST_X11 = 25
  234. # Callback Type
  235. CALLBACK_DEBUG = 0
  236. CALLBACK_PLUGIN_ADDED = 1
  237. CALLBACK_PLUGIN_REMOVED = 2
  238. CALLBACK_PARAMETER_VALUE_CHANGED = 3
  239. CALLBACK_PARAMETER_DEFAULT_CHANGED = 4
  240. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 5
  241. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 6
  242. CALLBACK_PROGRAM_CHANGED = 7
  243. CALLBACK_MIDI_PROGRAM_CHANGED = 8
  244. CALLBACK_NOTE_ON = 9
  245. CALLBACK_NOTE_OFF = 10
  246. CALLBACK_SHOW_GUI = 11
  247. CALLBACK_UPDATE = 12
  248. CALLBACK_RELOAD_INFO = 13
  249. CALLBACK_RELOAD_PARAMETERS = 14
  250. CALLBACK_RELOAD_PROGRAMS = 15
  251. CALLBACK_RELOAD_ALL = 16
  252. CALLBACK_NSM_ANNOUNCE = 17
  253. CALLBACK_NSM_OPEN1 = 18
  254. CALLBACK_NSM_OPEN2 = 19
  255. CALLBACK_NSM_SAVE = 20
  256. CALLBACK_ERROR = 21
  257. CALLBACK_QUIT = 22
  258. # Process Mode
  259. PROCESS_MODE_SINGLE_CLIENT = 0
  260. PROCESS_MODE_MULTIPLE_CLIENTS = 1
  261. PROCESS_MODE_CONTINUOUS_RACK = 2
  262. PROCESS_MODE_PATCHBAY = 3
  263. # Transport Mode
  264. TRANSPORT_MODE_INTERNAL = 0
  265. TRANSPORT_MODE_JACK = 1
  266. # Set BINARY_NATIVE
  267. if HAIKU or LINUX or MACOS:
  268. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  269. elif WINDOWS:
  270. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  271. else:
  272. BINARY_NATIVE = BINARY_OTHER
  273. # ------------------------------------------------------------------------------------------------------------
  274. # Carla Host object
  275. class CarlaHostObject(object):
  276. __slots__ = [
  277. 'host',
  278. 'gui',
  279. 'isControl',
  280. 'isLocal',
  281. 'processMode',
  282. 'maxParameters',
  283. 'LADSPA_PATH',
  284. 'DSSI_PATH',
  285. 'LV2_PATH',
  286. 'VST_PATH',
  287. 'GIG_PATH',
  288. 'SF2_PATH',
  289. 'SFZ_PATH'
  290. ]
  291. Carla = CarlaHostObject()
  292. Carla.host = None
  293. Carla.gui = None
  294. Carla.isControl = False
  295. Carla.isLocal = True
  296. Carla.processMode = PROCESS_MODE_CONTINUOUS_RACK
  297. Carla.maxParameters = MAX_RACK_PLUGINS
  298. # ------------------------------------------------------------------------------------------------------------
  299. # Carla GUI stuff
  300. ICON_STATE_NULL = 0
  301. ICON_STATE_WAIT = 1
  302. ICON_STATE_OFF = 2
  303. ICON_STATE_ON = 3
  304. PALETTE_COLOR_NONE = 0
  305. PALETTE_COLOR_WHITE = 1
  306. PALETTE_COLOR_RED = 2
  307. PALETTE_COLOR_GREEN = 3
  308. PALETTE_COLOR_BLUE = 4
  309. PALETTE_COLOR_YELLOW = 5
  310. PALETTE_COLOR_ORANGE = 6
  311. PALETTE_COLOR_BROWN = 7
  312. PALETTE_COLOR_PINK = 8
  313. CarlaStateParameter = {
  314. 'index': 0,
  315. 'name': "",
  316. 'symbol': "",
  317. 'value': 0.0,
  318. 'midiChannel': 1,
  319. 'midiCC': -1
  320. }
  321. CarlaStateCustomData = {
  322. 'type': "",
  323. 'key': "",
  324. 'value': ""
  325. }
  326. CarlaSaveState = {
  327. 'type': "",
  328. 'name': "",
  329. 'label': "",
  330. 'binary': "",
  331. 'uniqueId': 0,
  332. 'active': False,
  333. 'dryWet': 1.0,
  334. 'volume': 1.0,
  335. 'balanceLeft': -1.0,
  336. 'balanceRight': 1.0,
  337. 'pannning': 0.0,
  338. 'parameterList': [],
  339. 'currentProgramIndex': -1,
  340. 'currentProgramName': "",
  341. 'currentMidiBank': -1,
  342. 'currentMidiProgram': -1,
  343. 'customDataList': [],
  344. 'chunk': None
  345. }
  346. # ------------------------------------------------------------------------------------------------------------
  347. # Static MIDI CC list
  348. MIDI_CC_LIST = (
  349. #"0x00 Bank Select",
  350. "0x01 Modulation",
  351. "0x02 Breath",
  352. "0x03 (Undefined)",
  353. "0x04 Foot",
  354. "0x05 Portamento",
  355. #"0x06 (Data Entry MSB)",
  356. "0x07 Volume",
  357. "0x08 Balance",
  358. "0x09 (Undefined)",
  359. "0x0A Pan",
  360. "0x0B Expression",
  361. "0x0C FX Control 1",
  362. "0x0D FX Control 2",
  363. "0x0E (Undefined)",
  364. "0x0F (Undefined)",
  365. "0x10 General Purpose 1",
  366. "0x11 General Purpose 2",
  367. "0x12 General Purpose 3",
  368. "0x13 General Purpose 4",
  369. "0x14 (Undefined)",
  370. "0x15 (Undefined)",
  371. "0x16 (Undefined)",
  372. "0x17 (Undefined)",
  373. "0x18 (Undefined)",
  374. "0x19 (Undefined)",
  375. "0x1A (Undefined)",
  376. "0x1B (Undefined)",
  377. "0x1C (Undefined)",
  378. "0x1D (Undefined)",
  379. "0x1E (Undefined)",
  380. "0x1F (Undefined)",
  381. #"0x20 *Bank Select",
  382. #"0x21 *Modulation",
  383. #"0x22 *Breath",
  384. #"0x23 *(Undefined)",
  385. #"0x24 *Foot",
  386. #"0x25 *Portamento",
  387. #"0x26 *(Data Entry MSB)",
  388. #"0x27 *Volume",
  389. #"0x28 *Balance",
  390. #"0x29 *(Undefined)",
  391. #"0x2A *Pan",
  392. #"0x2B *Expression",
  393. #"0x2C *FX *Control 1",
  394. #"0x2D *FX *Control 2",
  395. #"0x2E *(Undefined)",
  396. #"0x2F *(Undefined)",
  397. #"0x30 *General Purpose 1",
  398. #"0x31 *General Purpose 2",
  399. #"0x32 *General Purpose 3",
  400. #"0x33 *General Purpose 4",
  401. #"0x34 *(Undefined)",
  402. #"0x35 *(Undefined)",
  403. #"0x36 *(Undefined)",
  404. #"0x37 *(Undefined)",
  405. #"0x38 *(Undefined)",
  406. #"0x39 *(Undefined)",
  407. #"0x3A *(Undefined)",
  408. #"0x3B *(Undefined)",
  409. #"0x3C *(Undefined)",
  410. #"0x3D *(Undefined)",
  411. #"0x3E *(Undefined)",
  412. #"0x3F *(Undefined)",
  413. #"0x40 Damper On/Off", # <63 off, >64 on
  414. #"0x41 Portamento On/Off", # <63 off, >64 on
  415. #"0x42 Sostenuto On/Off", # <63 off, >64 on
  416. #"0x43 Soft Pedal On/Off", # <63 off, >64 on
  417. #"0x44 Legato Footswitch", # <63 Normal, >64 Legato
  418. #"0x45 Hold 2", # <63 off, >64 on
  419. "0x46 Control 1 [Variation]",
  420. "0x47 Control 2 [Timbre]",
  421. "0x48 Control 3 [Release]",
  422. "0x49 Control 4 [Attack]",
  423. "0x4A Control 5 [Brightness]",
  424. "0x4B Control 6 [Decay]",
  425. "0x4C Control 7 [Vib Rate]",
  426. "0x4D Control 8 [Vib Depth]",
  427. "0x4E Control 9 [Vib Delay]",
  428. "0x4F Control 10 [Undefined]",
  429. "0x50 General Purpose 5",
  430. "0x51 General Purpose 6",
  431. "0x52 General Purpose 7",
  432. "0x53 General Purpose 8",
  433. "0x54 Portamento Control",
  434. "0x5B FX 1 Depth [Reverb]",
  435. "0x5C FX 2 Depth [Tremolo]",
  436. "0x5D FX 3 Depth [Chorus]",
  437. "0x5E FX 4 Depth [Detune]",
  438. "0x5F FX 5 Depth [Phaser]"
  439. )
  440. # ------------------------------------------------------------------------------------------------------------
  441. # Default Plugin Folders
  442. if WINDOWS:
  443. splitter = ";"
  444. APPDATA = os.getenv("APPDATA")
  445. PROGRAMFILES = os.getenv("PROGRAMFILES")
  446. PROGRAMFILESx86 = os.getenv("PROGRAMFILES(x86)")
  447. COMMONPROGRAMFILES = os.getenv("COMMONPROGRAMFILES")
  448. # Small integrity tests
  449. if not APPDATA:
  450. print("APPDATA variable not set, cannot continue")
  451. sys.exit(1)
  452. if not PROGRAMFILES:
  453. print("PROGRAMFILES variable not set, cannot continue")
  454. sys.exit(1)
  455. if not COMMONPROGRAMFILES:
  456. print("COMMONPROGRAMFILES variable not set, cannot continue")
  457. sys.exit(1)
  458. DEFAULT_LADSPA_PATH = ";".join((os.path.join(APPDATA, "LADSPA"),
  459. os.path.join(PROGRAMFILES, "LADSPA")))
  460. DEFAULT_DSSI_PATH = ";".join((os.path.join(APPDATA, "DSSI"),
  461. os.path.join(PROGRAMFILES, "DSSI")))
  462. DEFAULT_LV2_PATH = ";".join((os.path.join(APPDATA, "LV2"),
  463. os.path.join(COMMONPROGRAMFILES, "LV2")))
  464. DEFAULT_VST_PATH = ";".join((os.path.join(PROGRAMFILES, "VstPlugins"),
  465. os.path.join(PROGRAMFILES, "Steinberg", "VstPlugins")))
  466. DEFAULT_GIG_PATH = ";".join((os.path.join(APPDATA, "GIG"),))
  467. DEFAULT_SF2_PATH = ";".join((os.path.join(APPDATA, "SF2"),))
  468. DEFAULT_SFZ_PATH = ";".join((os.path.join(APPDATA, "SFZ"),))
  469. if PROGRAMFILESx86:
  470. DEFAULT_LADSPA_PATH += ";"+os.path.join(PROGRAMFILESx86, "LADSPA")
  471. DEFAULT_DSSI_PATH += ";"+os.path.join(PROGRAMFILESx86, "DSSI")
  472. DEFAULT_VST_PATH += ";"+os.path.join(PROGRAMFILESx86, "VstPlugins")
  473. DEFAULT_VST_PATH += ";"+os.path.join(PROGRAMFILESx86, "Steinberg", "VstPlugins")
  474. elif HAIKU:
  475. splitter = ":"
  476. # TODO
  477. DEFAULT_LADSPA_PATH = ""
  478. DEFAULT_DSSI_PATH = ""
  479. DEFAULT_LV2_PATH = ""
  480. DEFAULT_VST_PATH = ""
  481. DEFAULT_GIG_PATH = ""
  482. DEFAULT_SF2_PATH = ""
  483. DEFAULT_SFZ_PATH = ""
  484. elif MACOS:
  485. splitter = ":"
  486. DEFAULT_LADSPA_PATH = ":".join((os.path.join(HOME, "Library", "Audio", "Plug-Ins", "LADSPA"),
  487. os.path.join("/", "Library", "Audio", "Plug-Ins", "LADSPA")))
  488. DEFAULT_DSSI_PATH = ":".join((os.path.join(HOME, "Library", "Audio", "Plug-Ins", "DSSI"),
  489. os.path.join("/", "Library", "Audio", "Plug-Ins", "DSSI")))
  490. DEFAULT_LV2_PATH = ":".join((os.path.join(HOME, "Library", "Audio", "Plug-Ins", "LV2"),
  491. os.path.join("/", "Library", "Audio", "Plug-Ins", "LV2")))
  492. DEFAULT_VST_PATH = ":".join((os.path.join(HOME, "Library", "Audio", "Plug-Ins", "VST"),
  493. os.path.join("/", "Library", "Audio", "Plug-Ins", "VST")))
  494. # TODO
  495. DEFAULT_GIG_PATH = ""
  496. DEFAULT_SF2_PATH = ""
  497. DEFAULT_SFZ_PATH = ""
  498. else:
  499. splitter = ":"
  500. DEFAULT_LADSPA_PATH = ":".join((os.path.join(HOME, ".ladspa"),
  501. os.path.join("/", "usr", "lib", "ladspa"),
  502. os.path.join("/", "usr", "local", "lib", "ladspa")))
  503. DEFAULT_DSSI_PATH = ":".join((os.path.join(HOME, ".dssi"),
  504. os.path.join("/", "usr", "lib", "dssi"),
  505. os.path.join("/", "usr", "local", "lib", "dssi")))
  506. DEFAULT_LV2_PATH = ":".join((os.path.join(HOME, ".lv2"),
  507. os.path.join("/", "usr", "lib", "lv2"),
  508. os.path.join("/", "usr", "local", "lib", "lv2")))
  509. DEFAULT_VST_PATH = ":".join((os.path.join(HOME, ".vst"),
  510. os.path.join("/", "usr", "lib", "vst"),
  511. os.path.join("/", "usr", "local", "lib", "vst")))
  512. DEFAULT_GIG_PATH = ":".join((os.path.join(HOME, ".sounds"),
  513. os.path.join("/", "usr", "share", "sounds", "gig")))
  514. DEFAULT_SF2_PATH = ":".join((os.path.join(HOME, ".sounds"),
  515. os.path.join("/", "usr", "share", "sounds", "sf2"),
  516. "/home/falktx/Personal/Muzyks/Kits/SF2/"))
  517. DEFAULT_SFZ_PATH = ":".join((os.path.join(HOME, ".sounds"),
  518. os.path.join("/", "usr", "share", "sounds", "sfz")))
  519. # ------------------------------------------------------------------------------------------------------------
  520. # Default Plugin Folders (set)
  521. Carla.LADSPA_PATH = os.getenv("LADSPA_PATH", DEFAULT_LADSPA_PATH).split(splitter)
  522. Carla.DSSI_PATH = os.getenv("DSSI_PATH", DEFAULT_DSSI_PATH).split(splitter)
  523. Carla.LV2_PATH = os.getenv("LV2_PATH", DEFAULT_LV2_PATH).split(splitter)
  524. Carla.VST_PATH = os.getenv("VST_PATH", DEFAULT_VST_PATH).split(splitter)
  525. Carla.GIG_PATH = os.getenv("GIG_PATH", DEFAULT_GIG_PATH).split(splitter)
  526. Carla.SF2_PATH = os.getenv("SF2_PATH", DEFAULT_SF2_PATH).split(splitter)
  527. Carla.SFZ_PATH = os.getenv("SFZ_PATH", DEFAULT_SFZ_PATH).split(splitter)
  528. if haveLRDF:
  529. LADSPA_RDF_PATH_env = os.getenv("LADSPA_RDF_PATH")
  530. if LADSPA_RDF_PATH_env:
  531. ladspa_rdf.set_rdf_path(LADSPA_RDF_PATH_env.split(splitter))
  532. del LADSPA_RDF_PATH_env
  533. # ------------------------------------------------------------------------------------------------------------
  534. # Search for Carla library and tools
  535. global carla_library_path
  536. carla_library_path = ""
  537. carla_discovery_native = ""
  538. carla_discovery_posix32 = ""
  539. carla_discovery_posix64 = ""
  540. carla_discovery_win32 = ""
  541. carla_discovery_win64 = ""
  542. carla_bridge_native = ""
  543. carla_bridge_posix32 = ""
  544. carla_bridge_posix64 = ""
  545. carla_bridge_win32 = ""
  546. carla_bridge_win64 = ""
  547. carla_bridge_lv2_gtk2 = ""
  548. carla_bridge_lv2_gtk3 = ""
  549. carla_bridge_lv2_qt4 = ""
  550. carla_bridge_lv2_qt5 = ""
  551. carla_bridge_lv2_cocoa = ""
  552. carla_bridge_lv2_windows = ""
  553. carla_bridge_lv2_x11 = ""
  554. carla_bridge_vst_cocoa = ""
  555. carla_bridge_vst_hwnd = ""
  556. carla_bridge_vst_x11 = ""
  557. if WINDOWS:
  558. carla_libname = "libcarla_standalone.dll"
  559. elif MACOS:
  560. carla_libname = "libcarla_standalone.dylib"
  561. else:
  562. carla_libname = "libcarla_standalone.so"
  563. CWD = sys.path[0]
  564. # make it work with cxfreeze
  565. if CWD.endswith("%scarla" % os.sep):
  566. CWD = CWD.rsplit("%scarla" % os.sep, 1)[0]
  567. # find carla_library_path
  568. if os.path.exists(os.path.join(CWD, "backend", carla_libname)):
  569. carla_library_path = os.path.join(CWD, "backend", carla_libname)
  570. else:
  571. if WINDOWS:
  572. CARLA_PATH = (os.path.join(PROGRAMFILES, "Carla"),)
  573. elif MACOS:
  574. CARLA_PATH = ("/opt/local/lib", "/usr/local/lib/", "/usr/lib")
  575. else:
  576. CARLA_PATH = ("/usr/local/lib/", "/usr/lib")
  577. for path in CARLA_PATH:
  578. if os.path.exists(os.path.join(path, "carla", carla_libname)):
  579. carla_library_path = os.path.join(path, "carla", carla_libname)
  580. break
  581. # find any tool
  582. def findTool(tdir, tname):
  583. if os.path.exists(os.path.join(CWD, tdir, tname)):
  584. return os.path.join(CWD, tdir, tname)
  585. for p in PATH:
  586. if os.path.exists(os.path.join(p, tname)):
  587. return os.path.join(p, tname)
  588. return ""
  589. # find wine/windows tools
  590. carla_discovery_win32 = findTool("discovery", "carla-discovery-win32.exe")
  591. carla_discovery_win64 = findTool("discovery", "carla-discovery-win64.exe")
  592. carla_bridge_win32 = findTool("bridges", "carla-bridge-win32.exe")
  593. carla_bridge_win64 = findTool("bridges", "carla-bridge-win64.exe")
  594. # find native and posix tools
  595. if not WINDOWS:
  596. carla_discovery_native = findTool("discovery", "carla-discovery-native")
  597. carla_discovery_posix32 = findTool("discovery", "carla-discovery-posix32")
  598. carla_discovery_posix64 = findTool("discovery", "carla-discovery-posix64")
  599. carla_bridge_native = findTool("bridges", "carla-bridge-native")
  600. carla_bridge_posix32 = findTool("bridges", "carla-bridge-posix32")
  601. carla_bridge_posix64 = findTool("bridges", "carla-bridge-posix64")
  602. # find windows only tools
  603. if WINDOWS:
  604. carla_bridge_lv2_windows = findTool("bridges", "carla-bridge-lv2-windows.exe")
  605. carla_bridge_vst_hwnd = findTool("bridges", "carla-bridge-vst-hwnd.exe")
  606. # find mac os only tools
  607. elif MACOS:
  608. carla_bridge_lv2_cocoa = findTool("bridges", "carla-bridge-lv2-cocoa")
  609. carla_bridge_vst_cocoa = findTool("bridges", "carla-bridge-vst-cocoa")
  610. # find generic tools
  611. else:
  612. carla_bridge_lv2_gtk2 = findTool("bridges", "carla-bridge-lv2-gtk2")
  613. carla_bridge_lv2_gtk3 = findTool("bridges", "carla-bridge-lv2-gtk3")
  614. carla_bridge_lv2_qt4 = findTool("bridges", "carla-bridge-lv2-qt4")
  615. carla_bridge_lv2_qt5 = findTool("bridges", "carla-bridge-lv2-qt5")
  616. # find linux only tools
  617. if LINUX:
  618. carla_bridge_lv2_x11 = os.path.join("bridges", "carla-bridge-lv2-x11")
  619. carla_bridge_vst_x11 = os.path.join("bridges", "carla-bridge-vst-x11")
  620. # ------------------------------------------------------------------------------------------------------------
  621. # Convert a ctypes c_char_p into a python string
  622. def cString(value):
  623. if not value:
  624. return ""
  625. if isinstance(value, str):
  626. return value
  627. return value.decode("utf-8", errors="ignore")
  628. # ------------------------------------------------------------------------------------------------------------
  629. # Check if a value is a number (float support)
  630. def isNumber(value):
  631. try:
  632. float(value)
  633. return True
  634. except:
  635. return False
  636. # ------------------------------------------------------------------------------------------------------------
  637. # Convert a value to a list
  638. def toList(value):
  639. if value is None:
  640. return []
  641. elif not isinstance(value, list):
  642. return [value]
  643. else:
  644. return value
  645. # ------------------------------------------------------------------------------------------------------------
  646. # Unicode open
  647. def uopen(filename, mode="r"):
  648. return codecopen(filename, encoding="utf-8", mode=mode)
  649. # ------------------------------------------------------------------------------------------------------------
  650. # Get Icon from user theme, using our own as backup (Oxygen)
  651. def getIcon(icon, size=16):
  652. return QIcon.fromTheme(icon, QIcon(":/%ix%i/%s.png" % (size, size, icon)))
  653. # ------------------------------------------------------------------------------------------------------------
  654. # Signal handler
  655. def setUpSignals():
  656. if not haveSignal:
  657. return
  658. signal(SIGINT, signalHandler)
  659. signal(SIGTERM, signalHandler)
  660. signal(SIGUSR1, signalHandler)
  661. def signalHandler(sig, frame):
  662. if sig in (SIGINT, SIGTERM):
  663. Carla.gui.emit(SIGNAL("SIGTERM()"))
  664. elif sig == SIGUSR1:
  665. Carla.gui.emit(SIGNAL("SIGUSR1()"))
  666. # ------------------------------------------------------------------------------------------------------------
  667. # Custom MessageBox
  668. def CustomMessageBox(self_, icon, title, text, extraText="", buttons=QMessageBox.Yes|QMessageBox.No, defButton=QMessageBox.No):
  669. msgBox = QMessageBox(self_)
  670. msgBox.setIcon(icon)
  671. msgBox.setWindowTitle(title)
  672. msgBox.setText(text)
  673. msgBox.setInformativeText(extraText)
  674. msgBox.setStandardButtons(buttons)
  675. msgBox.setDefaultButton(defButton)
  676. return msgBox.exec_()
  677. # ------------------------------------------------------------------------------------------------------------
  678. # Plugin Query (helper functions)
  679. def findBinaries(bPATH, OS):
  680. binaries = []
  681. if OS == "WINDOWS":
  682. extensions = (".dll",)
  683. elif OS == "MACOS":
  684. extensions = (".dylib", ".so")
  685. else:
  686. extensions = (".so", ".sO", ".SO", ".So")
  687. for root, dirs, files in os.walk(bPATH):
  688. for name in [name for name in files if name.endswith(extensions)]:
  689. binaries.append(os.path.join(root, name))
  690. return binaries
  691. def findLV2Bundles(bPATH):
  692. bundles = []
  693. for root, dirs, files in os.walk(bPATH):
  694. if os.path.exists(os.path.join(root, "manifest.ttl")):
  695. bundles.append(root)
  696. return bundles
  697. def findSoundKits(bPATH, stype):
  698. soundfonts = []
  699. if stype == "gig":
  700. extensions = (".gig", ".giG", ".gIG", ".GIG", ".GIg", ".Gig") if not WINDOWS else (".gig",)
  701. elif stype == "sf2":
  702. extensions = (".sf2", ".sF2", ".SF2", ".Sf2") if not WINDOWS else (".sf2",)
  703. elif stype == "sfz":
  704. extensions = (".sfz", ".sfZ", ".sFZ", ".SFZ", ".SFz", ".Sfz") if not WINDOWS else (".sfz",)
  705. else:
  706. return []
  707. for root, dirs, files in os.walk(bPATH):
  708. for name in [name for name in files if name.endswith(extensions)]:
  709. soundfonts.append(os.path.join(root, name))
  710. return soundfonts
  711. def findDSSIGUI(filename, name, label):
  712. pluginDir = filename.rsplit(".", 1)[0]
  713. shortName = os.path.basename(pluginDir)
  714. guiFilename = ""
  715. checkName = name.replace(" ", "_")
  716. checkLabel = label
  717. checkSName = shortName
  718. if checkName[-1] != "_": checkName += "_"
  719. if checkLabel[-1] != "_": checkLabel += "_"
  720. if checkSName[-1] != "_": checkSName += "_"
  721. for root, dirs, files in os.walk(pluginDir):
  722. guiFiles = files
  723. break
  724. else:
  725. guiFiles = []
  726. for guiFile in guiFiles:
  727. if guiFile.startswith(checkName) or guiFile.startswith(checkLabel) or guiFile.startswith(checkSName):
  728. guiFilename = os.path.join(pluginDir, guiFile)
  729. break
  730. return guiFilename
  731. # ------------------------------------------------------------------------------------------------------------
  732. # Plugin Query
  733. PLUGIN_QUERY_API_VERSION = 1
  734. PyPluginInfo = {
  735. 'API': PLUGIN_QUERY_API_VERSION,
  736. 'build': 0, # BINARY_NONE
  737. 'type': 0, # PLUGIN_NONE
  738. 'hints': 0x0,
  739. 'binary': "",
  740. 'name': "",
  741. 'label': "",
  742. 'maker': "",
  743. 'copyright': "",
  744. 'uniqueId': 0,
  745. 'audio.ins': 0,
  746. 'audio.outs': 0,
  747. 'audio.total': 0,
  748. 'midi.ins': 0,
  749. 'midi.outs': 0,
  750. 'midi.total': 0,
  751. 'parameters.ins': 0,
  752. 'parameters.outs': 0,
  753. 'parameters.total': 0,
  754. 'programs.total': 0
  755. }
  756. def runCarlaDiscovery(itype, stype, filename, tool, isWine=False):
  757. fakeLabel = os.path.basename(filename).rsplit(".", 1)[0]
  758. plugins = []
  759. command = []
  760. if LINUX or MACOS:
  761. command.append("env")
  762. command.append("LANG=C")
  763. if isWine:
  764. command.append("WINEDEBUG=-all")
  765. command.append(tool)
  766. command.append(stype)
  767. command.append(filename)
  768. Ps = Popen(command, stdout=PIPE)
  769. Ps.wait()
  770. output = Ps.stdout.read().decode("utf-8", errors="ignore").split("\n")
  771. pinfo = None
  772. for line in output:
  773. line = line.strip()
  774. if line == "carla-discovery::init::-----------":
  775. pinfo = deepcopy(PyPluginInfo)
  776. pinfo['type'] = itype
  777. pinfo['binary'] = filename
  778. elif line == "carla-discovery::end::------------":
  779. if pinfo != None:
  780. plugins.append(pinfo)
  781. pinfo = None
  782. elif line == "Segmentation fault":
  783. print("carla-discovery::crash::%s crashed during discovery" % filename)
  784. elif line.startswith("err:module:import_dll Library"):
  785. print(line)
  786. elif line.startswith("carla-discovery::error::"):
  787. print("%s - %s" % (line, filename))
  788. elif line.startswith("carla-discovery::"):
  789. if pinfo == None:
  790. continue
  791. prop, value = line.replace("carla-discovery::", "").split("::", 1)
  792. if prop == "name":
  793. pinfo['name'] = value if value else fakeLabel
  794. elif prop == "label":
  795. pinfo['label'] = value if value else fakeLabel
  796. elif prop == "maker":
  797. pinfo['maker'] = value
  798. elif prop == "copyright":
  799. pinfo['copyright'] = value
  800. elif prop == "uniqueId":
  801. if value.isdigit(): pinfo['uniqueId'] = int(value)
  802. elif prop == "hints":
  803. if value.isdigit(): pinfo['hints'] = int(value)
  804. elif prop == "audio.ins":
  805. if value.isdigit(): pinfo['audio.ins'] = int(value)
  806. elif prop == "audio.outs":
  807. if value.isdigit(): pinfo['audio.outs'] = int(value)
  808. elif prop == "audio.total":
  809. if value.isdigit(): pinfo['audio.total'] = int(value)
  810. elif prop == "midi.ins":
  811. if value.isdigit(): pinfo['midi.ins'] = int(value)
  812. elif prop == "midi.outs":
  813. if value.isdigit(): pinfo['midi.outs'] = int(value)
  814. elif prop == "midi.total":
  815. if value.isdigit(): pinfo['midi.total'] = int(value)
  816. elif prop == "parameters.ins":
  817. if value.isdigit(): pinfo['parameters.ins'] = int(value)
  818. elif prop == "parameters.outs":
  819. if value.isdigit(): pinfo['parameters.outs'] = int(value)
  820. elif prop == "parameters.total":
  821. if value.isdigit(): pinfo['parameters.total'] = int(value)
  822. elif prop == "programs.total":
  823. if value.isdigit(): pinfo['programs.total'] = int(value)
  824. elif prop == "build":
  825. if value.isdigit(): pinfo['build'] = int(value)
  826. # Additional checks
  827. for pinfo in plugins:
  828. if itype == PLUGIN_DSSI:
  829. if findDSSIGUI(pinfo['binary'], pinfo['name'], pinfo['label']):
  830. pinfo['hints'] |= PLUGIN_HAS_GUI
  831. return plugins
  832. def checkPluginInternal(desc):
  833. plugins = []
  834. pinfo = deepcopy(PyPluginInfo)
  835. pinfo['build'] = BINARY_NATIVE
  836. pinfo['type'] = PLUGIN_INTERNAL
  837. pinfo['hints'] = int(desc['hints'])
  838. pinfo['name'] = cString(desc['name'])
  839. pinfo['label'] = cString(desc['label'])
  840. pinfo['maker'] = cString(desc['maker'])
  841. pinfo['copyright'] = cString(desc['copyright'])
  842. pinfo['audio.ins'] = int(desc['audioIns'])
  843. pinfo['audio.outs'] = int(desc['audioOuts'])
  844. pinfo['audio.total'] = pinfo['audio.ins'] + pinfo['audio.outs']
  845. pinfo['midi.ins'] = int(desc['midiIns'])
  846. pinfo['midi.outs'] = int(desc['midiOuts'])
  847. pinfo['midi.total'] = pinfo['midi.ins'] + pinfo['midi.outs']
  848. pinfo['parameters.ins'] = int(desc['parameterIns'])
  849. pinfo['parameters.outs'] = int(desc['parameterOuts'])
  850. pinfo['parameters.total'] = pinfo['parameters.ins'] + pinfo['parameters.outs']
  851. plugins.append(pinfo)
  852. return plugins
  853. def checkPluginLADSPA(filename, tool, isWine=False):
  854. return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, isWine)
  855. def checkPluginDSSI(filename, tool, isWine=False):
  856. return runCarlaDiscovery(PLUGIN_DSSI, "DSSI", filename, tool, isWine)
  857. def checkPluginLV2(filename, tool, isWine=False):
  858. return runCarlaDiscovery(PLUGIN_LV2, "LV2", filename, tool, isWine)
  859. def checkPluginVST(filename, tool, isWine=False):
  860. return runCarlaDiscovery(PLUGIN_VST, "VST", filename, tool, isWine)
  861. def checkPluginGIG(filename, tool):
  862. return runCarlaDiscovery(PLUGIN_GIG, "GIG", filename, tool)
  863. def checkPluginSF2(filename, tool):
  864. return runCarlaDiscovery(PLUGIN_SF2, "SF2", filename, tool)
  865. def checkPluginSFZ(filename, tool):
  866. return runCarlaDiscovery(PLUGIN_SFZ, "SFZ", filename, tool)
  867. # ------------------------------------------------------------------------------------------------------------
  868. # Carla XML helpers
  869. def xmlSafeString(string, toXml):
  870. if toXml:
  871. return string.replace("&", "&amp;").replace("<","&lt;").replace(">","&gt;").replace("'","&apos;").replace("\"","&quot;")
  872. else:
  873. return string.replace("&amp;", "&").replace("&lt;","<").replace("&gt;",">").replace("&apos;","'").replace("&quot;","\"")
  874. def getSaveStateDictFromXML(xmlNode):
  875. saveState = deepcopy(CarlaSaveState)
  876. node = xmlNode.firstChild()
  877. while not node.isNull():
  878. # ------------------------------------------------------
  879. # Info
  880. if node.toElement().tagName() == "Info":
  881. xmlInfo = node.toElement().firstChild()
  882. while not xmlInfo.isNull():
  883. tag = xmlInfo.toElement().tagName()
  884. text = xmlInfo.toElement().text().strip()
  885. if tag == "Type":
  886. saveState["type"] = text
  887. elif tag == "Name":
  888. saveState["name"] = xmlSafeString(text, False)
  889. elif tag in ("Label", "URI"):
  890. saveState["label"] = xmlSafeString(text, False)
  891. elif tag == "Binary":
  892. saveState["binary"] = xmlSafeString(text, False)
  893. elif tag == "UniqueID":
  894. if text.isdigit(): saveState["uniqueId"] = int(text)
  895. xmlInfo = xmlInfo.nextSibling()
  896. # ------------------------------------------------------
  897. # Data
  898. elif node.toElement().tagName() == "Data":
  899. xmlData = node.toElement().firstChild()
  900. while not xmlData.isNull():
  901. tag = xmlData.toElement().tagName()
  902. text = xmlData.toElement().text().strip()
  903. # ----------------------------------------------
  904. # Internal Data
  905. if tag == "Active":
  906. saveState['active'] = bool(text == "Yes")
  907. elif tag == "DryWet":
  908. if isNumber(text): saveState["dryWet"] = float(text)
  909. elif tag == "Volume":
  910. if isNumber(text): saveState["volume"] = float(text)
  911. elif tag == "Balance-Left":
  912. if isNumber(text): saveState["balanceLeft"] = float(text)
  913. elif tag == "Balance-Right":
  914. if isNumber(text): saveState["balanceRight"] = float(text)
  915. elif tag == "Panning":
  916. if isNumber(text): saveState["pannning"] = float(text)
  917. # ----------------------------------------------
  918. # Program (current)
  919. elif tag == "CurrentProgramIndex":
  920. if text.isdigit(): saveState["currentProgramIndex"] = int(text)
  921. elif tag == "CurrentProgramName":
  922. saveState["currentProgramName"] = xmlSafeString(text, False)
  923. # ----------------------------------------------
  924. # Midi Program (current)
  925. elif tag == "CurrentMidiBank":
  926. if text.isdigit(): saveState["currentMidiBank"] = int(text)
  927. elif tag == "CurrentMidiProgram":
  928. if text.isdigit(): saveState["currentMidiProgram"] = int(text)
  929. # ----------------------------------------------
  930. # Parameters
  931. elif tag == "Parameter":
  932. stateParameter = deepcopy(CarlaStateParameter)
  933. xmlSubData = xmlData.toElement().firstChild()
  934. while not xmlSubData.isNull():
  935. pTag = xmlSubData.toElement().tagName()
  936. pText = xmlSubData.toElement().text().strip()
  937. if pTag == "Index":
  938. if pText.isdigit(): stateParameter["index"] = int(pText)
  939. elif pTag == "Name":
  940. stateParameter["name"] = xmlSafeString(pText, False)
  941. elif pTag == "Symbol":
  942. stateParameter["symbol"] = xmlSafeString(pText, False)
  943. elif pTag == "Value":
  944. if isNumber(pText): stateParameter["value"] = float(pText)
  945. elif pTag == "MidiChannel":
  946. if pText.isdigit(): stateParameter["midiChannel"] = int(pText)
  947. elif pTag == "MidiCC":
  948. if pText.isdigit(): stateParameter["midiCC"] = int(pText)
  949. xmlSubData = xmlSubData.nextSibling()
  950. saveState["parameterList"].append(stateParameter)
  951. # ----------------------------------------------
  952. # Custom Data
  953. elif tag == "CustomData":
  954. stateCustomData = deepcopy(CarlaStateCustomData)
  955. xmlSubData = xmlData.toElement().firstChild()
  956. while not xmlSubData.isNull():
  957. cTag = xmlSubData.toElement().tagName()
  958. cText = xmlSubData.toElement().text().strip()
  959. if cTag == "Type":
  960. stateCustomData["type"] = xmlSafeString(cText, False)
  961. elif cTag == "Key":
  962. stateCustomData["key"] = xmlSafeString(cText, False)
  963. elif cTag == "Value":
  964. stateCustomData["value"] = xmlSafeString(cText, False)
  965. xmlSubData = xmlSubData.nextSibling()
  966. saveState["customDataList"].append(stateCustomData)
  967. # ----------------------------------------------
  968. # Chunk
  969. elif tag == "Chunk":
  970. saveState["chunk"] = xmlSafeString(text, False)
  971. # ----------------------------------------------
  972. xmlData = xmlData.nextSibling()
  973. # ------------------------------------------------------
  974. node = node.nextSibling()
  975. return saveState
  976. # ------------------------------------------------------------------------------------------------------------
  977. # Carla About dialog
  978. class CarlaAboutW(QDialog):
  979. def __init__(self, parent):
  980. QDialog.__init__(self, parent)
  981. self.ui = ui_carla_about.Ui_CarlaAboutW()
  982. self.ui.setupUi(self)
  983. if Carla.isControl:
  984. extraInfo = " - <b>%s</b>" % self.tr("OSC Bridge Version")
  985. else:
  986. extraInfo = ""
  987. self.ui.l_about.setText(self.tr(""
  988. "<br>Version %s"
  989. "<br>Carla is a Multi-Plugin Host for JACK%s.<br>"
  990. "<br>Copyright (C) 2011-2013 falkTX<br>"
  991. "" % (VERSION, extraInfo)))
  992. if Carla.isControl:
  993. self.ui.l_extended.hide()
  994. self.ui.tabWidget.removeTab(1)
  995. self.ui.tabWidget.removeTab(1)
  996. else:
  997. self.ui.l_extended.setText(cString(Carla.host.get_extended_license_text()))
  998. self.ui.le_osc_url.setText(cString(Carla.host.get_host_osc_url()) if Carla.host.is_engine_running() else self.tr("(Engine not running)"))
  999. self.ui.l_osc_cmds.setText(
  1000. " /set_active <i-value>\n"
  1001. " /set_drywet <f-value>\n"
  1002. " /set_volume <f-value>\n"
  1003. " /set_balance_left <f-value>\n"
  1004. " /set_balance_right <f-value>\n"
  1005. " /set_panning <f-value>\n"
  1006. " /set_parameter_value <i-index> <f-value>\n"
  1007. " /set_parameter_midi_cc <i-index> <i-cc>\n"
  1008. " /set_parameter_midi_channel <i-index> <i-channel>\n"
  1009. " /set_program <i-index>\n"
  1010. " /set_midi_program <i-index>\n"
  1011. " /note_on <i-note> <i-velo>\n"
  1012. " /note_off <i-note>\n"
  1013. )
  1014. self.ui.l_example.setText("/Carla/2/set_parameter_value 5 1.0")
  1015. self.ui.l_example_help.setText("<i>(as in this example, \"2\" is the plugin number and \"5\" the parameter)</i>")
  1016. self.ui.l_ladspa.setText(self.tr("Everything! (Including LRDF)"))
  1017. self.ui.l_dssi.setText(self.tr("Everything! (Including CustomData/Chunks)"))
  1018. self.ui.l_lv2.setText(self.tr("About 95&#37; complete (using custom extensions).<br/>"
  1019. "Implemented Feature/Extensions:"
  1020. "<ul>"
  1021. "<li>http://lv2plug.in/ns/ext/atom</li>"
  1022. "<li>http://lv2plug.in/ns/ext/buf-size</li>"
  1023. "<li>http://lv2plug.in/ns/ext/data-access</li>"
  1024. #"<li>http://lv2plug.in/ns/ext/dynmanifest</li>"
  1025. "<li>http://lv2plug.in/ns/ext/event</li>"
  1026. "<li>http://lv2plug.in/ns/ext/instance-access</li>"
  1027. "<li>http://lv2plug.in/ns/ext/log</li>"
  1028. "<li>http://lv2plug.in/ns/ext/midi</li>"
  1029. "<li>http://lv2plug.in/ns/ext/options</li>"
  1030. #"<li>http://lv2plug.in/ns/ext/parameters</li>"
  1031. "<li>http://lv2plug.in/ns/ext/patch</li>"
  1032. #"<li>http://lv2plug.in/ns/ext/port-groups</li>"
  1033. "<li>http://lv2plug.in/ns/ext/port-props</li>"
  1034. #"<li>http://lv2plug.in/ns/ext/presets</li>"
  1035. "<li>http://lv2plug.in/ns/ext/state</li>"
  1036. "<li>http://lv2plug.in/ns/ext/time</li>"
  1037. "<li>http://lv2plug.in/ns/ext/uri-map</li>"
  1038. "<li>http://lv2plug.in/ns/ext/urid</li>"
  1039. "<li>http://lv2plug.in/ns/ext/worker</li>"
  1040. "<li>http://lv2plug.in/ns/extensions/ui</li>"
  1041. "<li>http://lv2plug.in/ns/extensions/units</li>"
  1042. "<li>http://kxstudio.sf.net/ns/lv2ext/external-ui</li>"
  1043. "<li>http://kxstudio.sf.net/ns/lv2ext/programs</li>"
  1044. "<li>http://kxstudio.sf.net/ns/lv2ext/rtmempool</li>"
  1045. "<li>http://ll-plugins.nongnu.org/lv2/ext/midimap</li>"
  1046. "<li>http://ll-plugins.nongnu.org/lv2/ext/miditype</li>"
  1047. "</ul>"))
  1048. self.ui.l_vst.setText(self.tr("<p>About 85&#37; complete (missing vst bank/presets and some minor stuff)</p>"))
  1049. def done(self, r):
  1050. QDialog.done(self, r)
  1051. self.close()
  1052. # ------------------------------------------------------------------------------------------------------------
  1053. # Plugin Parameter
  1054. class PluginParameter(QWidget):
  1055. def __init__(self, parent, pInfo, pluginId, tabIndex):
  1056. QWidget.__init__(self, parent)
  1057. self.ui = ui_carla_parameter.Ui_PluginParameter()
  1058. self.ui.setupUi(self)
  1059. pType = pInfo['type']
  1060. pHints = pInfo['hints']
  1061. self.fMidiControl = -1
  1062. self.fMidiChannel = 1
  1063. self.fParameterId = pInfo['index']
  1064. self.fPluginId = pluginId
  1065. self.fTabIndex = tabIndex
  1066. self.ui.label.setText(pInfo['name'])
  1067. self.ui.widget.setName(pInfo['name'])
  1068. if pType == PARAMETER_INPUT:
  1069. self.ui.widget.setMinimum(pInfo['minimum'])
  1070. self.ui.widget.setMaximum(pInfo['maximum'])
  1071. self.ui.widget.setDefault(pInfo['default'])
  1072. self.ui.widget.setValue(pInfo['current'], False)
  1073. self.ui.widget.setLabel(pInfo['unit'])
  1074. self.ui.widget.setStep(pInfo['step'])
  1075. self.ui.widget.setStepSmall(pInfo['stepSmall'])
  1076. self.ui.widget.setStepLarge(pInfo['stepLarge'])
  1077. self.ui.widget.setScalePoints(pInfo['scalePoints'], bool(pHints & PARAMETER_USES_SCALEPOINTS))
  1078. if not pHints & PARAMETER_IS_ENABLED:
  1079. self.ui.widget.setReadOnly(True)
  1080. self.ui.sb_control.setEnabled(False)
  1081. self.ui.sb_channel.setEnabled(False)
  1082. elif not pHints & PARAMETER_IS_AUTOMABLE:
  1083. self.ui.sb_control.setEnabled(False)
  1084. self.ui.sb_channel.setEnabled(False)
  1085. elif pType == PARAMETER_OUTPUT:
  1086. self.ui.widget.setMinimum(pInfo['minimum'])
  1087. self.ui.widget.setMaximum(pInfo['maximum'])
  1088. self.ui.widget.setValue(pInfo['current'], False)
  1089. self.ui.widget.setLabel(pInfo['unit'])
  1090. self.ui.widget.setReadOnly(True)
  1091. if not pHints & PARAMETER_IS_AUTOMABLE:
  1092. self.ui.sb_control.setEnabled(False)
  1093. self.ui.sb_channel.setEnabled(False)
  1094. else:
  1095. self.ui.widget.setVisible(False)
  1096. self.ui.sb_control.setVisible(False)
  1097. self.ui.sb_channel.setVisible(False)
  1098. if pHints & PARAMETER_USES_CUSTOM_TEXT:
  1099. self.ui.widget.setTextCallback(self._textCallBack)
  1100. self.setMidiControl(pInfo['midiCC'])
  1101. self.setMidiChannel(pInfo['midiChannel'])
  1102. self.connect(self.ui.sb_control, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_controlSpinboxCustomMenu()"))
  1103. self.connect(self.ui.sb_control, SIGNAL("valueChanged(int)"), SLOT("slot_controlSpinboxChanged(int)"))
  1104. self.connect(self.ui.sb_channel, SIGNAL("valueChanged(int)"), SLOT("slot_channelSpinboxChanged(int)"))
  1105. self.connect(self.ui.widget, SIGNAL("valueChanged(double)"), SLOT("slot_widgetValueChanged(double)"))
  1106. self.ui.widget.updateAll()
  1107. def setDefault(self, value):
  1108. self.ui.widget.setDefault(value)
  1109. def setValue(self, value, send=True):
  1110. self.ui.widget.setValue(value, send)
  1111. def setMidiControl(self, control):
  1112. self.fMidiControl = control
  1113. self.ui.sb_control.blockSignals(True)
  1114. self.ui.sb_control.setValue(control)
  1115. self.ui.sb_control.blockSignals(False)
  1116. def setMidiChannel(self, channel):
  1117. self.fMidiChannel = channel
  1118. self.ui.sb_channel.blockSignals(True)
  1119. self.ui.sb_channel.setValue(channel)
  1120. self.ui.sb_channel.blockSignals(False)
  1121. def setLabelWidth(self, width):
  1122. self.ui.label.setMinimumWidth(width)
  1123. self.ui.label.setMaximumWidth(width)
  1124. def tabIndex(self):
  1125. return self.fTabIndex
  1126. @pyqtSlot()
  1127. def slot_controlSpinboxCustomMenu(self):
  1128. menu = QMenu(self)
  1129. for cc in MIDI_CC_LIST:
  1130. action = menu.addAction(cc)
  1131. if int(cc.split(" ")[0], 16) == self.fMidiControl:
  1132. action.setCheckable(True)
  1133. action.setChecked(True)
  1134. actSel = menu.exec_(QCursor.pos())
  1135. if actSel:
  1136. selControlStr = actSel.text()
  1137. selControl = int(selControlStr.split(" ")[0], 16)
  1138. self.ui.sb_control.setValue(selControl)
  1139. @pyqtSlot(int)
  1140. def slot_controlSpinboxChanged(self, control):
  1141. if self.fMidiControl != control:
  1142. self.emit(SIGNAL("midiControlChanged(int, int)"), self.fParameterId, control)
  1143. self.fMidiControl = control
  1144. @pyqtSlot(int)
  1145. def slot_channelSpinboxChanged(self, channel):
  1146. if self.fMidiChannel != channel:
  1147. self.emit(SIGNAL("midiChannelChanged(int, int)"), self.fParameterId, channel)
  1148. self.fMidiChannel = channel
  1149. @pyqtSlot(float)
  1150. def slot_widgetValueChanged(self, value):
  1151. self.emit(SIGNAL("valueChanged(int, double)"), self.fParameterId, value)
  1152. def _textCallBack(self):
  1153. return cString(Carla.host.get_parameter_text(self.fPluginId, self.fParameterId))
  1154. # ------------------------------------------------------------------------------------------------------------
  1155. # Plugin Editor (Built-in)
  1156. class PluginEdit(QDialog):
  1157. def __init__(self, parent, pluginId):
  1158. QDialog.__init__(self, Carla.gui)
  1159. self.ui = ui_carla_edit.Ui_PluginEdit()
  1160. self.ui.setupUi(self)
  1161. self.fGeometry = QByteArray()
  1162. self.fPluginId = pluginId
  1163. self.fPuginInfo = None
  1164. self.fRealParent = parent
  1165. self.fCurrentProgram = -1
  1166. self.fCurrentMidiProgram = -1
  1167. self.fCurrentStateFilename = None
  1168. self.fControlChannel = pluginId+1 if Carla.processMode == PROCESS_MODE_CONTINUOUS_RACK else 1
  1169. self.fParameterCount = 0
  1170. self.fParameterList = [] # (type, id, widget)
  1171. self.fParametersToUpdate = [] # (id, value)
  1172. self.fTabIconOff = QIcon(":/bitmaps/led_off.png")
  1173. self.fTabIconOn = QIcon(":/bitmaps/led_yellow.png")
  1174. self.fTabIconCount = 0
  1175. self.fTabIconTimers = []
  1176. self.ui.dial_drywet.setPixmap(3)
  1177. self.ui.dial_drywet.setLabel("Dry/Wet")
  1178. self.ui.dial_vol.setPixmap(3)
  1179. self.ui.dial_vol.setLabel("Volume")
  1180. self.ui.dial_b_left.setPixmap(4)
  1181. self.ui.dial_b_left.setLabel("L")
  1182. self.ui.dial_b_right.setPixmap(4)
  1183. self.ui.dial_b_right.setLabel("R")
  1184. self.ui.dial_drywet.setCustomPaint(self.ui.dial_drywet.CUSTOM_PAINT_CARLA_WET)
  1185. self.ui.dial_vol.setCustomPaint(self.ui.dial_vol.CUSTOM_PAINT_CARLA_VOL)
  1186. self.ui.dial_b_left.setCustomPaint(self.ui.dial_b_left.CUSTOM_PAINT_CARLA_L)
  1187. self.ui.dial_b_right.setCustomPaint(self.ui.dial_b_right.CUSTOM_PAINT_CARLA_R)
  1188. self.ui.keyboard.setMode(self.ui.keyboard.HORIZONTAL)
  1189. self.ui.keyboard.setOctaves(6)
  1190. self.ui.sb_ctrl_channel.setValue(self.fControlChannel)
  1191. self.ui.scrollArea.ensureVisible(self.ui.keyboard.width() / 5, 0)
  1192. self.ui.scrollArea.setEnabled(False)
  1193. self.ui.scrollArea.setVisible(False)
  1194. if Carla.isLocal:
  1195. self.connect(self.ui.b_save_state, SIGNAL("clicked()"), SLOT("slot_saveState()"))
  1196. self.connect(self.ui.b_load_state, SIGNAL("clicked()"), SLOT("slot_loadState()"))
  1197. else:
  1198. self.ui.b_load_state.setEnabled(False)
  1199. self.ui.b_save_state.setEnabled(False)
  1200. # Set options
  1201. self.connect(self.ui.ch_fixed_buffer, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  1202. self.connect(self.ui.ch_force_stereo, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  1203. self.connect(self.ui.ch_map_program_changes, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  1204. self.connect(self.ui.ch_use_chunks, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  1205. self.connect(self.ui.ch_send_control_changes, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  1206. self.connect(self.ui.ch_send_channel_pressure, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  1207. self.connect(self.ui.ch_send_note_aftertouch, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  1208. self.connect(self.ui.ch_send_pitchbend, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  1209. self.connect(self.ui.ch_send_all_sound_off, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  1210. self.connect(self.ui.dial_drywet, SIGNAL("valueChanged(int)"), SLOT("slot_dryWetChanged(int)"))
  1211. self.connect(self.ui.dial_vol, SIGNAL("valueChanged(int)"), SLOT("slot_volumeChanged(int)"))
  1212. self.connect(self.ui.dial_b_left, SIGNAL("valueChanged(int)"), SLOT("slot_balanceLeftChanged(int)"))
  1213. self.connect(self.ui.dial_b_right, SIGNAL("valueChanged(int)"), SLOT("slot_balanceRightChanged(int)"))
  1214. self.connect(self.ui.sb_ctrl_channel, SIGNAL("valueChanged(int)"), SLOT("slot_ctrlChannelChanged(int)"))
  1215. #self.connect(self.ui.dial_drywet, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  1216. #self.connect(self.ui.dial_vol, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  1217. #self.connect(self.ui.dial_b_left, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  1218. #self.connect(self.ui.dial_b_right, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  1219. self.connect(self.ui.keyboard, SIGNAL("noteOn(int)"), SLOT("slot_noteOn(int)"))
  1220. self.connect(self.ui.keyboard, SIGNAL("noteOff(int)"), SLOT("slot_noteOff(int)"))
  1221. self.connect(self.ui.keyboard, SIGNAL("notesOn()"), SLOT("slot_notesOn()"))
  1222. self.connect(self.ui.keyboard, SIGNAL("notesOff()"), SLOT("slot_notesOff()"))
  1223. self.connect(self.ui.cb_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_programIndexChanged(int)"))
  1224. self.connect(self.ui.cb_midi_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_midiProgramIndexChanged(int)"))
  1225. self.connect(self, SIGNAL("finished(int)"), SLOT("slot_finished()"))
  1226. self.reloadAll()
  1227. def reloadAll(self):
  1228. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId)
  1229. self.fPluginInfo["binary"] = cString(self.fPluginInfo["binary"])
  1230. self.fPluginInfo["name"] = cString(self.fPluginInfo["name"])
  1231. self.fPluginInfo["label"] = cString(self.fPluginInfo["label"])
  1232. self.fPluginInfo["maker"] = cString(self.fPluginInfo["maker"])
  1233. self.fPluginInfo["copyright"] = cString(self.fPluginInfo["copyright"])
  1234. self.reloadInfo()
  1235. self.reloadParameters()
  1236. self.reloadPrograms()
  1237. if not self.ui.scrollArea.isEnabled():
  1238. self.resize(self.width(), self.height()-self.ui.keyboard.height())
  1239. def reloadInfo(self):
  1240. pluginName = cString(Carla.host.get_real_plugin_name(self.fPluginId))
  1241. pluginType = self.fPluginInfo['type']
  1242. pluginHints = self.fPluginInfo['hints']
  1243. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  1244. midiCountInfo = Carla.host.get_midi_port_count_info(self.fPluginId)
  1245. paramCountInfo = Carla.host.get_parameter_count_info(self.fPluginId)
  1246. if pluginType == PLUGIN_INTERNAL:
  1247. self.ui.le_type.setText(self.tr("Internal"))
  1248. elif pluginType == PLUGIN_LADSPA:
  1249. self.ui.le_type.setText("LADSPA")
  1250. elif pluginType == PLUGIN_DSSI:
  1251. self.ui.le_type.setText("DSSI")
  1252. elif pluginType == PLUGIN_LV2:
  1253. self.ui.le_type.setText("LV2")
  1254. elif pluginType == PLUGIN_VST:
  1255. self.ui.le_type.setText("VST")
  1256. elif pluginType == PLUGIN_GIG:
  1257. self.ui.le_type.setText("GIG")
  1258. elif pluginType == PLUGIN_SF2:
  1259. self.ui.le_type.setText("SF2")
  1260. elif pluginType == PLUGIN_SFZ:
  1261. self.ui.le_type.setText("SFZ")
  1262. else:
  1263. self.ui.le_type.setText(self.tr("Unknown"))
  1264. self.ui.le_name.setText(pluginName)
  1265. self.ui.le_name.setToolTip(pluginName)
  1266. self.ui.le_label.setText(self.fPluginInfo['label'])
  1267. self.ui.le_label.setToolTip(self.fPluginInfo['label'])
  1268. self.ui.le_maker.setText(self.fPluginInfo['maker'])
  1269. self.ui.le_maker.setToolTip(self.fPluginInfo['maker'])
  1270. self.ui.le_copyright.setText(self.fPluginInfo['copyright'])
  1271. self.ui.le_copyright.setToolTip(self.fPluginInfo['copyright'])
  1272. self.ui.le_unique_id.setText(str(self.fPluginInfo['uniqueId']))
  1273. self.ui.le_unique_id.setToolTip(str(self.fPluginInfo['uniqueId']))
  1274. self.ui.le_ains.setText(str(audioCountInfo['ins']))
  1275. self.ui.le_aouts.setText(str(audioCountInfo['outs']))
  1276. self.ui.le_params.setText(str(paramCountInfo['ins']))
  1277. self.ui.label_plugin.setText("\n%s\n" % self.fPluginInfo['name'])
  1278. self.setWindowTitle(self.fPluginInfo['name'])
  1279. if self.fPluginInfo['latency'] > 0:
  1280. self.ui.le_latency.setText("%i samples" % self.fPluginInfo['latency'])
  1281. else:
  1282. self.ui.le_latency.setText(self.tr("None"))
  1283. self.ui.dial_drywet.setEnabled(pluginHints & PLUGIN_CAN_DRYWET)
  1284. self.ui.dial_vol.setEnabled(pluginHints & PLUGIN_CAN_VOLUME)
  1285. self.ui.dial_b_left.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  1286. self.ui.dial_b_right.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  1287. # Set options
  1288. self.ui.ch_fixed_buffer.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FIXED_BUFFER)
  1289. self.ui.ch_fixed_buffer.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FIXED_BUFFER)
  1290. self.ui.ch_force_stereo.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FORCE_STEREO)
  1291. self.ui.ch_force_stereo.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FORCE_STEREO)
  1292. self.ui.ch_map_program_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  1293. self.ui.ch_map_program_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  1294. self.ui.ch_use_chunks.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_USE_CHUNKS)
  1295. self.ui.ch_use_chunks.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_USE_CHUNKS)
  1296. self.ui.ch_send_control_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  1297. self.ui.ch_send_control_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  1298. self.ui.ch_send_channel_pressure.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  1299. self.ui.ch_send_channel_pressure.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  1300. self.ui.ch_send_note_aftertouch.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  1301. self.ui.ch_send_note_aftertouch.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  1302. self.ui.ch_send_pitchbend.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PITCHBEND)
  1303. self.ui.ch_send_pitchbend.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_PITCHBEND)
  1304. self.ui.ch_send_all_sound_off.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  1305. self.ui.ch_send_all_sound_off.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  1306. # Show/hide keyboard
  1307. showKeyboard = (pluginHints & PLUGIN_IS_SYNTH) != 0 or (midiCountInfo['ins'] > 0 < midiCountInfo['outs'])
  1308. self.ui.scrollArea.setEnabled(showKeyboard)
  1309. self.ui.scrollArea.setVisible(showKeyboard)
  1310. # Force-Update parent for new hints (knobs)
  1311. if self.fRealParent:
  1312. self.fRealParent.recheckPluginHints(pluginHints)
  1313. def reloadParameters(self):
  1314. parameterCount = Carla.host.get_parameter_count(self.fPluginId)
  1315. # Reset
  1316. self.fParameterCount = 0
  1317. self.fParameterList = []
  1318. self.fParametersToUpdate = []
  1319. self.fTabIconCount = 0
  1320. self.fTabIconTimers = []
  1321. # Remove all previous parameters
  1322. for i in range(self.ui.tabWidget.count()-1):
  1323. self.ui.tabWidget.widget(1).deleteLater()
  1324. self.ui.tabWidget.removeTab(1)
  1325. if parameterCount <= 0:
  1326. pass
  1327. elif parameterCount <= Carla.maxParameters:
  1328. paramInputListFull = []
  1329. paramOutputListFull = []
  1330. paramInputList = [] # ([params], width)
  1331. paramInputWidth = 0
  1332. paramOutputList = [] # ([params], width)
  1333. paramOutputWidth = 0
  1334. for i in range(parameterCount):
  1335. paramInfo = Carla.host.get_parameter_info(self.fPluginId, i)
  1336. paramData = Carla.host.get_parameter_data(self.fPluginId, i)
  1337. paramRanges = Carla.host.get_parameter_ranges(self.fPluginId, i)
  1338. if paramData['type'] not in (PARAMETER_INPUT, PARAMETER_OUTPUT):
  1339. continue
  1340. parameter = {
  1341. 'type': paramData['type'],
  1342. 'hints': paramData['hints'],
  1343. 'name': cString(paramInfo['name']),
  1344. 'unit': cString(paramInfo['unit']),
  1345. 'scalePoints': [],
  1346. 'index': paramData['index'],
  1347. 'default': paramRanges['def'],
  1348. 'minimum': paramRanges['min'],
  1349. 'maximum': paramRanges['max'],
  1350. 'step': paramRanges['step'],
  1351. 'stepSmall': paramRanges['stepSmall'],
  1352. 'stepLarge': paramRanges['stepLarge'],
  1353. 'midiCC': paramData['midiCC'],
  1354. 'midiChannel': paramData['midiChannel'],
  1355. 'current': Carla.host.get_current_parameter_value(self.fPluginId, i)
  1356. }
  1357. for j in range(paramInfo['scalePointCount']):
  1358. scalePointInfo = Carla.host.get_parameter_scalepoint_info(self.fPluginId, i, j)
  1359. parameter['scalePoints'].append({
  1360. 'value': scalePointInfo['value'],
  1361. 'label': cString(scalePointInfo['label'])
  1362. })
  1363. # -----------------------------------------------------------------
  1364. # Get width values, in packs of 10
  1365. if parameter['type'] == PARAMETER_INPUT:
  1366. paramInputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  1367. if paramInputWidthTMP > paramInputWidth:
  1368. paramInputWidth = paramInputWidthTMP
  1369. paramInputList.append(parameter)
  1370. if len(paramInputList) == 10:
  1371. paramInputListFull.append((paramInputList, paramInputWidth))
  1372. paramInputList = []
  1373. paramInputWidth = 0
  1374. else:
  1375. paramOutputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  1376. if paramOutputWidthTMP > paramOutputWidth:
  1377. paramOutputWidth = paramOutputWidthTMP
  1378. paramOutputList.append(parameter)
  1379. if len(paramOutputList) == 10:
  1380. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  1381. paramOutputList = []
  1382. paramOutputWidth = 0
  1383. # for i in range(parameterCount)
  1384. else:
  1385. # Final page width values
  1386. if 0 < len(paramInputList) < 10:
  1387. paramInputListFull.append((paramInputList, paramInputWidth))
  1388. if 0 < len(paramOutputList) < 10:
  1389. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  1390. # -----------------------------------------------------------------
  1391. # Create parameter widgets
  1392. self._createParameterWidgets(PARAMETER_INPUT, paramInputListFull, self.tr("Parameters"))
  1393. self._createParameterWidgets(PARAMETER_OUTPUT, paramOutputListFull, self.tr("Outputs"))
  1394. else: # > Carla.maxParameters
  1395. fakeName = self.tr("This plugin has too many parameters to display here!")
  1396. paramFakeListFull = []
  1397. paramFakeList = []
  1398. paramFakeWidth = QFontMetrics(self.font()).width(fakeName)
  1399. parameter = {
  1400. 'type': PARAMETER_UNKNOWN,
  1401. 'hints': 0,
  1402. 'name': fakeName,
  1403. 'unit': "",
  1404. 'scalePoints': [],
  1405. 'index': 0,
  1406. 'default': 0,
  1407. 'minimum': 0,
  1408. 'maximum': 0,
  1409. 'step': 0,
  1410. 'stepSmall': 0,
  1411. 'stepLarge': 0,
  1412. 'midiCC': -1,
  1413. 'midiChannel': 0,
  1414. 'current': 0.0
  1415. }
  1416. paramFakeList.append(parameter)
  1417. paramFakeListFull.append((paramFakeList, paramFakeWidth))
  1418. self._createParameterWidgets(PARAMETER_UNKNOWN, paramFakeListFull, self.tr("Information"))
  1419. def reloadPrograms(self):
  1420. # Programs
  1421. self.ui.cb_programs.blockSignals(True)
  1422. self.ui.cb_programs.clear()
  1423. programCount = Carla.host.get_program_count(self.fPluginId)
  1424. if programCount > 0:
  1425. self.ui.cb_programs.setEnabled(True)
  1426. for i in range(programCount):
  1427. pName = cString(Carla.host.get_program_name(self.fPluginId, i))
  1428. self.ui.cb_programs.addItem(pName)
  1429. self.fCurrentProgram = Carla.host.get_current_program_index(self.fPluginId)
  1430. self.ui.cb_programs.setCurrentIndex(self.fCurrentProgram)
  1431. else:
  1432. self.fCurrentProgram = -1
  1433. self.ui.cb_programs.setEnabled(False)
  1434. self.ui.cb_programs.blockSignals(False)
  1435. # MIDI Programs
  1436. self.ui.cb_midi_programs.blockSignals(True)
  1437. self.ui.cb_midi_programs.clear()
  1438. midiProgramCount = Carla.host.get_midi_program_count(self.fPluginId)
  1439. if midiProgramCount > 0:
  1440. self.ui.cb_midi_programs.setEnabled(True)
  1441. for i in range(midiProgramCount):
  1442. mpData = Carla.host.get_midi_program_data(self.fPluginId, i)
  1443. mpBank = int(mpData['bank'])
  1444. mpProg = int(mpData['program'])
  1445. mpLabel = cString(mpData['name'])
  1446. self.ui.cb_midi_programs.addItem("%03i:%03i - %s" % (mpBank, mpProg, mpLabel))
  1447. self.fCurrentMidiProgram = Carla.host.get_current_midi_program_index(self.fPluginId)
  1448. self.ui.cb_midi_programs.setCurrentIndex(self.fCurrentMidiProgram)
  1449. else:
  1450. self.fCurrentMidiProgram = -1
  1451. self.ui.cb_midi_programs.setEnabled(False)
  1452. self.ui.cb_midi_programs.blockSignals(False)
  1453. # Automatically change to Midi Programs tab
  1454. if midiProgramCount > 0 and programCount == 0:
  1455. self.ui.tab_programs.setCurrentIndex(1)
  1456. def updateInfo(self):
  1457. # Update current program text
  1458. if self.ui.cb_programs.count() > 0:
  1459. pIndex = self.ui.cb_programs.currentIndex()
  1460. pName = cString(Carla.host.get_program_name(self.fPluginId, pIndex))
  1461. self.ui.cb_programs.setItemText(pIndex, pName)
  1462. # Update current midi program text
  1463. if self.ui.cb_midi_programs.count() > 0:
  1464. mpIndex = self.ui.cb_midi_programs.currentIndex()
  1465. mpData = Carla.host.get_midi_program_data(self.fPluginId, mpIndex)
  1466. mpBank = int(mpData['bank'])
  1467. mpProg = int(mpData['program'])
  1468. mpLabel = cString(mpData['name'])
  1469. self.ui.cb_midi_programs.setItemText(mpIndex, "%03i:%03i - %s" % (mpBank, mpProg, mpLabel))
  1470. # Update all parameter values
  1471. for paramType, paramId, paramWidget in self.fParameterList:
  1472. paramWidget.setValue(Carla.host.get_current_parameter_value(self.fPluginId, paramId), False)
  1473. paramWidget.update()
  1474. def setParameterValue(self, parameterId, value):
  1475. for paramItem in self.fParametersToUpdate:
  1476. if paramItem[0] == parameterId:
  1477. paramItem[1] = value
  1478. break
  1479. else:
  1480. self.fParametersToUpdate.append([parameterId, value])
  1481. def setParameterDefault(self, parameterId, value):
  1482. for paramType, paramId, paramWidget in self.fParameterList:
  1483. if paramId == parameterId:
  1484. paramWidget.setDefault(value)
  1485. break
  1486. def setParameterMidiControl(self, parameterId, control):
  1487. for paramType, paramId, paramWidget in self.fParameterList:
  1488. if paramId == parameterId:
  1489. paramWidget.setMidiControl(control)
  1490. break
  1491. def setParameterMidiChannel(self, parameterId, channel):
  1492. for paramType, paramId, paramWidget in self.fParameterList:
  1493. if paramId == parameterId:
  1494. paramWidget.setMidiChannel(channel)
  1495. break
  1496. def setProgram(self, index):
  1497. self.ui.cb_programs.blockSignals(True)
  1498. self.ui.cb_programs.setCurrentIndex(index)
  1499. self.ui.cb_programs.blockSignals(False)
  1500. def setMidiProgram(self, index):
  1501. self.ui.cb_midi_programs.blockSignals(True)
  1502. self.ui.cb_midi_programs.setCurrentIndex(index)
  1503. self.ui.cb_midi_programs.blockSignals(False)
  1504. def sendNoteOn(self, channel, note):
  1505. if self.fControlChannel == channel:
  1506. self.ui.keyboard.sendNoteOn(note, False)
  1507. def sendNoteOff(self, channel, note):
  1508. if self.fControlChannel == channel:
  1509. self.ui.keyboard.sendNoteOff(note, False)
  1510. def setVisible(self, yesNo):
  1511. if yesNo:
  1512. if not self.fGeometry.isNull():
  1513. self.restoreGeometry(self.fGeometry)
  1514. else:
  1515. self.fGeometry = self.saveGeometry()
  1516. QDialog.setVisible(self, yesNo)
  1517. def idleSlow(self):
  1518. # Check Tab icons
  1519. for i in range(len(self.fTabIconTimers)):
  1520. if self.fTabIconTimers[i] == ICON_STATE_ON:
  1521. self.fTabIconTimers[i] = ICON_STATE_WAIT
  1522. elif self.fTabIconTimers[i] == ICON_STATE_WAIT:
  1523. self.fTabIconTimers[i] = ICON_STATE_OFF
  1524. elif self.fTabIconTimers[i] == ICON_STATE_OFF:
  1525. self.fTabIconTimers[i] = ICON_STATE_NULL
  1526. self.ui.tabWidget.setTabIcon(i+1, self.fTabIconOff)
  1527. # Check parameters needing update
  1528. for index, value in self.fParametersToUpdate:
  1529. if index == PARAMETER_DRYWET:
  1530. self.ui.dial_drywet.blockSignals(True)
  1531. self.ui.dial_drywet.setValue(value * 1000)
  1532. self.ui.dial_drywet.blockSignals(False)
  1533. elif index == PARAMETER_VOLUME:
  1534. self.ui.dial_vol.blockSignals(True)
  1535. self.ui.dial_vol.setValue(value * 1000)
  1536. self.ui.dial_vol.blockSignals(False)
  1537. elif index == PARAMETER_BALANCE_LEFT:
  1538. self.ui.dial_b_left.blockSignals(True)
  1539. self.ui.dial_b_left.setValue(value * 1000)
  1540. self.ui.dial_b_left.blockSignals(False)
  1541. elif index == PARAMETER_BALANCE_RIGHT:
  1542. self.ui.dial_b_right.blockSignals(True)
  1543. self.ui.dial_b_right.setValue(value * 1000)
  1544. self.ui.dial_b_right.blockSignals(False)
  1545. elif index == PARAMETER_PANNING:
  1546. pass
  1547. #self.ui.dial_pan.blockSignals(True)
  1548. #self.ui.dial_pan.setValue(value * 1000, True, False)
  1549. #self.ui.dial_pan.blockSignals(False)
  1550. elif index == PARAMETER_CTRL_CHANNEL:
  1551. self.fControlChannel = int(value)
  1552. self.ui.sb_ctrl_channel.blockSignals(True)
  1553. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  1554. self.ui.sb_ctrl_channel.blockSignals(False)
  1555. self.ui.keyboard.allNotesOff()
  1556. elif index >= 0:
  1557. for paramType, paramId, paramWidget in self.fParameterList:
  1558. if paramId == index:
  1559. paramWidget.setValue(value, False)
  1560. if paramType == PARAMETER_INPUT:
  1561. tabIndex = paramWidget.tabIndex()
  1562. if self.fTabIconTimers[tabIndex-1] == ICON_STATE_NULL:
  1563. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOn)
  1564. self.fTabIconTimers[tabIndex-1] = ICON_STATE_ON
  1565. break
  1566. # Clear all parameters
  1567. self.fParametersToUpdate = []
  1568. # Update parameter outputs
  1569. for paramType, paramId, paramWidget in self.fParameterList:
  1570. if paramType == PARAMETER_OUTPUT:
  1571. value = Carla.host.get_current_parameter_value(self.fPluginId, paramId)
  1572. paramWidget.setValue(value, False)
  1573. @pyqtSlot()
  1574. def slot_saveState(self):
  1575. if self.fCurrentStateFilename:
  1576. askTry = QMessageBox.question(self, self.tr("Overwrite?"), self.tr("Overwrite previously created file?"), QMessageBox.Ok|QMessageBox.Cancel)
  1577. if askTry == QMessageBox.Ok:
  1578. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1579. self.fCurrentStateFilename = None
  1580. fileFilter = self.tr("Carla State File (*.carxs)")
  1581. filenameTry = QFileDialog.getSaveFileName(self, self.tr("Save Plugin State File"), filter=fileFilter)
  1582. if filenameTry:
  1583. if not filenameTry.endswith(".carxs"):
  1584. filenameTry += ".carxs"
  1585. self.fCurrentStateFilename = filenameTry
  1586. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1587. @pyqtSlot()
  1588. def slot_loadState(self):
  1589. fileFilter = self.tr("Carla State File (*.carxs)")
  1590. filenameTry = QFileDialog.getOpenFileName(self, self.tr("Open Plugin State File"), filter=fileFilter)
  1591. if filenameTry:
  1592. self.fCurrentStateFilename = filenameTry
  1593. Carla.host.load_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1594. @pyqtSlot(bool)
  1595. def slot_optionChanged(self, clicked):
  1596. sender = self.sender()
  1597. if sender == self.ui.ch_fixed_buffer:
  1598. option = PLUGIN_OPTION_FIXED_BUFFER
  1599. elif sender == self.ui.ch_force_stereo:
  1600. option = PLUGIN_OPTION_FORCE_STEREO
  1601. elif sender == self.ui.ch_map_program_changes:
  1602. option = PLUGIN_OPTION_MAP_PROGRAM_CHANGES
  1603. elif sender == self.ui.ch_use_chunks:
  1604. option = PLUGIN_OPTION_USE_CHUNKS
  1605. elif sender == self.ui.ch_send_control_changes:
  1606. option = PLUGIN_OPTION_SEND_CONTROL_CHANGES
  1607. elif sender == self.ui.ch_send_channel_pressure:
  1608. option = PLUGIN_OPTION_SEND_CHANNEL_PRESSURE
  1609. elif sender == self.ui.ch_send_note_aftertouch:
  1610. option = PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH
  1611. elif sender == self.ui.ch_send_pitchbend:
  1612. option = PLUGIN_OPTION_SEND_PITCHBEND
  1613. elif sender == self.ui.ch_send_all_sound_off:
  1614. option = PLUGIN_OPTION_SEND_ALL_SOUND_OFF
  1615. else:
  1616. return
  1617. Carla.host.set_option(self.fPluginId, option, clicked)
  1618. @pyqtSlot(int)
  1619. def slot_dryWetChanged(self, value):
  1620. Carla.host.set_drywet(self.fPluginId, float(value)/1000)
  1621. @pyqtSlot(int)
  1622. def slot_volumeChanged(self, value):
  1623. Carla.host.set_volume(self.fPluginId, float(value)/1000)
  1624. @pyqtSlot(int)
  1625. def slot_balanceLeftChanged(self, value):
  1626. Carla.host.set_balance_left(self.fPluginId, float(value)/1000)
  1627. @pyqtSlot(int)
  1628. def slot_balanceRightChanged(self, value):
  1629. Carla.host.set_balance_right(self.fPluginId, float(value)/1000)
  1630. @pyqtSlot(int)
  1631. def slot_panningChanged(self, value):
  1632. Carla.host.set_panning(self.fPluginId, float(value)/1000)
  1633. @pyqtSlot(int)
  1634. def slot_ctrlChannelChanged(self, value):
  1635. self.fControlChannel = value-1
  1636. Carla.host.set_ctrl_channel(self.fPluginId, self.fControlChannel)
  1637. self.ui.keyboard.allNotesOff()
  1638. @pyqtSlot(int, float)
  1639. def slot_parameterValueChanged(self, parameterId, value):
  1640. Carla.host.set_parameter_value(self.fPluginId, parameterId, value)
  1641. @pyqtSlot(int, int)
  1642. def slot_parameterMidiControlChanged(self, parameterId, control):
  1643. Carla.host.set_parameter_midi_cc(self.fPluginId, parameterId, control)
  1644. @pyqtSlot(int, int)
  1645. def slot_parameterMidiChannelChanged(self, parameterId, channel):
  1646. Carla.host.set_parameter_midi_channel(self.fPluginId, parameterId, channel-1)
  1647. @pyqtSlot(int)
  1648. def slot_programIndexChanged(self, index):
  1649. if self.fCurrentProgram != index:
  1650. self.fCurrentProgram = index
  1651. Carla.host.set_program(self.fPluginId, index)
  1652. @pyqtSlot(int)
  1653. def slot_midiProgramIndexChanged(self, index):
  1654. if self.fCurrentMidiProgram != index:
  1655. self.fCurrentMidiProgram = index
  1656. Carla.host.set_midi_program(self.fPluginId, index)
  1657. @pyqtSlot(int)
  1658. def slot_noteOn(self, note):
  1659. if self.fControlChannel >= 0:
  1660. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 100)
  1661. @pyqtSlot(int)
  1662. def slot_noteOff(self, note):
  1663. if self.fControlChannel >= 0:
  1664. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 0)
  1665. @pyqtSlot()
  1666. def slot_notesOn(self):
  1667. if self.fRealParent:
  1668. self.fRealParent.ui.led_midi.setChecked(True)
  1669. @pyqtSlot()
  1670. def slot_notesOff(self):
  1671. if self.fRealParent:
  1672. self.fRealParent.ui.led_midi.setChecked(False)
  1673. @pyqtSlot()
  1674. def slot_finished(self):
  1675. if self.fRealParent:
  1676. self.fRealParent.editClosed()
  1677. def _createParameterWidgets(self, paramType, paramListFull, tabPageName):
  1678. i = 1
  1679. for paramList, width in paramListFull:
  1680. if len(paramList) == 0:
  1681. break
  1682. tabIndex = self.ui.tabWidget.count()
  1683. tabPageContainer = QWidget(self.ui.tabWidget)
  1684. tabPageLayout = QVBoxLayout(tabPageContainer)
  1685. tabPageContainer.setLayout(tabPageLayout)
  1686. for paramInfo in paramList:
  1687. paramWidget = PluginParameter(tabPageContainer, paramInfo, self.fPluginId, tabIndex)
  1688. paramWidget.setLabelWidth(width)
  1689. tabPageLayout.addWidget(paramWidget)
  1690. self.fParameterList.append((paramType, paramInfo['index'], paramWidget))
  1691. if paramType == PARAMETER_INPUT:
  1692. self.connect(paramWidget, SIGNAL("valueChanged(int, double)"), SLOT("slot_parameterValueChanged(int, double)"))
  1693. self.connect(paramWidget, SIGNAL("midiControlChanged(int, int)"), SLOT("slot_parameterMidiControlChanged(int, int)"))
  1694. self.connect(paramWidget, SIGNAL("midiChannelChanged(int, int)"), SLOT("slot_parameterMidiChannelChanged(int, int)"))
  1695. tabPageLayout.addStretch()
  1696. self.ui.tabWidget.addTab(tabPageContainer, "%s (%i)" % (tabPageName, i))
  1697. i += 1
  1698. if paramType == PARAMETER_INPUT:
  1699. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOff)
  1700. self.fTabIconTimers.append(ICON_STATE_NULL)
  1701. def done(self, r):
  1702. QDialog.done(self, r)
  1703. self.close()
  1704. # ------------------------------------------------------------------------------------------------------------
  1705. # Plugin Widget
  1706. class PluginWidget(QFrame):
  1707. def __init__(self, parent, pluginId):
  1708. QFrame.__init__(self, parent)
  1709. self.ui = ui_carla_plugin.Ui_PluginWidget()
  1710. self.ui.setupUi(self)
  1711. self.fLastGreenLedState = False
  1712. self.fLastBlueLedState = False
  1713. self.fParameterIconTimer = ICON_STATE_NULL
  1714. self.fPluginId = pluginId
  1715. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId)
  1716. self.fPluginInfo["binary"] = cString(self.fPluginInfo["binary"])
  1717. self.fPluginInfo["name"] = cString(self.fPluginInfo["name"])
  1718. self.fPluginInfo["label"] = cString(self.fPluginInfo["label"])
  1719. self.fPluginInfo["maker"] = cString(self.fPluginInfo["maker"])
  1720. self.fPluginInfo["copyright"] = cString(self.fPluginInfo["copyright"])
  1721. if Carla.processMode == PROCESS_MODE_CONTINUOUS_RACK:
  1722. self.fPeaksInputCount = 2
  1723. self.fPeaksOutputCount = 2
  1724. else:
  1725. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  1726. self.fPeaksInputCount = int(audioCountInfo['ins'])
  1727. self.fPeaksOutputCount = int(audioCountInfo['outs'])
  1728. if self.fPeaksInputCount > 2:
  1729. self.fPeaksInputCount = 2
  1730. if self.fPeaksOutputCount > 2:
  1731. self.fPeaksOutputCount = 2
  1732. # Background
  1733. self.fColorTop = QColor(60, 60, 60)
  1734. self.fColorBottom = QColor(47, 47, 47)
  1735. # Colorify
  1736. #if self.m_pluginInfo['category'] == PLUGIN_CATEGORY_SYNTH:
  1737. #self.setWidgetColor(PALETTE_COLOR_WHITE)
  1738. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  1739. #self.setWidgetColor(PALETTE_COLOR_ORANGE)
  1740. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_EQ:
  1741. #self.setWidgetColor(PALETTE_COLOR_GREEN)
  1742. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  1743. #self.setWidgetColor(PALETTE_COLOR_BLUE)
  1744. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_DYNAMICS:
  1745. #self.setWidgetColor(PALETTE_COLOR_PINK)
  1746. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_MODULATOR:
  1747. #self.setWidgetColor(PALETTE_COLOR_RED)
  1748. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_UTILITY:
  1749. #self.setWidgetColor(PALETTE_COLOR_YELLOW)
  1750. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_OTHER:
  1751. #self.setWidgetColor(PALETTE_COLOR_BROWN)
  1752. #else:
  1753. #self.setWidgetColor(PALETTE_COLOR_NONE)
  1754. self.ui.b_enable.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  1755. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  1756. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  1757. self.ui.b_up.setPixmaps(":/bitmaps/button_up.png", ":/bitmaps/button_up.png", ":/bitmaps/button_up_hover.png")
  1758. self.ui.b_down.setPixmaps(":/bitmaps/button_down.png", ":/bitmaps/button_down.png", ":/bitmaps/button_down_hover.png")
  1759. self.ui.b_restore.setPixmaps(":/bitmaps/button_restore.png", ":/bitmaps/button_restore.png", ":/bitmaps/button_restore_hover.png")
  1760. self.ui.b_close.setPixmaps(":/bitmaps/button_close.png", ":/bitmaps/button_close_down.png", ":/bitmaps/button_close_hover.png")
  1761. # TODO
  1762. self.ui.b_up.setEnabled(False)
  1763. self.ui.b_down.setEnabled(False)
  1764. self.ui.b_restore.setEnabled(False)
  1765. self.ui.led_control.setColor(self.ui.led_control.YELLOW)
  1766. self.ui.led_control.setEnabled(False)
  1767. self.ui.led_midi.setColor(self.ui.led_midi.RED)
  1768. self.ui.led_midi.setEnabled(False)
  1769. self.ui.led_audio_in.setColor(self.ui.led_audio_in.GREEN)
  1770. self.ui.led_audio_in.setEnabled(False)
  1771. self.ui.led_audio_out.setColor(self.ui.led_audio_out.BLUE)
  1772. self.ui.led_audio_out.setEnabled(False)
  1773. self.ui.peak_in.setColor(self.ui.peak_in.GREEN)
  1774. self.ui.peak_in.setOrientation(self.ui.peak_in.HORIZONTAL)
  1775. self.ui.peak_out.setColor(self.ui.peak_in.BLUE)
  1776. self.ui.peak_out.setOrientation(self.ui.peak_out.HORIZONTAL)
  1777. self.ui.peak_in.setChannels(self.fPeaksInputCount)
  1778. self.ui.peak_out.setChannels(self.fPeaksOutputCount)
  1779. self.ui.label_name.setText(self.fPluginInfo['name'])
  1780. self.ui.edit_dialog = PluginEdit(self, self.fPluginId)
  1781. self.ui.edit_dialog.hide()
  1782. self.connect(self.ui.b_enable, SIGNAL("clicked(bool)"), SLOT("slot_setActive(bool)"))
  1783. self.connect(self.ui.b_gui, SIGNAL("clicked(bool)"), SLOT("slot_guiClicked(bool)"))
  1784. self.connect(self.ui.b_edit, SIGNAL("clicked(bool)"), SLOT("slot_editClicked(bool)"))
  1785. self.connect(self.ui.b_up, SIGNAL("clicked()"), SLOT("slot_upClicked()"))
  1786. self.connect(self.ui.b_down, SIGNAL("clicked()"), SLOT("slot_downClicked()"))
  1787. self.connect(self.ui.b_restore, SIGNAL("clicked()"), SLOT("slot_restoreClicked()"))
  1788. self.connect(self.ui.b_close, SIGNAL("clicked()"), SLOT("slot_closeClicked()"))
  1789. # FIXME
  1790. #self.setMaximumHeight(32)
  1791. def idleFast(self):
  1792. # Input peaks
  1793. if self.fPeaksInputCount > 0:
  1794. if self.fPeaksInputCount > 1:
  1795. peak1 = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1796. peak2 = Carla.host.get_input_peak_value(self.fPluginId, 2)
  1797. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1798. self.ui.peak_in.displayMeter(1, peak1)
  1799. self.ui.peak_in.displayMeter(2, peak2)
  1800. else:
  1801. peak = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1802. ledState = bool(peak != 0.0)
  1803. self.ui.peak_in.displayMeter(1, peak)
  1804. if self.fLastGreenLedState != ledState:
  1805. self.fLastGreenLedState = ledState
  1806. self.ui.led_audio_in.setChecked(ledState)
  1807. # Output peaks
  1808. if self.fPeaksOutputCount > 0:
  1809. if self.fPeaksOutputCount > 1:
  1810. peak1 = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1811. peak2 = Carla.host.get_output_peak_value(self.fPluginId, 2)
  1812. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1813. self.ui.peak_out.displayMeter(1, peak1)
  1814. self.ui.peak_out.displayMeter(2, peak2)
  1815. else:
  1816. peak = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1817. ledState = bool(peak != 0.0)
  1818. self.ui.peak_out.displayMeter(1, peak)
  1819. if self.fLastBlueLedState != ledState:
  1820. self.fLastBlueLedState = ledState
  1821. self.ui.led_audio_out.setChecked(ledState)
  1822. def idleSlow(self):
  1823. # Parameter Activity LED
  1824. if self.fParameterIconTimer == ICON_STATE_ON:
  1825. self.fParameterIconTimer = ICON_STATE_WAIT
  1826. self.ui.led_control.setChecked(True)
  1827. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  1828. self.fParameterIconTimer = ICON_STATE_OFF
  1829. elif self.fParameterIconTimer == ICON_STATE_OFF:
  1830. self.fParameterIconTimer = ICON_STATE_NULL
  1831. self.ui.led_control.setChecked(False)
  1832. # Update edit dialog
  1833. self.ui.edit_dialog.idleSlow()
  1834. def editClosed(self):
  1835. self.ui.b_edit.setChecked(False)
  1836. def recheckPluginHints(self, hints):
  1837. self.fPluginInfo['hints'] = hints
  1838. self.ui.b_gui.setEnabled(hints & PLUGIN_HAS_GUI)
  1839. def setActive(self, active, sendGui=False, sendCallback=True):
  1840. if sendGui: self.ui.b_enable.setChecked(active)
  1841. if sendCallback: Carla.host.set_active(self.fPluginId, active)
  1842. if active:
  1843. self.ui.edit_dialog.ui.keyboard.allNotesOff()
  1844. def setParameterDefault(self, parameterId, value):
  1845. self.ui.edit_dialog.setParameterDefault(parameterId, value)
  1846. def setParameterValue(self, parameterId, value):
  1847. self.fParameterIconTimer = ICON_STATE_ON
  1848. if parameterId == PARAMETER_ACTIVE:
  1849. return self.setActive(bool(value), True, False)
  1850. self.ui.edit_dialog.setParameterValue(parameterId, value)
  1851. def setParameterMidiControl(self, parameterId, control):
  1852. self.ui.edit_dialog.setParameterMidiControl(parameterId, control)
  1853. def setParameterMidiChannel(self, parameterId, channel):
  1854. self.ui.edit_dialog.setParameterMidiChannel(parameterId, channel)
  1855. def setProgram(self, index):
  1856. self.fParameterIconTimer = ICON_STATE_ON
  1857. self.ui.edit_dialog.setProgram(index)
  1858. def setMidiProgram(self, index):
  1859. self.fParameterIconTimer = ICON_STATE_ON
  1860. self.ui.edit_dialog.setMidiProgram(index)
  1861. def sendNoteOn(self, channel, note):
  1862. self.ui.edit_dialog.sendNoteOn(channel, note)
  1863. def sendNoteOff(self, channel, note):
  1864. self.ui.edit_dialog.sendNoteOff(channel, note)
  1865. def setId(self, idx):
  1866. self.fPluginId = idx
  1867. self.ui.edit_dialog.fPluginId = idx
  1868. def setRefreshRate(self, rate):
  1869. self.ui.peak_in.setRefreshRate(rate)
  1870. self.ui.peak_out.setRefreshRate(rate)
  1871. def paintEvent(self, event):
  1872. painter = QPainter(self)
  1873. areaX = self.ui.led_control.x()
  1874. # bottom line
  1875. painter.setPen(self.fColorBottom)
  1876. painter.setBrush(self.fColorBottom)
  1877. painter.drawRect(0, self.height()-5, areaX, 5)
  1878. # top line
  1879. painter.drawLine(0, 0, areaX+40, 0)
  1880. # name -> leds arc
  1881. path = QPainterPath()
  1882. path.moveTo(areaX-80, self.height())
  1883. path.cubicTo(areaX+40, self.height()-5, areaX-40, 30, areaX+20, 0)
  1884. path.lineTo(areaX+20, self.height())
  1885. painter.drawPath(path)
  1886. # fill the rest
  1887. painter.drawRect(areaX+20, 0, self.width(), self.height())
  1888. #painter.drawLine(0, 3, self.width(), 3)
  1889. #painter.drawLine(0, self.height() - 4, self.width(), self.height() - 4)
  1890. #painter.setPen(self.m_color2)
  1891. #painter.drawLine(0, 2, self.width(), 2)
  1892. #painter.drawLine(0, self.height() - 3, self.width(), self.height() - 3)
  1893. #painter.setPen(self.m_color3)
  1894. #painter.drawLine(0, 1, self.width(), 1)
  1895. #painter.drawLine(0, self.height() - 2, self.width(), self.height() - 2)
  1896. #painter.setPen(self.m_color4)
  1897. #painter.drawLine(0, 0, self.width(), 0)
  1898. #painter.drawLine(0, self.height() - 1, self.width(), self.height() - 1)
  1899. QFrame.paintEvent(self, event)
  1900. @pyqtSlot(bool)
  1901. def slot_setActive(self, yesNo):
  1902. self.setActive(yesNo, False, True)
  1903. @pyqtSlot(bool)
  1904. def slot_guiClicked(self, show):
  1905. Carla.host.show_gui(self.fPluginId, show)
  1906. @pyqtSlot(bool)
  1907. def slot_editClicked(self, show):
  1908. self.ui.edit_dialog.setVisible(show)
  1909. @pyqtSlot()
  1910. def slot_upClicked(self):
  1911. pass
  1912. @pyqtSlot()
  1913. def slot_downClicked(self):
  1914. pass
  1915. @pyqtSlot()
  1916. def slot_restoreClicked(self):
  1917. pass
  1918. @pyqtSlot()
  1919. def slot_closeClicked(self):
  1920. Carla.host.remove_plugin(self.fPluginId)
  1921. # ------------------------------------------------------------------------------------------------------------
  1922. # Separate Thread for Plugin Search
  1923. class SearchPluginsThread(QThread):
  1924. def __init__(self, parent):
  1925. QThread.__init__(self, parent)
  1926. self.fCheckNative = False
  1927. self.fCheckPosix32 = False
  1928. self.fCheckPosix64 = False
  1929. self.fCheckWin32 = False
  1930. self.fCheckWin64 = False
  1931. self.fCheckLADSPA = False
  1932. self.fCheckDSSI = False
  1933. self.fCheckLV2 = False
  1934. self.fCheckVST = False
  1935. self.fCheckGIG = False
  1936. self.fCheckSF2 = False
  1937. self.fCheckSFZ = False
  1938. self.fToolNative = carla_discovery_native
  1939. self.fCurCount = 0
  1940. self.fCurPercentValue = 0
  1941. self.fLastCheckValue = 0
  1942. self.fSomethingChanged = False
  1943. def somethingChanged(self):
  1944. return self.fSomethingChanged
  1945. def skipPlugin(self):
  1946. # TODO - windows and mac support
  1947. apps = " carla-discovery"
  1948. apps += " carla-discovery-native"
  1949. apps += " carla-discovery-posix32"
  1950. apps += " carla-discovery-posix64"
  1951. apps += " carla-discovery-win32.exe"
  1952. apps += " carla-discovery-win64.exe"
  1953. if LINUX:
  1954. os.system("killall -KILL %s" % apps)
  1955. def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64):
  1956. self.fCheckNative = native
  1957. self.fCheckPosix32 = posix32
  1958. self.fCheckPosix64 = posix64
  1959. self.fCheckWin32 = win32
  1960. self.fCheckWin64 = win64
  1961. def setSearchPluginTypes(self, ladspa, dssi, lv2, vst, gig, sf2, sfz):
  1962. self.fCheckLADSPA = ladspa
  1963. self.fCheckDSSI = dssi
  1964. self.fCheckLV2 = lv2
  1965. self.fCheckVST = vst
  1966. self.fCheckGIG = gig
  1967. self.fCheckSF2 = sf2
  1968. self.fCheckSFZ = sfz
  1969. def setSearchToolNative(self, tool):
  1970. self.fToolNative = tool
  1971. def run(self):
  1972. self.fCurCount = 0
  1973. pluginCount = 0
  1974. settingsDB = QSettings("falkTX", "CarlaPlugins")
  1975. if self.fCheckLADSPA: pluginCount += 1
  1976. if self.fCheckDSSI: pluginCount += 1
  1977. if self.fCheckLV2: pluginCount += 1
  1978. if self.fCheckVST: pluginCount += 1
  1979. if self.fCheckNative:
  1980. self.fCurCount += pluginCount
  1981. if self.fCheckPosix32:
  1982. self.fCurCount += pluginCount
  1983. if self.fCheckPosix64:
  1984. self.fCurCount += pluginCount
  1985. if self.fCheckWin32:
  1986. self.fCurCount += pluginCount
  1987. if self.fCheckWin64:
  1988. self.fCurCount += pluginCount
  1989. if self.fToolNative:
  1990. if self.fCheckGIG: self.fCurCount += 1
  1991. if self.fCheckSF2: self.fCurCount += 1
  1992. if self.fCheckSFZ: self.fCurCount += 1
  1993. else:
  1994. self.fCheckGIG = False
  1995. self.fCheckSF2 = False
  1996. self.fCheckSFZ = False
  1997. if self.fCurCount == 0:
  1998. return
  1999. self.fCurPercentValue = 100 / self.fCurCount
  2000. self.fLastCheckValue = 0
  2001. if HAIKU:
  2002. OS = "HAIKU"
  2003. elif LINUX:
  2004. OS = "LINUX"
  2005. elif MACOS:
  2006. OS = "MACOS"
  2007. elif WINDOWS:
  2008. OS = "WINDOWS"
  2009. else:
  2010. OS = "UNKNOWN"
  2011. if self.fCheckLADSPA:
  2012. checkValue = 0
  2013. if haveLRDF:
  2014. if self.fCheckNative: checkValue += 0.1
  2015. if self.fCheckPosix32: checkValue += 0.1
  2016. if self.fCheckPosix64: checkValue += 0.1
  2017. if self.fCheckWin32: checkValue += 0.1
  2018. if self.fCheckWin64: checkValue += 0.1
  2019. rdfPadValue = self.fCurPercentValue * checkValue
  2020. if self.fCheckNative:
  2021. self._checkLADSPA(OS, carla_discovery_native)
  2022. settingsDB.setValue("Plugins/LADSPA_native", self.fLadspaPlugins)
  2023. settingsDB.sync()
  2024. if self.fCheckPosix32:
  2025. self._checkLADSPA(OS, carla_discovery_posix32)
  2026. settingsDB.setValue("Plugins/LADSPA_posix32", self.fLadspaPlugins)
  2027. settingsDB.sync()
  2028. if self.fCheckPosix64:
  2029. self._checkLADSPA(OS, carla_discovery_posix64)
  2030. settingsDB.setValue("Plugins/LADSPA_posix64", self.fLadspaPlugins)
  2031. settingsDB.sync()
  2032. if self.fCheckWin32:
  2033. self._checkLADSPA("WINDOWS", carla_discovery_win32, not WINDOWS)
  2034. settingsDB.setValue("Plugins/LADSPA_win32", self.fLadspaPlugins)
  2035. settingsDB.sync()
  2036. if self.fCheckWin64:
  2037. self._checkLADSPA("WINDOWS", carla_discovery_win64, not WINDOWS)
  2038. settingsDB.setValue("Plugins/LADSPA_win64", self.fLadspaPlugins)
  2039. settingsDB.sync()
  2040. if haveLRDF and checkValue > 0:
  2041. startValue = self.fLastCheckValue - rdfPadValue
  2042. self._pluginLook(startValue, "LADSPA RDFs...")
  2043. ladspaRdfInfo = ladspa_rdf.recheck_all_plugins(self, startValue, self.fCurPercentValue, checkValue)
  2044. SettingsDir = os.path.join(HOME, ".config", "falkTX")
  2045. fLadspa = open(os.path.join(SettingsDir, "ladspa_rdf.db"), 'w')
  2046. json.dump(ladspaRdfInfo, fLadspa)
  2047. fLadspa.close()
  2048. if self.fCheckDSSI:
  2049. if self.fCheckNative:
  2050. self._checkDSSI(OS, carla_discovery_native)
  2051. settingsDB.setValue("Plugins/DSSI_native", self.fDssiPlugins)
  2052. settingsDB.sync()
  2053. if self.fCheckPosix32:
  2054. self._checkDSSI(OS, carla_discovery_posix32)
  2055. settingsDB.setValue("Plugins/DSSI_posix32", self.fDssiPlugins)
  2056. settingsDB.sync()
  2057. if self.fCheckPosix64:
  2058. self._checkDSSI(OS, carla_discovery_posix64)
  2059. settingsDB.setValue("Plugins/DSSI_posix64", self.fDssiPlugins)
  2060. settingsDB.sync()
  2061. if self.fCheckWin32:
  2062. self._checkDSSI("WINDOWS", carla_discovery_win32, not WINDOWS)
  2063. settingsDB.setValue("Plugins/DSSI_win32", self.fDssiPlugins)
  2064. settingsDB.sync()
  2065. if self.fCheckWin64:
  2066. self._checkDSSI("WINDOWS", carla_discovery_win64, not WINDOWS)
  2067. settingsDB.setValue("Plugins/DSSI_win64", self.fDssiPlugins)
  2068. settingsDB.sync()
  2069. if self.fCheckLV2:
  2070. if self.fCheckNative:
  2071. self._checkLV2(carla_discovery_native)
  2072. settingsDB.setValue("Plugins/LV2_native", self.fLv2Plugins)
  2073. settingsDB.sync()
  2074. if self.fCheckPosix32:
  2075. self._checkLV2(carla_discovery_posix32)
  2076. settingsDB.setValue("Plugins/LV2_posix32", self.fLv2Plugins)
  2077. settingsDB.sync()
  2078. if self.fCheckPosix64:
  2079. self._checkLV2(carla_discovery_posix64)
  2080. settingsDB.setValue("Plugins/LV2_posix64", self.fLv2Plugins)
  2081. settingsDB.sync()
  2082. if self.fCheckWin32:
  2083. self._checkLV2(carla_discovery_win32, not WINDOWS)
  2084. settingsDB.setValue("Plugins/LV2_win32", self.fLv2Plugins)
  2085. settingsDB.sync()
  2086. if self.fCheckWin64:
  2087. self._checkLV2(carla_discovery_win64, not WINDOWS)
  2088. settingsDB.setValue("Plugins/LV2_win64", self.fLv2Plugins)
  2089. settingsDB.sync()
  2090. if self.fCheckVST:
  2091. if self.fCheckNative:
  2092. self._checkVST(OS, carla_discovery_native)
  2093. settingsDB.setValue("Plugins/VST_native", self.fVstPlugins)
  2094. settingsDB.sync()
  2095. if self.fCheckPosix32:
  2096. self._checkVST(OS, carla_discovery_posix32)
  2097. settingsDB.setValue("Plugins/VST_posix32", self.fVstPlugins)
  2098. settingsDB.sync()
  2099. if self.fCheckPosix64:
  2100. self._checkVST(OS, carla_discovery_posix64)
  2101. settingsDB.setValue("Plugins/VST_posix64", self.fVstPlugins)
  2102. settingsDB.sync()
  2103. if self.fCheckWin32:
  2104. self._checkVST("WINDOWS", carla_discovery_win32, not WINDOWS)
  2105. settingsDB.setValue("Plugins/VST_win32", self.fVstPlugins)
  2106. settingsDB.sync()
  2107. if self.fCheckWin64:
  2108. self._checkVST("WINDOWS", carla_discovery_win64, not WINDOWS)
  2109. settingsDB.setValue("Plugins/VST_win64", self.fVstPlugins)
  2110. settingsDB.sync()
  2111. if self.fCheckGIG:
  2112. self._checkKIT(Carla.GIG_PATH, "gig")
  2113. settingsDB.setValue("Plugins/GIG", self.fKitPlugins)
  2114. settingsDB.sync()
  2115. if self.fCheckSF2:
  2116. self._checkKIT(Carla.SF2_PATH, "sf2")
  2117. settingsDB.setValue("Plugins/SF2", self.fKitPlugins)
  2118. settingsDB.sync()
  2119. if self.fCheckSFZ:
  2120. self._checkKIT(Carla.SFZ_PATH, "sfz")
  2121. settingsDB.setValue("Plugins/SFZ", self.fKitPlugins)
  2122. settingsDB.sync()
  2123. def _checkLADSPA(self, OS, tool, isWine=False):
  2124. ladspaBinaries = []
  2125. self.fLadspaPlugins = []
  2126. for iPATH in Carla.LADSPA_PATH:
  2127. binaries = findBinaries(iPATH, OS)
  2128. for binary in binaries:
  2129. if binary not in ladspaBinaries:
  2130. ladspaBinaries.append(binary)
  2131. ladspaBinaries.sort()
  2132. for i in range(len(ladspaBinaries)):
  2133. ladspa = ladspaBinaries[i]
  2134. percent = ( float(i) / len(ladspaBinaries) ) * self.fCurPercentValue
  2135. self._pluginLook((self.fLastCheckValue + percent) * 0.9, ladspa)
  2136. plugins = checkPluginLADSPA(ladspa, tool, isWine)
  2137. if plugins:
  2138. self.fLadspaPlugins.append(plugins)
  2139. self.fSomethingChanged = True
  2140. self.fLastCheckValue += self.fCurPercentValue
  2141. def _checkDSSI(self, OS, tool, isWine=False):
  2142. dssiBinaries = []
  2143. self.fDssiPlugins = []
  2144. for iPATH in Carla.DSSI_PATH:
  2145. binaries = findBinaries(iPATH, OS)
  2146. for binary in binaries:
  2147. if binary not in dssiBinaries:
  2148. dssiBinaries.append(binary)
  2149. dssiBinaries.sort()
  2150. for i in range(len(dssiBinaries)):
  2151. dssi = dssiBinaries[i]
  2152. percent = ( float(i) / len(dssiBinaries) ) * self.fCurPercentValue
  2153. self._pluginLook(self.fLastCheckValue + percent, dssi)
  2154. plugins = checkPluginDSSI(dssi, tool, isWine)
  2155. if plugins:
  2156. self.fDssiPlugins.append(plugins)
  2157. self.fSomethingChanged = True
  2158. self.fLastCheckValue += self.fCurPercentValue
  2159. def _checkLV2(self, tool, isWine=False):
  2160. lv2Bundles = []
  2161. self.fLv2Plugins = []
  2162. self._pluginLook(self.fLastCheckValue, "LV2 bundles...")
  2163. for iPATH in Carla.LV2_PATH:
  2164. bundles = findLV2Bundles(iPATH)
  2165. for bundle in bundles:
  2166. if bundle not in lv2Bundles:
  2167. lv2Bundles.append(bundle)
  2168. lv2Bundles.sort()
  2169. for i in range(len(lv2Bundles)):
  2170. lv2 = lv2Bundles[i]
  2171. percent = ( float(i) / len(lv2Bundles) ) * self.fCurPercentValue
  2172. self._pluginLook(self.fLastCheckValue + percent, lv2)
  2173. plugins = checkPluginLV2(lv2, tool, isWine)
  2174. if plugins:
  2175. self.fLv2Plugins.append(plugins)
  2176. self.fSomethingChanged = True
  2177. self.fLastCheckValue += self.fCurPercentValue
  2178. def _checkVST(self, OS, tool, isWine=False):
  2179. vstBinaries = []
  2180. self.fVstPlugins = []
  2181. for iPATH in Carla.VST_PATH:
  2182. binaries = findBinaries(iPATH, OS)
  2183. for binary in binaries:
  2184. if binary not in vstBinaries:
  2185. vstBinaries.append(binary)
  2186. vstBinaries.sort()
  2187. for i in range(len(vstBinaries)):
  2188. vst = vstBinaries[i]
  2189. percent = ( float(i) / len(vstBinaries) ) * self.fCurPercentValue
  2190. self._pluginLook(self.fLastCheckValue + percent, vst)
  2191. plugins = checkPluginVST(vst, tool, isWine)
  2192. if plugins:
  2193. self.fVstPlugins.append(plugins)
  2194. self.fSomethingChanged = True
  2195. self.fLastCheckValue += self.fCurPercentValue
  2196. def _checkKIT(self, kPATH, kType):
  2197. kitFiles = []
  2198. self.fKitPlugins = []
  2199. for iPATH in kPATH:
  2200. files = findSoundKits(iPATH, kType)
  2201. for file_ in files:
  2202. if file_ not in kitFiles:
  2203. kitFiles.append(file_)
  2204. kitFiles.sort()
  2205. for i in range(len(kitFiles)):
  2206. kit = kitFiles[i]
  2207. percent = ( float(i) / len(kitFiles) ) * self.fCurPercentValue
  2208. self._pluginLook(self.fLastCheckValue + percent, kit)
  2209. if kType == "gig":
  2210. plugins = checkPluginGIG(kit, self.fToolNative)
  2211. elif kType == "sf2":
  2212. plugins = checkPluginSF2(kit, self.fToolNative)
  2213. elif kType == "sfz":
  2214. plugins = checkPluginSFZ(kit, self.fToolNative)
  2215. else:
  2216. plugins = None
  2217. if plugins:
  2218. self.fKitPlugins.append(plugins)
  2219. self.fSomethingChanged = True
  2220. self.fLastCheckValue += self.fCurPercentValue
  2221. def _pluginLook(self, percent, plugin):
  2222. self.emit(SIGNAL("PluginLook(int, QString)"), percent, plugin)
  2223. # ------------------------------------------------------------------------------------------------------------
  2224. # Plugin Refresh Dialog
  2225. class PluginRefreshW(QDialog):
  2226. def __init__(self, parent):
  2227. QDialog.__init__(self, parent)
  2228. self.ui = ui_carla_refresh.Ui_PluginRefreshW()
  2229. self.ui.setupUi(self)
  2230. self._loadSettings()
  2231. self.ui.b_skip.setVisible(False)
  2232. if HAIKU:
  2233. self.ui.ch_posix32.setText("Haiku 32bit")
  2234. self.ui.ch_posix64.setText("Haiku 64bit")
  2235. elif LINUX:
  2236. self.ui.ch_posix32.setText("Linux 32bit")
  2237. self.ui.ch_posix64.setText("Linux 64bit")
  2238. elif MACOS:
  2239. self.ui.ch_posix32.setText("MacOS 32bit")
  2240. self.ui.ch_posix64.setText("MacOS 64bit")
  2241. self.fThread = SearchPluginsThread(self)
  2242. if carla_discovery_posix32 and not WINDOWS:
  2243. self.ui.ico_posix32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2244. else:
  2245. self.ui.ico_posix32.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2246. self.ui.ch_posix32.setChecked(False)
  2247. self.ui.ch_posix32.setEnabled(False)
  2248. if carla_discovery_posix64 and not WINDOWS:
  2249. self.ui.ico_posix64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2250. else:
  2251. self.ui.ico_posix64.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2252. self.ui.ch_posix64.setChecked(False)
  2253. self.ui.ch_posix64.setEnabled(False)
  2254. if carla_discovery_win32:
  2255. self.ui.ico_win32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2256. else:
  2257. self.ui.ico_win32.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2258. self.ui.ch_win32.setChecked(False)
  2259. self.ui.ch_win32.setEnabled(False)
  2260. if carla_discovery_win64:
  2261. self.ui.ico_win64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2262. else:
  2263. self.ui.ico_win64.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2264. self.ui.ch_win64.setChecked(False)
  2265. self.ui.ch_win64.setEnabled(False)
  2266. if haveLRDF:
  2267. self.ui.ico_rdflib.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2268. else:
  2269. self.ui.ico_rdflib.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2270. hasNative = bool(carla_discovery_native)
  2271. hasNonNative = False
  2272. if WINDOWS:
  2273. if kIs64bit:
  2274. hasNative = bool(carla_discovery_win64)
  2275. hasNonNative = bool(carla_discovery_win32)
  2276. self.fThread.setSearchToolNative(carla_discovery_win64)
  2277. self.ui.ch_win64.setChecked(False)
  2278. self.ui.ch_win64.setVisible(False)
  2279. self.ui.ico_win64.setVisible(False)
  2280. self.ui.label_win64.setVisible(False)
  2281. else:
  2282. hasNative = bool(carla_discovery_win32)
  2283. hasNonNative = bool(carla_discovery_win64)
  2284. self.fThread.setSearchToolNative(carla_discovery_win32)
  2285. self.ui.ch_win32.setChecked(False)
  2286. self.ui.ch_win32.setVisible(False)
  2287. self.ui.ico_win32.setVisible(False)
  2288. self.ui.label_win32.setVisible(False)
  2289. elif LINUX or MACOS:
  2290. if kIs64bit:
  2291. hasNonNative = bool(carla_discovery_posix32 or carla_discovery_win32 or carla_discovery_win64)
  2292. self.ui.ch_posix64.setChecked(False)
  2293. self.ui.ch_posix64.setVisible(False)
  2294. self.ui.ico_posix64.setVisible(False)
  2295. self.ui.label_posix64.setVisible(False)
  2296. else:
  2297. hasNonNative = bool(carla_discovery_posix64 or carla_discovery_win32 or carla_discovery_win64)
  2298. self.ui.ch_posix32.setChecked(False)
  2299. self.ui.ch_posix32.setVisible(False)
  2300. self.ui.ico_posix32.setVisible(False)
  2301. self.ui.label_posix32.setVisible(False)
  2302. if hasNative:
  2303. self.ui.ico_native.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2304. else:
  2305. self.ui.ico_native.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2306. self.ui.ch_native.setChecked(False)
  2307. self.ui.ch_native.setEnabled(False)
  2308. self.ui.ch_gig.setChecked(False)
  2309. self.ui.ch_gig.setEnabled(False)
  2310. self.ui.ch_sf2.setChecked(False)
  2311. self.ui.ch_sf2.setEnabled(False)
  2312. self.ui.ch_sfz.setChecked(False)
  2313. self.ui.ch_sfz.setEnabled(False)
  2314. if not hasNonNative:
  2315. self.ui.ch_ladspa.setChecked(False)
  2316. self.ui.ch_ladspa.setEnabled(False)
  2317. self.ui.ch_dssi.setChecked(False)
  2318. self.ui.ch_dssi.setEnabled(False)
  2319. self.ui.ch_lv2.setChecked(False)
  2320. self.ui.ch_lv2.setEnabled(False)
  2321. self.ui.ch_vst.setChecked(False)
  2322. self.ui.ch_vst.setEnabled(False)
  2323. self.ui.b_start.setEnabled(False)
  2324. self.connect(self.ui.b_start, SIGNAL("clicked()"), SLOT("slot_start()"))
  2325. self.connect(self.ui.b_skip, SIGNAL("clicked()"), SLOT("slot_skip()"))
  2326. self.connect(self.fThread, SIGNAL("PluginLook(int, QString)"), SLOT("slot_handlePluginLook(int, QString)"))
  2327. self.connect(self.fThread, SIGNAL("finished()"), SLOT("slot_handlePluginThreadFinished()"))
  2328. @pyqtSlot()
  2329. def slot_start(self):
  2330. self.ui.progressBar.setMinimum(0)
  2331. self.ui.progressBar.setMaximum(100)
  2332. self.ui.progressBar.setValue(0)
  2333. self.ui.b_start.setEnabled(False)
  2334. self.ui.b_skip.setVisible(True)
  2335. self.ui.b_close.setVisible(False)
  2336. native, posix32, posix64, win32, win64 = (self.ui.ch_native.isChecked(), self.ui.ch_posix32.isChecked(), self.ui.ch_posix64.isChecked(), self.ui.ch_win32.isChecked(), self.ui.ch_win64.isChecked())
  2337. ladspa, dssi, lv2, vst, gig, sf2, sfz = (self.ui.ch_ladspa.isChecked(), self.ui.ch_dssi.isChecked(), self.ui.ch_lv2.isChecked(), self.ui.ch_vst.isChecked(),
  2338. self.ui.ch_gig.isChecked(), self.ui.ch_sf2.isChecked(), self.ui.ch_sfz.isChecked())
  2339. self.fThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64)
  2340. self.fThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, gig, sf2, sfz)
  2341. self.fThread.start()
  2342. @pyqtSlot()
  2343. def slot_skip(self):
  2344. self.fThread.skipPlugin()
  2345. @pyqtSlot(int, str)
  2346. def slot_handlePluginLook(self, percent, plugin):
  2347. self.ui.progressBar.setFormat("%s" % plugin)
  2348. self.ui.progressBar.setValue(percent)
  2349. @pyqtSlot()
  2350. def slot_handlePluginThreadFinished(self):
  2351. self.ui.progressBar.setMinimum(0)
  2352. self.ui.progressBar.setMaximum(1)
  2353. self.ui.progressBar.setValue(1)
  2354. self.ui.progressBar.setFormat(self.tr("Done"))
  2355. self.ui.b_start.setEnabled(True)
  2356. self.ui.b_skip.setVisible(False)
  2357. self.ui.b_close.setVisible(True)
  2358. def _saveSettings(self):
  2359. settings = QSettings()
  2360. settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked())
  2361. settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked())
  2362. settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked())
  2363. settings.setValue("PluginDatabase/SearchVST", self.ui.ch_vst.isChecked())
  2364. settings.setValue("PluginDatabase/SearchGIG", self.ui.ch_gig.isChecked())
  2365. settings.setValue("PluginDatabase/SearchSF2", self.ui.ch_sf2.isChecked())
  2366. settings.setValue("PluginDatabase/SearchSFZ", self.ui.ch_sfz.isChecked())
  2367. settings.setValue("PluginDatabase/SearchNative", self.ui.ch_native.isChecked())
  2368. settings.setValue("PluginDatabase/SearchPOSIX32", self.ui.ch_posix32.isChecked())
  2369. settings.setValue("PluginDatabase/SearchPOSIX64", self.ui.ch_posix64.isChecked())
  2370. settings.setValue("PluginDatabase/SearchWin32", self.ui.ch_win32.isChecked())
  2371. settings.setValue("PluginDatabase/SearchWin64", self.ui.ch_win64.isChecked())
  2372. def _loadSettings(self):
  2373. settings = QSettings()
  2374. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/SearchLADSPA", True, type=bool))
  2375. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/SearchDSSI", True, type=bool))
  2376. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/SearchLV2", True, type=bool))
  2377. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/SearchVST", True, type=bool))
  2378. self.ui.ch_gig.setChecked(settings.value("PluginDatabase/SearchGIG", False, type=bool))
  2379. self.ui.ch_sf2.setChecked(settings.value("PluginDatabase/SearchSF2", False, type=bool))
  2380. self.ui.ch_sfz.setChecked(settings.value("PluginDatabase/SearchSFZ", False, type=bool))
  2381. self.ui.ch_native.setChecked(settings.value("PluginDatabase/SearchNative", True, type=bool))
  2382. self.ui.ch_posix32.setChecked(settings.value("PluginDatabase/SearchPOSIX32", False, type=bool))
  2383. self.ui.ch_posix64.setChecked(settings.value("PluginDatabase/SearchPOSIX64", False, type=bool))
  2384. self.ui.ch_win32.setChecked(settings.value("PluginDatabase/SearchWin32", False, type=bool))
  2385. self.ui.ch_win64.setChecked(settings.value("PluginDatabase/SearchWin64", False, type=bool))
  2386. def closeEvent(self, event):
  2387. if self.fThread.isRunning():
  2388. self.fThread.terminate()
  2389. self.fThread.wait()
  2390. self._saveSettings()
  2391. if self.fThread.somethingChanged():
  2392. self.accept()
  2393. else:
  2394. self.reject()
  2395. QDialog.closeEvent(self, event)
  2396. def done(self, r):
  2397. QDialog.done(self, r)
  2398. self.close()
  2399. # ------------------------------------------------------------------------------------------------------------
  2400. # Plugin Database Dialog
  2401. class PluginDatabaseW(QDialog):
  2402. def __init__(self, parent):
  2403. QDialog.__init__(self, parent)
  2404. self.ui = ui_carla_database.Ui_PluginDatabaseW()
  2405. self.ui.setupUi(self)
  2406. self.fLastTableIndex = 0
  2407. self.fRetPlugin = None
  2408. self.fRealParent = parent
  2409. self.ui.b_add.setEnabled(False)
  2410. if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32):
  2411. self.ui.ch_bridged.setText(self.tr("Bridged (64bit)"))
  2412. else:
  2413. self.ui.ch_bridged.setText(self.tr("Bridged (32bit)"))
  2414. if not (LINUX or MACOS):
  2415. self.ui.ch_bridged_wine.setChecked(False)
  2416. self.ui.ch_bridged_wine.setEnabled(False)
  2417. self._loadSettings()
  2418. self.connect(self.ui.b_add, SIGNAL("clicked()"), SLOT("slot_addPlugin()"))
  2419. self.connect(self.ui.b_refresh, SIGNAL("clicked()"), SLOT("slot_refreshPlugins()"))
  2420. self.connect(self.ui.tb_filters, SIGNAL("clicked()"), SLOT("slot_maybeShowFilters()"))
  2421. self.connect(self.ui.tableWidget, SIGNAL("currentCellChanged(int, int, int, int)"), SLOT("slot_checkPlugin(int)"))
  2422. self.connect(self.ui.tableWidget, SIGNAL("cellDoubleClicked(int, int)"), SLOT("slot_addPlugin()"))
  2423. self.connect(self.ui.lineEdit, SIGNAL("textChanged(QString)"), SLOT("slot_checkFilters()"))
  2424. self.connect(self.ui.ch_effects, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2425. self.connect(self.ui.ch_instruments, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2426. self.connect(self.ui.ch_midi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2427. self.connect(self.ui.ch_other, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2428. self.connect(self.ui.ch_kits, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2429. self.connect(self.ui.ch_internal, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2430. self.connect(self.ui.ch_ladspa, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2431. self.connect(self.ui.ch_dssi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2432. self.connect(self.ui.ch_lv2, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2433. self.connect(self.ui.ch_vst, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2434. self.connect(self.ui.ch_native, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2435. self.connect(self.ui.ch_bridged, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2436. self.connect(self.ui.ch_bridged_wine, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2437. self.connect(self.ui.ch_gui, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2438. self.connect(self.ui.ch_stereo, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2439. @pyqtSlot()
  2440. def slot_addPlugin(self):
  2441. if self.ui.tableWidget.currentRow() >= 0:
  2442. self.fRetPlugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(), 0).pluginData
  2443. self.accept()
  2444. else:
  2445. self.reject()
  2446. @pyqtSlot(int)
  2447. def slot_checkPlugin(self, row):
  2448. self.ui.b_add.setEnabled(row >= 0)
  2449. @pyqtSlot()
  2450. def slot_checkFilters(self):
  2451. self._checkFilters()
  2452. @pyqtSlot()
  2453. def slot_maybeShowFilters(self):
  2454. self._showFilters(not self.ui.frame.isVisible())
  2455. @pyqtSlot()
  2456. def slot_refreshPlugins(self):
  2457. if PluginRefreshW(self).exec_():
  2458. self._reAddPlugins()
  2459. if self.fRealParent:
  2460. self.fRealParent.loadRDFs()
  2461. def _checkFilters(self):
  2462. text = self.ui.lineEdit.text().lower()
  2463. hideEffects = not self.ui.ch_effects.isChecked()
  2464. hideInstruments = not self.ui.ch_instruments.isChecked()
  2465. hideMidi = not self.ui.ch_midi.isChecked()
  2466. hideOther = not self.ui.ch_other.isChecked()
  2467. hideInternal = not self.ui.ch_internal.isChecked()
  2468. hideLadspa = not self.ui.ch_ladspa.isChecked()
  2469. hideDssi = not self.ui.ch_dssi.isChecked()
  2470. hideLV2 = not self.ui.ch_lv2.isChecked()
  2471. hideVST = not self.ui.ch_vst.isChecked()
  2472. hideKits = not self.ui.ch_kits.isChecked()
  2473. hideNative = not self.ui.ch_native.isChecked()
  2474. hideBridged = not self.ui.ch_bridged.isChecked()
  2475. hideBridgedWine = not self.ui.ch_bridged_wine.isChecked()
  2476. hideNonGui = self.ui.ch_gui.isChecked()
  2477. hideNonStereo = self.ui.ch_stereo.isChecked()
  2478. if HAIKU or LINUX or MACOS:
  2479. nativeBins = [BINARY_POSIX32, BINARY_POSIX64]
  2480. wineBins = [BINARY_WIN32, BINARY_WIN64]
  2481. elif WINDOWS:
  2482. nativeBins = [BINARY_WIN32, BINARY_WIN64]
  2483. wineBins = []
  2484. else:
  2485. nativeBins = []
  2486. wineBins = []
  2487. rowCount = self.ui.tableWidget.rowCount()
  2488. for i in range(rowCount):
  2489. self.ui.tableWidget.showRow(i)
  2490. plugin = self.ui.tableWidget.item(i, 0).pluginData
  2491. aIns = plugin['audio.ins']
  2492. aOuts = plugin['audio.outs']
  2493. mIns = plugin['midi.ins']
  2494. mOuts = plugin['midi.outs']
  2495. ptype = self.ui.tableWidget.item(i, 12).text()
  2496. isSynth = bool(plugin['hints'] & PLUGIN_IS_SYNTH)
  2497. isEffect = bool(aIns > 0 < aOuts and not isSynth)
  2498. isMidi = bool(aIns == 0 and aOuts == 0 and mIns > 0 < mOuts)
  2499. isKit = bool(ptype in ("GIG", "SF2", "SFZ"))
  2500. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  2501. isNative = bool(plugin['build'] == BINARY_NATIVE)
  2502. isStereo = bool(aIns == 2 and aOuts == 2) or (isSynth and aOuts == 2)
  2503. hasGui = bool(plugin['hints'] & PLUGIN_HAS_GUI)
  2504. isBridged = bool(not isNative and plugin['build'] in nativeBins)
  2505. isBridgedWine = bool(not isNative and plugin['build'] in wineBins)
  2506. if (hideEffects and isEffect):
  2507. self.ui.tableWidget.hideRow(i)
  2508. elif (hideInstruments and isSynth):
  2509. self.ui.tableWidget.hideRow(i)
  2510. elif (hideMidi and isMidi):
  2511. self.ui.tableWidget.hideRow(i)
  2512. elif (hideOther and isOther):
  2513. self.ui.tableWidget.hideRow(i)
  2514. elif (hideKits and isKit):
  2515. self.ui.tableWidget.hideRow(i)
  2516. elif (hideInternal and ptype == self.tr("Internal")):
  2517. self.ui.tableWidget.hideRow(i)
  2518. elif (hideLadspa and ptype == "LADSPA"):
  2519. self.ui.tableWidget.hideRow(i)
  2520. elif (hideDssi and ptype == "DSSI"):
  2521. self.ui.tableWidget.hideRow(i)
  2522. elif (hideLV2 and ptype == "LV2"):
  2523. self.ui.tableWidget.hideRow(i)
  2524. elif (hideVST and ptype == "VST"):
  2525. self.ui.tableWidget.hideRow(i)
  2526. elif (hideNative and isNative):
  2527. self.ui.tableWidget.hideRow(i)
  2528. elif (hideBridged and isBridged):
  2529. self.ui.tableWidget.hideRow(i)
  2530. elif (hideBridgedWine and isBridgedWine):
  2531. self.ui.tableWidget.hideRow(i)
  2532. elif (hideNonGui and not hasGui):
  2533. self.ui.tableWidget.hideRow(i)
  2534. elif (hideNonStereo and not isStereo):
  2535. self.ui.tableWidget.hideRow(i)
  2536. elif (text and not (
  2537. text in self.ui.tableWidget.item(i, 0).text().lower() or
  2538. text in self.ui.tableWidget.item(i, 1).text().lower() or
  2539. text in self.ui.tableWidget.item(i, 2).text().lower() or
  2540. text in self.ui.tableWidget.item(i, 3).text().lower() or
  2541. text in self.ui.tableWidget.item(i, 13).text().lower())):
  2542. self.ui.tableWidget.hideRow(i)
  2543. def _showFilters(self, yesNo):
  2544. self.ui.tb_filters.setArrowType(Qt.UpArrow if yesNo else Qt.DownArrow)
  2545. self.ui.frame.setVisible(yesNo)
  2546. def _reAddPlugins(self):
  2547. settingsDB = QSettings("falkTX", "CarlaPlugins")
  2548. rowCount = self.ui.tableWidget.rowCount()
  2549. for x in range(rowCount):
  2550. self.ui.tableWidget.removeRow(0)
  2551. self.fLastTableIndex = 0
  2552. self.ui.tableWidget.setSortingEnabled(False)
  2553. internalCount = 0
  2554. ladspaCount = 0
  2555. dssiCount = 0
  2556. lv2Count = 0
  2557. vstCount = 0
  2558. kitCount = 0
  2559. # ---------------------------------------------------------------------------
  2560. # Internal
  2561. internalPlugins = toList(settingsDB.value("Plugins/Internal", []))
  2562. for plugins in internalPlugins:
  2563. for plugin in plugins:
  2564. internalCount += 1
  2565. if (not Carla.isControl) and internalCount != Carla.host.get_internal_plugin_count():
  2566. internalCount = Carla.host.get_internal_plugin_count()
  2567. internalPlugins = []
  2568. for i in range(Carla.host.get_internal_plugin_count()):
  2569. descInfo = Carla.host.get_internal_plugin_info(i)
  2570. plugins = checkPluginInternal(descInfo)
  2571. if plugins:
  2572. internalPlugins.append(plugins)
  2573. settingsDB.setValue("Plugins/Internal", internalPlugins)
  2574. for plugins in internalPlugins:
  2575. for plugin in plugins:
  2576. self._addPluginToTable(plugin, self.tr("Internal"))
  2577. # ---------------------------------------------------------------------------
  2578. # LADSPA
  2579. ladspaPlugins = []
  2580. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_native", []))
  2581. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix32", []))
  2582. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix64", []))
  2583. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win32", []))
  2584. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win64", []))
  2585. for plugins in ladspaPlugins:
  2586. for plugin in plugins:
  2587. self._addPluginToTable(plugin, "LADSPA")
  2588. ladspaCount += 1
  2589. # ---------------------------------------------------------------------------
  2590. # DSSI
  2591. dssiPlugins = []
  2592. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_native", []))
  2593. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix32", []))
  2594. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix64", []))
  2595. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win32", []))
  2596. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win64", []))
  2597. for plugins in dssiPlugins:
  2598. for plugin in plugins:
  2599. self._addPluginToTable(plugin, "DSSI")
  2600. dssiCount += 1
  2601. # ---------------------------------------------------------------------------
  2602. # LV2
  2603. lv2Plugins = []
  2604. lv2Plugins += toList(settingsDB.value("Plugins/LV2_native", []))
  2605. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix32", []))
  2606. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix64", []))
  2607. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win32", []))
  2608. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win64", []))
  2609. for plugins in lv2Plugins:
  2610. for plugin in plugins:
  2611. self._addPluginToTable(plugin, "LV2")
  2612. lv2Count += 1
  2613. # ---------------------------------------------------------------------------
  2614. # VST
  2615. vstPlugins = []
  2616. vstPlugins += toList(settingsDB.value("Plugins/VST_native", []))
  2617. vstPlugins += toList(settingsDB.value("Plugins/VST_posix32", []))
  2618. vstPlugins += toList(settingsDB.value("Plugins/VST_posix64", []))
  2619. vstPlugins += toList(settingsDB.value("Plugins/VST_win32", []))
  2620. vstPlugins += toList(settingsDB.value("Plugins/VST_win64", []))
  2621. for plugins in vstPlugins:
  2622. for plugin in plugins:
  2623. self._addPluginToTable(plugin, "VST")
  2624. vstCount += 1
  2625. # ---------------------------------------------------------------------------
  2626. # Kits
  2627. gigs = toList(settingsDB.value("Plugins/GIG", []))
  2628. sf2s = toList(settingsDB.value("Plugins/SF2", []))
  2629. sfzs = toList(settingsDB.value("Plugins/SFZ", []))
  2630. for gig in gigs:
  2631. for gig_i in gig:
  2632. self._addPluginToTable(gig_i, "GIG")
  2633. kitCount += 1
  2634. for sf2 in sf2s:
  2635. for sf2_i in sf2:
  2636. self._addPluginToTable(sf2_i, "SF2")
  2637. kitCount += 1
  2638. for sfz in sfzs:
  2639. for sfz_i in sfz:
  2640. self._addPluginToTable(sfz_i, "SFZ")
  2641. kitCount += 1
  2642. # ---------------------------------------------------------------------------
  2643. self.ui.tableWidget.setSortingEnabled(True)
  2644. self.ui.tableWidget.sortByColumn(0, Qt.AscendingOrder)
  2645. self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2, %i VST and %i Sound Kits" % (internalCount, ladspaCount, dssiCount, lv2Count, vstCount, kitCount)))
  2646. self._checkFilters()
  2647. def _addPluginToTable(self, plugin, ptype):
  2648. index = self.fLastTableIndex
  2649. if plugin['build'] == BINARY_NATIVE:
  2650. bridgeText = self.tr("No")
  2651. else:
  2652. typeText = self.tr("Unknown")
  2653. if LINUX or MACOS:
  2654. if plugin['build'] == BINARY_POSIX32:
  2655. typeText = "32bit"
  2656. elif plugin['build'] == BINARY_POSIX64:
  2657. typeText = "64bit"
  2658. elif plugin['build'] == BINARY_WIN32:
  2659. typeText = "Windows 32bit"
  2660. elif plugin['build'] == BINARY_WIN64:
  2661. typeText = "Windows 64bit"
  2662. elif WINDOWS:
  2663. if plugin['build'] == BINARY_WIN32:
  2664. typeText = "32bit"
  2665. elif plugin['build'] == BINARY_WIN64:
  2666. typeText = "64bit"
  2667. bridgeText = self.tr("Yes (%s)" % typeText)
  2668. self.ui.tableWidget.insertRow(index)
  2669. self.ui.tableWidget.setItem(index, 0, QTableWidgetItem(plugin['name']))
  2670. self.ui.tableWidget.setItem(index, 1, QTableWidgetItem(plugin['label']))
  2671. self.ui.tableWidget.setItem(index, 2, QTableWidgetItem(plugin['maker']))
  2672. self.ui.tableWidget.setItem(index, 3, QTableWidgetItem(str(plugin['uniqueId'])))
  2673. self.ui.tableWidget.setItem(index, 4, QTableWidgetItem(str(plugin['audio.ins'])))
  2674. self.ui.tableWidget.setItem(index, 5, QTableWidgetItem(str(plugin['audio.outs'])))
  2675. self.ui.tableWidget.setItem(index, 6, QTableWidgetItem(str(plugin['parameters.ins'])))
  2676. self.ui.tableWidget.setItem(index, 7, QTableWidgetItem(str(plugin['parameters.outs'])))
  2677. self.ui.tableWidget.setItem(index, 8, QTableWidgetItem(str(plugin['programs.total'])))
  2678. self.ui.tableWidget.setItem(index, 9, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_HAS_GUI) else self.tr("No")))
  2679. self.ui.tableWidget.setItem(index, 10, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_IS_SYNTH) else self.tr("No")))
  2680. self.ui.tableWidget.setItem(index, 11, QTableWidgetItem(bridgeText))
  2681. self.ui.tableWidget.setItem(index, 12, QTableWidgetItem(ptype))
  2682. self.ui.tableWidget.setItem(index, 13, QTableWidgetItem(plugin['binary']))
  2683. self.ui.tableWidget.item(self.fLastTableIndex, 0).pluginData = plugin
  2684. self.fLastTableIndex += 1
  2685. def _saveSettings(self):
  2686. settings = QSettings()
  2687. settings.setValue("PluginDatabase/Geometry", self.saveGeometry())
  2688. settings.setValue("PluginDatabase/TableGeometry", self.ui.tableWidget.horizontalHeader().saveState())
  2689. settings.setValue("PluginDatabase/ShowFilters", (self.ui.tb_filters.arrowType() == Qt.UpArrow))
  2690. settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked())
  2691. settings.setValue("PluginDatabase/ShowInstruments", self.ui.ch_instruments.isChecked())
  2692. settings.setValue("PluginDatabase/ShowMIDI", self.ui.ch_midi.isChecked())
  2693. settings.setValue("PluginDatabase/ShowOther", self.ui.ch_other.isChecked())
  2694. settings.setValue("PluginDatabase/ShowInternal", self.ui.ch_internal.isChecked())
  2695. settings.setValue("PluginDatabase/ShowLADSPA", self.ui.ch_ladspa.isChecked())
  2696. settings.setValue("PluginDatabase/ShowDSSI", self.ui.ch_dssi.isChecked())
  2697. settings.setValue("PluginDatabase/ShowLV2", self.ui.ch_lv2.isChecked())
  2698. settings.setValue("PluginDatabase/ShowVST", self.ui.ch_vst.isChecked())
  2699. settings.setValue("PluginDatabase/ShowKits", self.ui.ch_kits.isChecked())
  2700. settings.setValue("PluginDatabase/ShowNative", self.ui.ch_native.isChecked())
  2701. settings.setValue("PluginDatabase/ShowBridged", self.ui.ch_bridged.isChecked())
  2702. settings.setValue("PluginDatabase/ShowBridgedWine", self.ui.ch_bridged_wine.isChecked())
  2703. settings.setValue("PluginDatabase/ShowHasGUI", self.ui.ch_gui.isChecked())
  2704. settings.setValue("PluginDatabase/ShowStereoOnly", self.ui.ch_stereo.isChecked())
  2705. def _loadSettings(self):
  2706. settings = QSettings()
  2707. self.restoreGeometry(settings.value("PluginDatabase/Geometry", ""))
  2708. self.ui.tableWidget.horizontalHeader().restoreState(settings.value("PluginDatabase/TableGeometry", ""))
  2709. self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, type=bool))
  2710. self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, type=bool))
  2711. self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, type=bool))
  2712. self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, type=bool))
  2713. self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, type=bool))
  2714. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, type=bool))
  2715. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, type=bool))
  2716. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, type=bool))
  2717. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST", True, type=bool))
  2718. self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, type=bool))
  2719. self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, type=bool))
  2720. self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, type=bool))
  2721. self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, type=bool))
  2722. self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, type=bool))
  2723. self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, type=bool))
  2724. self._showFilters(settings.value("PluginDatabase/ShowFilters", False, type=bool))
  2725. self._reAddPlugins()
  2726. def closeEvent(self, event):
  2727. self._saveSettings()
  2728. QDialog.closeEvent(self, event)
  2729. def done(self, r):
  2730. QDialog.done(self, r)
  2731. self.close()
  2732. # ------------------------------------------------------------------------------------------------------------
  2733. # TESTING
  2734. #from PyQt4.QtGui import QApplication
  2735. #Carla.isControl = True
  2736. #ptest = {
  2737. #'index': 0,
  2738. #'name': "Parameter",
  2739. #'symbol': "param",
  2740. #'current': 0.1,
  2741. #'default': 0.3,
  2742. #'minimum': 0.0,
  2743. #'maximum': 1.0,
  2744. #'midiChannel': 7,
  2745. #'midiCC': 2,
  2746. #'type': PARAMETER_INPUT,
  2747. #'hints': PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE,
  2748. #'scalePoints': [],
  2749. #'step': 0.01,
  2750. #'stepSmall': 0.001,
  2751. #'stepLarge': 0.1,
  2752. #'unit': "un",
  2753. #}
  2754. #app = QApplication(sys.argv)
  2755. #app.setApplicationName("Carla")
  2756. #app.setApplicationVersion(VERSION)
  2757. #app.setOrganizationName("falkTX")
  2758. #gui = CarlaAboutW(None)
  2759. #gui = PluginParameter(None, ptest, 0, 0)
  2760. #gui = PluginEdit(None, 0)
  2761. #gui = PluginWidget(None, 0)
  2762. #gui = PluginDatabaseW(None)
  2763. #gui.show()
  2764. #if gui.exec_():
  2765. #print(gui.fRetPlugin)
  2766. #gui = PluginRefreshW(None)
  2767. #app.exec_()