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

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