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

carla_shared.py 132KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353
  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 = "1.1.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_MULTIPLE_CLIENTS if LINUX else 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. try:
  547. Ps.wait()
  548. output = Ps.stdout.read().decode("utf-8", errors="ignore").split("\n")
  549. except:
  550. output = ""
  551. pinfo = None
  552. for line in output:
  553. line = line.strip()
  554. if line == "carla-discovery::init::-----------":
  555. pinfo = deepcopy(PyPluginInfo)
  556. pinfo['type'] = itype
  557. pinfo['binary'] = filename
  558. elif line == "carla-discovery::end::------------":
  559. if pinfo != None:
  560. plugins.append(pinfo)
  561. pinfo = None
  562. elif line == "Segmentation fault":
  563. print("carla-discovery::crash::%s crashed during discovery" % filename)
  564. elif line.startswith("err:module:import_dll Library"):
  565. print(line)
  566. elif line.startswith("carla-discovery::error::"):
  567. print("%s - %s" % (line, filename))
  568. elif line.startswith("carla-discovery::"):
  569. if pinfo == None:
  570. continue
  571. prop, value = line.replace("carla-discovery::", "").split("::", 1)
  572. if prop == "name":
  573. pinfo['name'] = value if value else fakeLabel
  574. elif prop in ("label", "uri"):
  575. pinfo['label'] = value if value else fakeLabel
  576. elif prop == "maker":
  577. pinfo['maker'] = value
  578. elif prop == "copyright":
  579. pinfo['copyright'] = value
  580. elif prop == "uniqueId":
  581. if value.isdigit(): pinfo['uniqueId'] = int(value)
  582. elif prop == "hints":
  583. if value.isdigit(): pinfo['hints'] = int(value)
  584. elif prop == "audio.ins":
  585. if value.isdigit(): pinfo['audio.ins'] = int(value)
  586. elif prop == "audio.outs":
  587. if value.isdigit(): pinfo['audio.outs'] = int(value)
  588. elif prop == "audio.total":
  589. if value.isdigit(): pinfo['audio.total'] = int(value)
  590. elif prop == "midi.ins":
  591. if value.isdigit(): pinfo['midi.ins'] = int(value)
  592. elif prop == "midi.outs":
  593. if value.isdigit(): pinfo['midi.outs'] = int(value)
  594. elif prop == "midi.total":
  595. if value.isdigit(): pinfo['midi.total'] = int(value)
  596. elif prop == "parameters.ins":
  597. if value.isdigit(): pinfo['parameters.ins'] = int(value)
  598. elif prop == "parameters.outs":
  599. if value.isdigit(): pinfo['parameters.outs'] = int(value)
  600. elif prop == "parameters.total":
  601. if value.isdigit(): pinfo['parameters.total'] = int(value)
  602. elif prop == "programs.total":
  603. if value.isdigit(): pinfo['programs.total'] = int(value)
  604. elif prop == "build":
  605. if value.isdigit(): pinfo['build'] = int(value)
  606. # Additional checks
  607. for pinfo in plugins:
  608. if itype == PLUGIN_DSSI:
  609. if findDSSIGUI(pinfo['binary'], pinfo['name'], pinfo['label']):
  610. pinfo['hints'] |= PLUGIN_HAS_GUI
  611. return plugins
  612. def checkPluginInternal(desc):
  613. plugins = []
  614. pinfo = deepcopy(PyPluginInfo)
  615. pinfo['build'] = BINARY_NATIVE
  616. pinfo['type'] = PLUGIN_INTERNAL
  617. pinfo['hints'] = int(desc['hints'])
  618. pinfo['name'] = cString(desc['name'])
  619. pinfo['label'] = cString(desc['label'])
  620. pinfo['maker'] = cString(desc['maker'])
  621. pinfo['copyright'] = cString(desc['copyright'])
  622. pinfo['audio.ins'] = int(desc['audioIns'])
  623. pinfo['audio.outs'] = int(desc['audioOuts'])
  624. pinfo['audio.total'] = pinfo['audio.ins'] + pinfo['audio.outs']
  625. pinfo['midi.ins'] = int(desc['midiIns'])
  626. pinfo['midi.outs'] = int(desc['midiOuts'])
  627. pinfo['midi.total'] = pinfo['midi.ins'] + pinfo['midi.outs']
  628. pinfo['parameters.ins'] = int(desc['parameterIns'])
  629. pinfo['parameters.outs'] = int(desc['parameterOuts'])
  630. pinfo['parameters.total'] = pinfo['parameters.ins'] + pinfo['parameters.outs']
  631. plugins.append(pinfo)
  632. return plugins
  633. def checkPluginLADSPA(filename, tool, isWine=False):
  634. return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, isWine)
  635. def checkPluginDSSI(filename, tool, isWine=False):
  636. return runCarlaDiscovery(PLUGIN_DSSI, "DSSI", filename, tool, isWine)
  637. def checkPluginLV2(filename, tool, isWine=False):
  638. return runCarlaDiscovery(PLUGIN_LV2, "LV2", filename, tool, isWine)
  639. def checkPluginVST(filename, tool, isWine=False):
  640. return runCarlaDiscovery(PLUGIN_VST, "VST", filename, tool, isWine)
  641. def checkPluginGIG(filename, tool):
  642. return runCarlaDiscovery(PLUGIN_GIG, "GIG", filename, tool)
  643. def checkPluginSF2(filename, tool):
  644. return runCarlaDiscovery(PLUGIN_SF2, "SF2", filename, tool)
  645. def checkPluginSFZ(filename, tool):
  646. return runCarlaDiscovery(PLUGIN_SFZ, "SFZ", filename, tool)
  647. # ------------------------------------------------------------------------------------------------------------
  648. # Carla About dialog
  649. class CarlaAboutW(QDialog):
  650. def __init__(self, parent):
  651. QDialog.__init__(self, parent)
  652. self.ui = ui_carla_about.Ui_CarlaAboutW()
  653. self.ui.setupUi(self)
  654. if Carla.isControl:
  655. extraInfo = " - <b>%s</b>" % self.tr("OSC Bridge Version")
  656. else:
  657. extraInfo = ""
  658. self.ui.l_about.setText(self.tr(""
  659. "<br>Version %s"
  660. "<br>Carla is a Multi-Plugin Host for JACK%s.<br>"
  661. "<br>Copyright (C) 2011-2013 falkTX<br>"
  662. "" % (VERSION, extraInfo)))
  663. if Carla.isControl:
  664. self.ui.l_extended.hide()
  665. self.ui.tabWidget.removeTab(1)
  666. self.ui.tabWidget.removeTab(1)
  667. self.adjustSize()
  668. else:
  669. self.ui.l_extended.setText(cString(Carla.host.get_extended_license_text()))
  670. if Carla.host.is_engine_running():
  671. self.ui.le_osc_url_tcp.setText(cString(Carla.host.get_host_osc_url_tcp()))
  672. self.ui.le_osc_url_udp.setText(cString(Carla.host.get_host_osc_url_udp()))
  673. else:
  674. self.ui.le_osc_url_tcp.setText(self.tr("(Engine not running)"))
  675. self.ui.le_osc_url_udp.setText(self.tr("(Engine not running)"))
  676. self.ui.l_osc_cmds.setText(""
  677. " /set_active <i-value>\n"
  678. " /set_drywet <f-value>\n"
  679. " /set_volume <f-value>\n"
  680. " /set_balance_left <f-value>\n"
  681. " /set_balance_right <f-value>\n"
  682. " /set_panning <f-value>\n"
  683. " /set_parameter_value <i-index> <f-value>\n"
  684. " /set_parameter_midi_cc <i-index> <i-cc>\n"
  685. " /set_parameter_midi_channel <i-index> <i-channel>\n"
  686. " /set_program <i-index>\n"
  687. " /set_midi_program <i-index>\n"
  688. " /note_on <i-note> <i-velo>\n"
  689. " /note_off <i-note>\n"
  690. )
  691. self.ui.l_example.setText("/Carla/2/set_parameter_value 5 1.0")
  692. self.ui.l_example_help.setText("<i>(as in this example, \"2\" is the plugin number and \"5\" the parameter)</i>")
  693. self.ui.l_ladspa.setText(self.tr("Everything! (Including LRDF)"))
  694. self.ui.l_dssi.setText(self.tr("Everything! (Including CustomData/Chunks)"))
  695. self.ui.l_lv2.setText(self.tr("About 80&#37; complete (using custom extensions)<br/>"
  696. "Implemented Feature/Extensions:"
  697. "<ul>"
  698. "<li>http://lv2plug.in/ns/ext/atom</li>"
  699. "<li>http://lv2plug.in/ns/ext/buf-size</li>"
  700. "<li>http://lv2plug.in/ns/ext/data-access</li>"
  701. #"<li>http://lv2plug.in/ns/ext/dynmanifest</li>"
  702. "<li>http://lv2plug.in/ns/ext/event</li>"
  703. "<li>http://lv2plug.in/ns/ext/instance-access</li>"
  704. "<li>http://lv2plug.in/ns/ext/log</li>"
  705. "<li>http://lv2plug.in/ns/ext/midi</li>"
  706. "<li>http://lv2plug.in/ns/ext/options</li>"
  707. "<li>http://lv2plug.in/ns/ext/parameters</li>"
  708. #"<li>http://lv2plug.in/ns/ext/patch</li>"
  709. #"<li>http://lv2plug.in/ns/ext/port-groups</li>"
  710. #"<li>http://lv2plug.in/ns/ext/port-props</li>"
  711. "<li>http://lv2plug.in/ns/ext/presets</li>"
  712. "<li>http://lv2plug.in/ns/ext/state</li>"
  713. "<li>http://lv2plug.in/ns/ext/time</li>"
  714. "<li>http://lv2plug.in/ns/ext/uri-map</li>"
  715. "<li>http://lv2plug.in/ns/ext/urid</li>"
  716. #"<li>http://lv2plug.in/ns/ext/worker</li>"
  717. "<li>http://lv2plug.in/ns/extensions/ui</li>"
  718. "<li>http://lv2plug.in/ns/extensions/units</li>"
  719. "<li>http://kxstudio.sf.net/ns/lv2ext/external-ui</li>"
  720. "<li>http://kxstudio.sf.net/ns/lv2ext/programs</li>"
  721. "<li>http://kxstudio.sf.net/ns/lv2ext/rtmempool</li>"
  722. "<li>http://ll-plugins.nongnu.org/lv2/ext/midimap</li>"
  723. "<li>http://ll-plugins.nongnu.org/lv2/ext/miditype</li>"
  724. "</ul>"))
  725. self.ui.l_vst.setText(self.tr("<p>About 85&#37; complete (missing vst bank/presets and some minor stuff)</p>"))
  726. def done(self, r):
  727. QDialog.done(self, r)
  728. self.close()
  729. # ------------------------------------------------------------------------------------------------------------
  730. # Plugin Parameter
  731. class PluginParameter(QWidget):
  732. def __init__(self, parent, pInfo, pluginId, tabIndex):
  733. QWidget.__init__(self, parent)
  734. self.ui = ui_carla_parameter.Ui_PluginParameter()
  735. self.ui.setupUi(self)
  736. # -------------------------------------------------------------
  737. # Internal stuff
  738. self.fMidiControl = -1
  739. self.fMidiChannel = 1
  740. self.fParameterId = pInfo['index']
  741. self.fPluginId = pluginId
  742. self.fTabIndex = tabIndex
  743. # -------------------------------------------------------------
  744. # Set-up GUI
  745. pType = pInfo['type']
  746. pHints = pInfo['hints']
  747. self.ui.label.setText(pInfo['name'])
  748. self.ui.widget.setName(pInfo['name'])
  749. if pType == PARAMETER_INPUT:
  750. self.ui.widget.setMinimum(pInfo['minimum'])
  751. self.ui.widget.setMaximum(pInfo['maximum'])
  752. self.ui.widget.setDefault(pInfo['default'])
  753. self.ui.widget.setValue(pInfo['current'], False)
  754. self.ui.widget.setLabel(pInfo['unit'])
  755. self.ui.widget.setStep(pInfo['step'])
  756. self.ui.widget.setStepSmall(pInfo['stepSmall'])
  757. self.ui.widget.setStepLarge(pInfo['stepLarge'])
  758. self.ui.widget.setScalePoints(pInfo['scalePoints'], bool(pHints & PARAMETER_USES_SCALEPOINTS))
  759. if not pHints & PARAMETER_IS_ENABLED:
  760. self.ui.label.setEnabled(False)
  761. self.ui.widget.setEnabled(False)
  762. self.ui.widget.setReadOnly(True)
  763. self.ui.sb_control.setEnabled(False)
  764. self.ui.sb_channel.setEnabled(False)
  765. elif not pHints & PARAMETER_IS_AUTOMABLE:
  766. self.ui.sb_control.setEnabled(False)
  767. self.ui.sb_channel.setEnabled(False)
  768. if pHints & PARAMETER_IS_READ_ONLY:
  769. self.ui.widget.setReadOnly(True)
  770. elif pType == PARAMETER_OUTPUT:
  771. self.ui.widget.setMinimum(pInfo['minimum'])
  772. self.ui.widget.setMaximum(pInfo['maximum'])
  773. self.ui.widget.setValue(pInfo['current'], False)
  774. self.ui.widget.setLabel(pInfo['unit'])
  775. self.ui.widget.setReadOnly(True)
  776. if not pHints & PARAMETER_IS_AUTOMABLE:
  777. self.ui.sb_control.setEnabled(False)
  778. self.ui.sb_channel.setEnabled(False)
  779. else:
  780. self.ui.widget.setVisible(False)
  781. self.ui.sb_control.setVisible(False)
  782. self.ui.sb_channel.setVisible(False)
  783. if pHints & PARAMETER_USES_CUSTOM_TEXT:
  784. self.ui.widget.setTextCallback(self._textCallBack)
  785. self.ui.widget.updateAll()
  786. self.setMidiControl(pInfo['midiCC'])
  787. self.setMidiChannel(pInfo['midiChannel'])
  788. # -------------------------------------------------------------
  789. # Set-up connections
  790. self.connect(self.ui.sb_control, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_controlSpinboxCustomMenu()"))
  791. self.connect(self.ui.sb_channel, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_channelSpinboxCustomMenu()"))
  792. self.connect(self.ui.sb_control, SIGNAL("valueChanged(int)"), SLOT("slot_controlSpinboxChanged(int)"))
  793. self.connect(self.ui.sb_channel, SIGNAL("valueChanged(int)"), SLOT("slot_channelSpinboxChanged(int)"))
  794. self.connect(self.ui.widget, SIGNAL("valueChanged(double)"), SLOT("slot_widgetValueChanged(double)"))
  795. # -------------------------------------------------------------
  796. def pluginId(self):
  797. return self.fPluginId
  798. def tabIndex(self):
  799. return self.fTabIndex
  800. def setDefault(self, value):
  801. self.ui.widget.setDefault(value)
  802. def setValue(self, value, send=True):
  803. self.ui.widget.setValue(value, send)
  804. def setMidiControl(self, control):
  805. self.fMidiControl = control
  806. self.ui.sb_control.blockSignals(True)
  807. self.ui.sb_control.setValue(control)
  808. self.ui.sb_control.blockSignals(False)
  809. def setMidiChannel(self, channel):
  810. self.fMidiChannel = channel
  811. self.ui.sb_channel.blockSignals(True)
  812. self.ui.sb_channel.setValue(channel)
  813. self.ui.sb_channel.blockSignals(False)
  814. def setLabelWidth(self, width):
  815. self.ui.label.setMinimumWidth(width)
  816. self.ui.label.setMaximumWidth(width)
  817. @pyqtSlot()
  818. def slot_controlSpinboxCustomMenu(self):
  819. menu = QMenu(self)
  820. actNone = menu.addAction(self.tr("None"))
  821. if self.fMidiControl == -1:
  822. actNone.setCheckable(True)
  823. actNone.setChecked(True)
  824. for cc in MIDI_CC_LIST:
  825. action = menu.addAction(cc)
  826. if self.fMidiControl != -1 and int(cc.split(" ")[0], 16) == self.fMidiControl:
  827. action.setCheckable(True)
  828. action.setChecked(True)
  829. actSel = menu.exec_(QCursor.pos())
  830. if not actSel:
  831. pass
  832. elif actSel == actNone:
  833. self.ui.sb_control.setValue(-1)
  834. else:
  835. selControlStr = actSel.text()
  836. selControl = int(selControlStr.split(" ")[0], 16)
  837. self.ui.sb_control.setValue(selControl)
  838. @pyqtSlot()
  839. def slot_channelSpinboxCustomMenu(self):
  840. menu = QMenu(self)
  841. for i in range(1, 16+1):
  842. action = menu.addAction("%i" % i)
  843. if self.fMidiChannel == i:
  844. action.setCheckable(True)
  845. action.setChecked(True)
  846. actSel = menu.exec_(QCursor.pos())
  847. if actSel:
  848. selChannel = int(actSel.text())
  849. self.ui.sb_channel.setValue(selChannel)
  850. @pyqtSlot(int)
  851. def slot_controlSpinboxChanged(self, control):
  852. if self.fMidiControl != control:
  853. self.emit(SIGNAL("midiControlChanged(int, int)"), self.fParameterId, control)
  854. self.fMidiControl = control
  855. @pyqtSlot(int)
  856. def slot_channelSpinboxChanged(self, channel):
  857. if self.fMidiChannel != channel:
  858. self.emit(SIGNAL("midiChannelChanged(int, int)"), self.fParameterId, channel)
  859. self.fMidiChannel = channel
  860. @pyqtSlot(float)
  861. def slot_widgetValueChanged(self, value):
  862. self.emit(SIGNAL("valueChanged(int, double)"), self.fParameterId, value)
  863. def _textCallBack(self):
  864. return cString(Carla.host.get_parameter_text(self.fPluginId, self.fParameterId))
  865. # ------------------------------------------------------------------------------------------------------------
  866. # Plugin Editor (Built-in)
  867. class PluginEdit(QDialog):
  868. def __init__(self, parent, pluginId):
  869. QDialog.__init__(self, Carla.gui)
  870. self.ui = ui_carla_edit.Ui_PluginEdit()
  871. self.ui.setupUi(self)
  872. # -------------------------------------------------------------
  873. # Internal stuff
  874. self.fGeometry = QByteArray()
  875. self.fPluginId = pluginId
  876. self.fPuginInfo = None
  877. self.fRealParent = parent
  878. self.fCurrentProgram = -1
  879. self.fCurrentMidiProgram = -1
  880. self.fCurrentStateFilename = None
  881. self.fControlChannel = 0
  882. self.fScrollAreaSetup = False
  883. self.fParameterCount = 0
  884. self.fParameterList = [] # (type, id, widget)
  885. self.fParametersToUpdate = [] # (id, value)
  886. self.fPlayingNotes = [] # (channel, note)
  887. self.fTabIconOff = QIcon(":/bitmaps/led_off.png")
  888. self.fTabIconOn = QIcon(":/bitmaps/led_yellow.png")
  889. self.fTabIconCount = 0
  890. self.fTabIconTimers = []
  891. # -------------------------------------------------------------
  892. # Set-up GUI
  893. self.ui.dial_drywet.setCustomPaint(self.ui.dial_drywet.CUSTOM_PAINT_CARLA_WET)
  894. self.ui.dial_drywet.setPixmap(3)
  895. self.ui.dial_drywet.setLabel("Dry/Wet")
  896. self.ui.dial_vol.setCustomPaint(self.ui.dial_vol.CUSTOM_PAINT_CARLA_VOL)
  897. self.ui.dial_vol.setPixmap(3)
  898. self.ui.dial_vol.setLabel("Volume")
  899. self.ui.dial_b_left.setCustomPaint(self.ui.dial_b_left.CUSTOM_PAINT_CARLA_L)
  900. self.ui.dial_b_left.setPixmap(4)
  901. self.ui.dial_b_left.setLabel("L")
  902. self.ui.dial_b_right.setCustomPaint(self.ui.dial_b_right.CUSTOM_PAINT_CARLA_R)
  903. self.ui.dial_b_right.setPixmap(4)
  904. self.ui.dial_b_right.setLabel("R")
  905. self.ui.keyboard.setMode(self.ui.keyboard.HORIZONTAL)
  906. self.ui.keyboard.setOctaves(10)
  907. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  908. self.ui.scrollArea.ensureVisible(self.ui.keyboard.width() / 3, 0)
  909. self.ui.scrollArea.setEnabled(False)
  910. self.ui.scrollArea.setVisible(False)
  911. self.reloadAll()
  912. # -------------------------------------------------------------
  913. # Set-up connections
  914. self.connect(self, SIGNAL("finished(int)"), SLOT("slot_finished()"))
  915. self.connect(self.ui.ch_fixed_buffer, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  916. self.connect(self.ui.ch_force_stereo, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  917. self.connect(self.ui.ch_map_program_changes, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  918. self.connect(self.ui.ch_use_chunks, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  919. self.connect(self.ui.ch_send_control_changes, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  920. self.connect(self.ui.ch_send_channel_pressure, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  921. self.connect(self.ui.ch_send_note_aftertouch, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  922. self.connect(self.ui.ch_send_pitchbend, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  923. self.connect(self.ui.ch_send_all_sound_off, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  924. self.connect(self.ui.dial_drywet, SIGNAL("valueChanged(int)"), SLOT("slot_dryWetChanged(int)"))
  925. self.connect(self.ui.dial_vol, SIGNAL("valueChanged(int)"), SLOT("slot_volumeChanged(int)"))
  926. self.connect(self.ui.dial_b_left, SIGNAL("valueChanged(int)"), SLOT("slot_balanceLeftChanged(int)"))
  927. self.connect(self.ui.dial_b_right, SIGNAL("valueChanged(int)"), SLOT("slot_balanceRightChanged(int)"))
  928. self.connect(self.ui.sb_ctrl_channel, SIGNAL("valueChanged(int)"), SLOT("slot_ctrlChannelChanged(int)"))
  929. self.connect(self.ui.dial_drywet, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_knobCustomMenu()"))
  930. self.connect(self.ui.dial_vol, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_knobCustomMenu()"))
  931. self.connect(self.ui.dial_b_left, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_knobCustomMenu()"))
  932. self.connect(self.ui.dial_b_right, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_knobCustomMenu()"))
  933. self.connect(self.ui.sb_ctrl_channel, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_channelCustomMenu()"))
  934. self.connect(self.ui.keyboard, SIGNAL("noteOn(int)"), SLOT("slot_noteOn(int)"))
  935. self.connect(self.ui.keyboard, SIGNAL("noteOff(int)"), SLOT("slot_noteOff(int)"))
  936. self.connect(self.ui.cb_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_programIndexChanged(int)"))
  937. self.connect(self.ui.cb_midi_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_midiProgramIndexChanged(int)"))
  938. if Carla.isLocal:
  939. self.connect(self.ui.b_save_state, SIGNAL("clicked()"), SLOT("slot_stateSave()"))
  940. self.connect(self.ui.b_load_state, SIGNAL("clicked()"), SLOT("slot_stateLoad()"))
  941. else:
  942. self.ui.b_load_state.setEnabled(False)
  943. self.ui.b_save_state.setEnabled(False)
  944. # -------------------------------------------------------------
  945. def reloadAll(self):
  946. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId)
  947. self.fPluginInfo['binary'] = cString(self.fPluginInfo['binary'])
  948. self.fPluginInfo['name'] = cString(self.fPluginInfo['name'])
  949. self.fPluginInfo['label'] = cString(self.fPluginInfo['label'])
  950. self.fPluginInfo['maker'] = cString(self.fPluginInfo['maker'])
  951. self.fPluginInfo['copyright'] = cString(self.fPluginInfo['copyright'])
  952. self.fPluginInfo['iconName'] = cString(self.fPluginInfo['iconName'])
  953. if not Carla.isLocal:
  954. self.fPluginInfo['hints'] &= ~PLUGIN_HAS_GUI
  955. self.reloadInfo()
  956. self.reloadParameters()
  957. self.reloadPrograms()
  958. if self.fPluginInfo['type'] == PLUGIN_LV2:
  959. self.ui.b_save_state.setEnabled(False)
  960. if not self.ui.scrollArea.isEnabled():
  961. self.resize(self.width(), self.height()-self.ui.scrollArea.height())
  962. def reloadInfo(self):
  963. pluginName = cString(Carla.host.get_real_plugin_name(self.fPluginId))
  964. pluginType = self.fPluginInfo['type']
  965. pluginHints = self.fPluginInfo['hints']
  966. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  967. midiCountInfo = Carla.host.get_midi_port_count_info(self.fPluginId)
  968. paramCountInfo = Carla.host.get_parameter_count_info(self.fPluginId)
  969. if pluginType == PLUGIN_INTERNAL:
  970. self.ui.le_type.setText(self.tr("Internal"))
  971. elif pluginType == PLUGIN_LADSPA:
  972. self.ui.le_type.setText("LADSPA")
  973. elif pluginType == PLUGIN_DSSI:
  974. self.ui.le_type.setText("DSSI")
  975. elif pluginType == PLUGIN_LV2:
  976. self.ui.le_type.setText("LV2")
  977. elif pluginType == PLUGIN_VST:
  978. self.ui.le_type.setText("VST")
  979. elif pluginType == PLUGIN_VST3:
  980. self.ui.le_type.setText("VST3")
  981. elif pluginType == PLUGIN_GIG:
  982. self.ui.le_type.setText("GIG")
  983. elif pluginType == PLUGIN_SF2:
  984. self.ui.le_type.setText("SF2")
  985. elif pluginType == PLUGIN_SFZ:
  986. self.ui.le_type.setText("SFZ")
  987. else:
  988. self.ui.le_type.setText(self.tr("Unknown"))
  989. self.ui.le_name.setText(pluginName)
  990. self.ui.le_name.setToolTip(pluginName)
  991. self.ui.le_label.setText(self.fPluginInfo['label'])
  992. self.ui.le_label.setToolTip(self.fPluginInfo['label'])
  993. self.ui.le_maker.setText(self.fPluginInfo['maker'])
  994. self.ui.le_maker.setToolTip(self.fPluginInfo['maker'])
  995. self.ui.le_copyright.setText(self.fPluginInfo['copyright'])
  996. self.ui.le_copyright.setToolTip(self.fPluginInfo['copyright'])
  997. self.ui.le_unique_id.setText(str(self.fPluginInfo['uniqueId']))
  998. self.ui.le_unique_id.setToolTip(str(self.fPluginInfo['uniqueId']))
  999. self.ui.le_ains.setText(str(audioCountInfo['ins']))
  1000. self.ui.le_aouts.setText(str(audioCountInfo['outs']))
  1001. self.ui.le_params.setText(str(paramCountInfo['ins']))
  1002. self.ui.label_plugin.setText("\n%s\n" % self.fPluginInfo['name'])
  1003. self.setWindowTitle(self.fPluginInfo['name'])
  1004. if self.fPluginInfo['latency'] > 0:
  1005. self.ui.le_latency.setText("%i samples" % self.fPluginInfo['latency'])
  1006. else:
  1007. self.ui.le_latency.setText(self.tr("None"))
  1008. self.ui.dial_drywet.setEnabled(pluginHints & PLUGIN_CAN_DRYWET)
  1009. self.ui.dial_vol.setEnabled(pluginHints & PLUGIN_CAN_VOLUME)
  1010. self.ui.dial_b_left.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  1011. self.ui.dial_b_right.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  1012. self.ui.ch_fixed_buffer.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FIXED_BUFFER)
  1013. self.ui.ch_fixed_buffer.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FIXED_BUFFER)
  1014. self.ui.ch_force_stereo.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FORCE_STEREO)
  1015. self.ui.ch_force_stereo.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FORCE_STEREO)
  1016. self.ui.ch_map_program_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  1017. self.ui.ch_map_program_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  1018. self.ui.ch_use_chunks.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_USE_CHUNKS)
  1019. self.ui.ch_use_chunks.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_USE_CHUNKS)
  1020. self.ui.ch_send_control_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  1021. self.ui.ch_send_control_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  1022. self.ui.ch_send_channel_pressure.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  1023. self.ui.ch_send_channel_pressure.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  1024. self.ui.ch_send_note_aftertouch.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  1025. self.ui.ch_send_note_aftertouch.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  1026. self.ui.ch_send_pitchbend.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PITCHBEND)
  1027. self.ui.ch_send_pitchbend.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_PITCHBEND)
  1028. self.ui.ch_send_all_sound_off.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  1029. self.ui.ch_send_all_sound_off.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  1030. if self.fPluginInfo['type'] != PLUGIN_VST:
  1031. self.ui.tab_programs.setCurrentIndex(1)
  1032. # Show/hide keyboard
  1033. showKeyboard = (pluginHints & PLUGIN_IS_SYNTH) != 0 or (midiCountInfo['ins'] > 0 < midiCountInfo['outs'])
  1034. self.ui.scrollArea.setEnabled(showKeyboard)
  1035. self.ui.scrollArea.setVisible(showKeyboard)
  1036. # Force-Update parent for new hints
  1037. if self.fRealParent:
  1038. self.fRealParent.recheckPluginHints(pluginHints)
  1039. def reloadParameters(self):
  1040. parameterCount = Carla.host.get_parameter_count(self.fPluginId)
  1041. # Reset
  1042. self.fParameterCount = 0
  1043. self.fParameterList = []
  1044. self.fParametersToUpdate = []
  1045. self.fTabIconCount = 0
  1046. self.fTabIconTimers = []
  1047. # Remove all previous parameters
  1048. for x in range(self.ui.tabWidget.count()-1):
  1049. self.ui.tabWidget.widget(1).deleteLater()
  1050. self.ui.tabWidget.removeTab(1)
  1051. if parameterCount <= 0:
  1052. pass
  1053. elif parameterCount <= Carla.maxParameters:
  1054. paramInputListFull = []
  1055. paramOutputListFull = []
  1056. paramInputList = [] # ([params], width)
  1057. paramInputWidth = 0
  1058. paramOutputList = [] # ([params], width)
  1059. paramOutputWidth = 0
  1060. for i in range(parameterCount):
  1061. paramInfo = Carla.host.get_parameter_info(self.fPluginId, i)
  1062. paramData = Carla.host.get_parameter_data(self.fPluginId, i)
  1063. paramRanges = Carla.host.get_parameter_ranges(self.fPluginId, i)
  1064. paramValue = Carla.host.get_current_parameter_value(self.fPluginId, i)
  1065. if paramData['type'] not in (PARAMETER_INPUT, PARAMETER_OUTPUT):
  1066. continue
  1067. parameter = {
  1068. 'type': paramData['type'],
  1069. 'hints': paramData['hints'],
  1070. 'name': cString(paramInfo['name']),
  1071. 'unit': cString(paramInfo['unit']),
  1072. 'scalePoints': [],
  1073. 'index': paramData['index'],
  1074. 'default': paramRanges['def'],
  1075. 'minimum': paramRanges['min'],
  1076. 'maximum': paramRanges['max'],
  1077. 'step': paramRanges['step'],
  1078. 'stepSmall': paramRanges['stepSmall'],
  1079. 'stepLarge': paramRanges['stepLarge'],
  1080. 'midiCC': paramData['midiCC'],
  1081. 'midiChannel': paramData['midiChannel']+1,
  1082. 'current': paramValue
  1083. }
  1084. for j in range(paramInfo['scalePointCount']):
  1085. scalePointInfo = Carla.host.get_parameter_scalepoint_info(self.fPluginId, i, j)
  1086. parameter['scalePoints'].append({
  1087. 'value': scalePointInfo['value'],
  1088. 'label': cString(scalePointInfo['label'])
  1089. })
  1090. #parameter['name'] = parameter['name'][:30] + (parameter['name'][30:] and "...")
  1091. # -----------------------------------------------------------------
  1092. # Get width values, in packs of 10
  1093. if parameter['type'] == PARAMETER_INPUT:
  1094. paramInputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  1095. if paramInputWidthTMP > paramInputWidth:
  1096. paramInputWidth = paramInputWidthTMP
  1097. paramInputList.append(parameter)
  1098. if len(paramInputList) == 10:
  1099. paramInputListFull.append((paramInputList, paramInputWidth))
  1100. paramInputList = []
  1101. paramInputWidth = 0
  1102. else:
  1103. paramOutputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  1104. if paramOutputWidthTMP > paramOutputWidth:
  1105. paramOutputWidth = paramOutputWidthTMP
  1106. paramOutputList.append(parameter)
  1107. if len(paramOutputList) == 10:
  1108. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  1109. paramOutputList = []
  1110. paramOutputWidth = 0
  1111. # for i in range(parameterCount)
  1112. else:
  1113. # Final page width values
  1114. if 0 < len(paramInputList) < 10:
  1115. paramInputListFull.append((paramInputList, paramInputWidth))
  1116. if 0 < len(paramOutputList) < 10:
  1117. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  1118. # -----------------------------------------------------------------
  1119. # Create parameter tabs + widgets
  1120. self._createParameterWidgets(PARAMETER_INPUT, paramInputListFull, self.tr("Parameters"))
  1121. self._createParameterWidgets(PARAMETER_OUTPUT, paramOutputListFull, self.tr("Outputs"))
  1122. else: # > Carla.maxParameters
  1123. fakeName = self.tr("This plugin has too many parameters to display here!")
  1124. paramFakeListFull = []
  1125. paramFakeList = []
  1126. paramFakeWidth = QFontMetrics(self.font()).width(fakeName)
  1127. parameter = {
  1128. 'type': PARAMETER_UNKNOWN,
  1129. 'hints': 0,
  1130. 'name': fakeName,
  1131. 'unit': "",
  1132. 'scalePoints': [],
  1133. 'index': 0,
  1134. 'default': 0.0,
  1135. 'minimum': 0.0,
  1136. 'maximum': 0.0,
  1137. 'step': 0.0,
  1138. 'stepSmall': 0.0,
  1139. 'stepLarge': 0.0,
  1140. 'midiCC': -1,
  1141. 'midiChannel': 1,
  1142. 'current': 0.0
  1143. }
  1144. paramFakeList.append(parameter)
  1145. paramFakeListFull.append((paramFakeList, paramFakeWidth))
  1146. self._createParameterWidgets(PARAMETER_UNKNOWN, paramFakeListFull, self.tr("Information"))
  1147. def reloadPrograms(self):
  1148. # Programs
  1149. self.ui.cb_programs.blockSignals(True)
  1150. self.ui.cb_programs.clear()
  1151. programCount = Carla.host.get_program_count(self.fPluginId)
  1152. if programCount > 0:
  1153. self.ui.cb_programs.setEnabled(True)
  1154. self.ui.label_programs.setEnabled(True)
  1155. for i in range(programCount):
  1156. pName = cString(Carla.host.get_program_name(self.fPluginId, i))
  1157. #pName = pName[:40] + (pName[40:] and "...")
  1158. self.ui.cb_programs.addItem(pName)
  1159. self.fCurrentProgram = Carla.host.get_current_program_index(self.fPluginId)
  1160. self.ui.cb_programs.setCurrentIndex(self.fCurrentProgram)
  1161. else:
  1162. self.fCurrentProgram = -1
  1163. self.ui.cb_programs.setEnabled(False)
  1164. self.ui.label_programs.setEnabled(False)
  1165. self.ui.cb_programs.blockSignals(False)
  1166. # MIDI Programs
  1167. self.ui.cb_midi_programs.blockSignals(True)
  1168. self.ui.cb_midi_programs.clear()
  1169. midiProgramCount = Carla.host.get_midi_program_count(self.fPluginId)
  1170. if midiProgramCount > 0:
  1171. self.ui.cb_midi_programs.setEnabled(True)
  1172. self.ui.label_midi_programs.setEnabled(True)
  1173. for i in range(midiProgramCount):
  1174. mpData = Carla.host.get_midi_program_data(self.fPluginId, i)
  1175. mpBank = int(mpData['bank'])
  1176. mpProg = int(mpData['program'])
  1177. mpName = cString(mpData['name'])
  1178. #mpName = mpName[:40] + (mpName[40:] and "...")
  1179. self.ui.cb_midi_programs.addItem("%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  1180. self.fCurrentMidiProgram = Carla.host.get_current_midi_program_index(self.fPluginId)
  1181. self.ui.cb_midi_programs.setCurrentIndex(self.fCurrentMidiProgram)
  1182. else:
  1183. self.fCurrentMidiProgram = -1
  1184. self.ui.cb_midi_programs.setEnabled(False)
  1185. self.ui.label_midi_programs.setEnabled(False)
  1186. self.ui.cb_midi_programs.blockSignals(False)
  1187. if self.fPluginInfo['type'] == PLUGIN_LV2:
  1188. self.ui.b_load_state.setEnabled(programCount > 0)
  1189. def updateInfo(self):
  1190. # Update current program text
  1191. if self.ui.cb_programs.count() > 0:
  1192. pIndex = self.ui.cb_programs.currentIndex()
  1193. pName = cString(Carla.host.get_program_name(self.fPluginId, pIndex))
  1194. #pName = pName[:40] + (pName[40:] and "...")
  1195. self.ui.cb_programs.setItemText(pIndex, pName)
  1196. # Update current midi program text
  1197. if self.ui.cb_midi_programs.count() > 0:
  1198. mpIndex = self.ui.cb_midi_programs.currentIndex()
  1199. mpData = Carla.host.get_midi_program_data(self.fPluginId, mpIndex)
  1200. mpBank = int(mpData['bank'])
  1201. mpProg = int(mpData['program'])
  1202. mpName = cString(mpData['name'])
  1203. #mpName = mpName[:40] + (mpName[40:] and "...")
  1204. self.ui.cb_midi_programs.setItemText(mpIndex, "%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  1205. # Update all parameter values
  1206. for paramType, paramId, paramWidget in self.fParameterList:
  1207. paramWidget.setValue(Carla.host.get_current_parameter_value(self.fPluginId, paramId), False)
  1208. paramWidget.update()
  1209. self.fParametersToUpdate = []
  1210. def clearNotes(self):
  1211. self.fPlayingNotes = []
  1212. self.ui.keyboard.allNotesOff()
  1213. def setParameterValue(self, parameterId, value):
  1214. for paramItem in self.fParametersToUpdate:
  1215. if paramItem[0] == parameterId:
  1216. paramItem[1] = value
  1217. break
  1218. else:
  1219. self.fParametersToUpdate.append([parameterId, value])
  1220. def setParameterDefault(self, parameterId, value):
  1221. for paramType, paramId, paramWidget in self.fParameterList:
  1222. if paramId == parameterId:
  1223. paramWidget.setDefault(value)
  1224. break
  1225. def setParameterMidiControl(self, parameterId, control):
  1226. for paramType, paramId, paramWidget in self.fParameterList:
  1227. if paramId == parameterId:
  1228. paramWidget.setMidiControl(control)
  1229. break
  1230. def setParameterMidiChannel(self, parameterId, channel):
  1231. for paramType, paramId, paramWidget in self.fParameterList:
  1232. if paramId == parameterId:
  1233. paramWidget.setMidiChannel(channel+1)
  1234. break
  1235. def setProgram(self, index):
  1236. self.ui.cb_programs.blockSignals(True)
  1237. self.ui.cb_programs.setCurrentIndex(index)
  1238. self.ui.cb_programs.blockSignals(False)
  1239. def setMidiProgram(self, index):
  1240. self.ui.cb_midi_programs.blockSignals(True)
  1241. self.ui.cb_midi_programs.setCurrentIndex(index)
  1242. self.ui.cb_midi_programs.blockSignals(False)
  1243. def sendNoteOn(self, channel, note):
  1244. if self.fControlChannel == channel:
  1245. self.ui.keyboard.sendNoteOn(note, False)
  1246. if len(self.fPlayingNotes) == 0 and self.fRealParent:
  1247. self.fRealParent.ui.led_midi.setChecked(True)
  1248. playItem = (channel, note)
  1249. if playItem not in self.fPlayingNotes:
  1250. self.fPlayingNotes.append(playItem)
  1251. def sendNoteOff(self, channel, note):
  1252. if self.fControlChannel == channel:
  1253. self.ui.keyboard.sendNoteOff(note, False)
  1254. if len(self.fPlayingNotes) == 1 and self.fRealParent:
  1255. self.fRealParent.ui.led_midi.setChecked(False)
  1256. playItem = (channel, note)
  1257. if playItem in self.fPlayingNotes:
  1258. self.fPlayingNotes.remove(playItem)
  1259. def setVisible(self, yesNo):
  1260. if yesNo:
  1261. if not self.fGeometry.isNull():
  1262. self.restoreGeometry(self.fGeometry)
  1263. else:
  1264. self.fGeometry = self.saveGeometry()
  1265. QDialog.setVisible(self, yesNo)
  1266. def idleSlow(self):
  1267. # Check Tab icons
  1268. for i in range(len(self.fTabIconTimers)):
  1269. if self.fTabIconTimers[i] == ICON_STATE_ON:
  1270. self.fTabIconTimers[i] = ICON_STATE_WAIT
  1271. elif self.fTabIconTimers[i] == ICON_STATE_WAIT:
  1272. self.fTabIconTimers[i] = ICON_STATE_OFF
  1273. elif self.fTabIconTimers[i] == ICON_STATE_OFF:
  1274. self.fTabIconTimers[i] = ICON_STATE_NULL
  1275. self.ui.tabWidget.setTabIcon(i+1, self.fTabIconOff)
  1276. # Check parameters needing update
  1277. for index, value in self.fParametersToUpdate:
  1278. if index == PARAMETER_DRYWET:
  1279. self.ui.dial_drywet.blockSignals(True)
  1280. self.ui.dial_drywet.setValue(value * 1000)
  1281. self.ui.dial_drywet.blockSignals(False)
  1282. elif index == PARAMETER_VOLUME:
  1283. self.ui.dial_vol.blockSignals(True)
  1284. self.ui.dial_vol.setValue(value * 1000)
  1285. self.ui.dial_vol.blockSignals(False)
  1286. elif index == PARAMETER_BALANCE_LEFT:
  1287. self.ui.dial_b_left.blockSignals(True)
  1288. self.ui.dial_b_left.setValue(value * 1000)
  1289. self.ui.dial_b_left.blockSignals(False)
  1290. elif index == PARAMETER_BALANCE_RIGHT:
  1291. self.ui.dial_b_right.blockSignals(True)
  1292. self.ui.dial_b_right.setValue(value * 1000)
  1293. self.ui.dial_b_right.blockSignals(False)
  1294. #elif index == PARAMETER_PANNING:
  1295. #self.ui.dial_pan.blockSignals(True)
  1296. #self.ui.dial_pan.setValue(value * 1000, True, False)
  1297. #self.ui.dial_pan.blockSignals(False)
  1298. elif index == PARAMETER_CTRL_CHANNEL:
  1299. self.fControlChannel = int(value)
  1300. self.ui.sb_ctrl_channel.blockSignals(True)
  1301. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  1302. self.ui.sb_ctrl_channel.blockSignals(False)
  1303. self.ui.keyboard.allNotesOff()
  1304. self._updateCtrlMidiProgram()
  1305. elif index >= 0:
  1306. for paramType, paramId, paramWidget in self.fParameterList:
  1307. if paramId != index:
  1308. continue
  1309. paramWidget.setValue(value, False)
  1310. if paramType == PARAMETER_INPUT:
  1311. tabIndex = paramWidget.tabIndex()
  1312. if self.fTabIconTimers[tabIndex-1] == ICON_STATE_NULL:
  1313. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOn)
  1314. self.fTabIconTimers[tabIndex-1] = ICON_STATE_ON
  1315. break
  1316. # Clear all parameters
  1317. self.fParametersToUpdate = []
  1318. # Update parameter outputs
  1319. for paramType, paramId, paramWidget in self.fParameterList:
  1320. if paramType == PARAMETER_OUTPUT:
  1321. value = Carla.host.get_current_parameter_value(self.fPluginId, paramId)
  1322. paramWidget.setValue(value, False)
  1323. @pyqtSlot()
  1324. def slot_stateSave(self):
  1325. if self.fPluginInfo['type'] == PLUGIN_LV2:
  1326. # TODO
  1327. return
  1328. if self.fCurrentStateFilename:
  1329. askTry = QMessageBox.question(self, self.tr("Overwrite?"), self.tr("Overwrite previously created file?"), QMessageBox.Ok|QMessageBox.Cancel)
  1330. if askTry == QMessageBox.Ok:
  1331. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1332. return
  1333. self.fCurrentStateFilename = None
  1334. fileFilter = self.tr("Carla State File (*.carxs)")
  1335. filenameTry = QFileDialog.getSaveFileName(self, self.tr("Save Plugin State File"), filter=fileFilter)
  1336. if filenameTry:
  1337. if not filenameTry.lower().endswith(".carxs"):
  1338. filenameTry += ".carxs"
  1339. self.fCurrentStateFilename = filenameTry
  1340. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1341. @pyqtSlot()
  1342. def slot_stateLoad(self):
  1343. if self.fPluginInfo['type'] == PLUGIN_LV2:
  1344. presetList = []
  1345. for i in range(Carla.host.get_program_count(self.fPluginId)):
  1346. presetList.append("%03i - %s" % (i+1, cString(Carla.host.get_program_name(self.fPluginId, i))))
  1347. ret = QInputDialog.getItem(self, self.tr("Open LV2 Preset"), self.tr("Select an LV2 Preset:"), presetList, 0, False)
  1348. if ret[1]:
  1349. index = int(ret[0].split(" - ", 1)[0])-1
  1350. Carla.host.set_midi_program(self.fPluginId, -1)
  1351. Carla.host.set_program(self.fPluginId, index)
  1352. self.setMidiProgram(-1)
  1353. return
  1354. fileFilter = self.tr("Carla State File (*.carxs)")
  1355. filenameTry = QFileDialog.getOpenFileName(self, self.tr("Open Plugin State File"), filter=fileFilter)
  1356. if filenameTry:
  1357. self.fCurrentStateFilename = filenameTry
  1358. Carla.host.load_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1359. @pyqtSlot(bool)
  1360. def slot_optionChanged(self, clicked):
  1361. sender = self.sender()
  1362. if sender == self.ui.ch_fixed_buffer:
  1363. option = PLUGIN_OPTION_FIXED_BUFFER
  1364. elif sender == self.ui.ch_force_stereo:
  1365. option = PLUGIN_OPTION_FORCE_STEREO
  1366. elif sender == self.ui.ch_map_program_changes:
  1367. option = PLUGIN_OPTION_MAP_PROGRAM_CHANGES
  1368. elif sender == self.ui.ch_use_chunks:
  1369. option = PLUGIN_OPTION_USE_CHUNKS
  1370. elif sender == self.ui.ch_send_control_changes:
  1371. option = PLUGIN_OPTION_SEND_CONTROL_CHANGES
  1372. elif sender == self.ui.ch_send_channel_pressure:
  1373. option = PLUGIN_OPTION_SEND_CHANNEL_PRESSURE
  1374. elif sender == self.ui.ch_send_note_aftertouch:
  1375. option = PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH
  1376. elif sender == self.ui.ch_send_pitchbend:
  1377. option = PLUGIN_OPTION_SEND_PITCHBEND
  1378. elif sender == self.ui.ch_send_all_sound_off:
  1379. option = PLUGIN_OPTION_SEND_ALL_SOUND_OFF
  1380. else:
  1381. return
  1382. Carla.host.set_option(self.fPluginId, option, clicked)
  1383. @pyqtSlot(int)
  1384. def slot_dryWetChanged(self, value):
  1385. Carla.host.set_drywet(self.fPluginId, float(value)/1000)
  1386. @pyqtSlot(int)
  1387. def slot_volumeChanged(self, value):
  1388. Carla.host.set_volume(self.fPluginId, float(value)/1000)
  1389. @pyqtSlot(int)
  1390. def slot_balanceLeftChanged(self, value):
  1391. Carla.host.set_balance_left(self.fPluginId, float(value)/1000)
  1392. @pyqtSlot(int)
  1393. def slot_balanceRightChanged(self, value):
  1394. Carla.host.set_balance_right(self.fPluginId, float(value)/1000)
  1395. @pyqtSlot(int)
  1396. def slot_panningChanged(self, value):
  1397. Carla.host.set_panning(self.fPluginId, float(value)/1000)
  1398. @pyqtSlot(int)
  1399. def slot_ctrlChannelChanged(self, value):
  1400. self.fControlChannel = value-1
  1401. Carla.host.set_ctrl_channel(self.fPluginId, self.fControlChannel)
  1402. self.ui.keyboard.allNotesOff()
  1403. self._updateCtrlMidiProgram()
  1404. @pyqtSlot(int, float)
  1405. def slot_parameterValueChanged(self, parameterId, value):
  1406. Carla.host.set_parameter_value(self.fPluginId, parameterId, value)
  1407. @pyqtSlot(int, int)
  1408. def slot_parameterMidiControlChanged(self, parameterId, control):
  1409. Carla.host.set_parameter_midi_cc(self.fPluginId, parameterId, control)
  1410. @pyqtSlot(int, int)
  1411. def slot_parameterMidiChannelChanged(self, parameterId, channel):
  1412. Carla.host.set_parameter_midi_channel(self.fPluginId, parameterId, channel-1)
  1413. @pyqtSlot(int)
  1414. def slot_programIndexChanged(self, index):
  1415. self.fCurrentProgram = index
  1416. Carla.host.set_program(self.fPluginId, index)
  1417. @pyqtSlot(int)
  1418. def slot_midiProgramIndexChanged(self, index):
  1419. self.fCurrentMidiProgram = index
  1420. Carla.host.set_midi_program(self.fPluginId, index)
  1421. @pyqtSlot(int)
  1422. def slot_noteOn(self, note):
  1423. if self.fControlChannel >= 0:
  1424. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 100)
  1425. @pyqtSlot(int)
  1426. def slot_noteOff(self, note):
  1427. if self.fControlChannel >= 0:
  1428. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 0)
  1429. @pyqtSlot()
  1430. def slot_finished(self):
  1431. if self.fRealParent:
  1432. self.fRealParent.editClosed()
  1433. @pyqtSlot()
  1434. def slot_knobCustomMenu(self):
  1435. dialName = self.sender().objectName()
  1436. if dialName == "dial_drywet":
  1437. minimum = 0
  1438. maximum = 100
  1439. default = 100
  1440. label = "Dry/Wet"
  1441. elif dialName == "dial_vol":
  1442. minimum = 0
  1443. maximum = 127
  1444. default = 100
  1445. label = "Volume"
  1446. elif dialName == "dial_b_left":
  1447. minimum = -100
  1448. maximum = 100
  1449. default = -100
  1450. label = "Balance-Left"
  1451. elif dialName == "dial_b_right":
  1452. minimum = -100
  1453. maximum = 100
  1454. default = 100
  1455. label = "Balance-Right"
  1456. elif dialName == "dial_panning":
  1457. minimum = -100
  1458. maximum = 100
  1459. default = 0
  1460. label = "Panning"
  1461. else:
  1462. minimum = 0
  1463. maximum = 100
  1464. default = 100
  1465. label = "Unknown"
  1466. current = self.sender().value() / 10
  1467. menu = QMenu(self)
  1468. actReset = menu.addAction(self.tr("Reset (%i%%)" % default))
  1469. menu.addSeparator()
  1470. actMinimum = menu.addAction(self.tr("Set to Minimum (%i%%)" % minimum))
  1471. actCenter = menu.addAction(self.tr("Set to Center"))
  1472. actMaximum = menu.addAction(self.tr("Set to Maximum (%i%%)" % maximum))
  1473. menu.addSeparator()
  1474. actSet = menu.addAction(self.tr("Set value..."))
  1475. if label not in ("Balance-Left", "Balance-Right"):
  1476. menu.removeAction(actCenter)
  1477. actSelected = menu.exec_(QCursor.pos())
  1478. if actSelected == actSet:
  1479. valueTry = QInputDialog.getInteger(self, self.tr("Set value"), label, current, minimum, maximum, 1)
  1480. if valueTry[1]:
  1481. value = valueTry[0] * 10
  1482. else:
  1483. return
  1484. elif actSelected == actMinimum:
  1485. value = minimum * 10
  1486. elif actSelected == actMaximum:
  1487. value = maximum * 10
  1488. elif actSelected == actReset:
  1489. value = default * 10
  1490. elif actSelected == actCenter:
  1491. value = 0
  1492. else:
  1493. return
  1494. if label == "Dry/Wet":
  1495. self.ui.dial_drywet.setValue(value)
  1496. elif label == "Volume":
  1497. self.ui.dial_vol.setValue(value)
  1498. elif label == "Balance-Left":
  1499. self.ui.dial_b_left.setValue(value)
  1500. elif label == "Balance-Right":
  1501. self.ui.dial_b_right.setValue(value)
  1502. #elif label == "Panning":
  1503. #self.ui.dial_panning.setValue(value)
  1504. @pyqtSlot()
  1505. def slot_channelCustomMenu(self):
  1506. menu = QMenu(self)
  1507. actNone = menu.addAction(self.tr("None"))
  1508. if self.fControlChannel+1 == 0:
  1509. actNone.setCheckable(True)
  1510. actNone.setChecked(True)
  1511. for i in range(1, 16+1):
  1512. action = menu.addAction("%i" % i)
  1513. if self.fControlChannel+1 == i:
  1514. action.setCheckable(True)
  1515. action.setChecked(True)
  1516. actSel = menu.exec_(QCursor.pos())
  1517. if not actSel:
  1518. pass
  1519. elif actSel == actNone:
  1520. self.ui.sb_ctrl_channel.setValue(0)
  1521. elif actSel:
  1522. selChannel = int(actSel.text())
  1523. self.ui.sb_ctrl_channel.setValue(selChannel)
  1524. def _createParameterWidgets(self, paramType, paramListFull, tabPageName):
  1525. i = 1
  1526. for paramList, width in paramListFull:
  1527. if len(paramList) == 0:
  1528. break
  1529. tabIndex = self.ui.tabWidget.count()
  1530. tabPageContainer = QWidget(self.ui.tabWidget)
  1531. tabPageLayout = QVBoxLayout(tabPageContainer)
  1532. tabPageContainer.setLayout(tabPageLayout)
  1533. for paramInfo in paramList:
  1534. paramWidget = PluginParameter(tabPageContainer, paramInfo, self.fPluginId, tabIndex)
  1535. paramWidget.setLabelWidth(width)
  1536. tabPageLayout.addWidget(paramWidget)
  1537. self.fParameterList.append((paramType, paramInfo['index'], paramWidget))
  1538. if paramType == PARAMETER_INPUT:
  1539. self.connect(paramWidget, SIGNAL("valueChanged(int, double)"), SLOT("slot_parameterValueChanged(int, double)"))
  1540. self.connect(paramWidget, SIGNAL("midiControlChanged(int, int)"), SLOT("slot_parameterMidiControlChanged(int, int)"))
  1541. self.connect(paramWidget, SIGNAL("midiChannelChanged(int, int)"), SLOT("slot_parameterMidiChannelChanged(int, int)"))
  1542. tabPageLayout.addStretch()
  1543. self.ui.tabWidget.addTab(tabPageContainer, "%s (%i)" % (tabPageName, i))
  1544. i += 1
  1545. if paramType == PARAMETER_INPUT:
  1546. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOff)
  1547. self.fTabIconTimers.append(ICON_STATE_NULL)
  1548. def _updateCtrlMidiProgram(self):
  1549. if self.fPluginInfo['type'] not in (PLUGIN_INTERNAL, PLUGIN_SF2):
  1550. return
  1551. elif not self.fPluginInfo['hints'] & PLUGIN_IS_SYNTH:
  1552. return
  1553. if self.fControlChannel < 0:
  1554. self.ui.cb_midi_programs.setEnabled(False)
  1555. return
  1556. self.ui.cb_midi_programs.setEnabled(True)
  1557. mpIndex = Carla.host.get_current_midi_program_index(self.fPluginId)
  1558. if self.ui.cb_midi_programs.currentIndex() != mpIndex:
  1559. self.setMidiProgram(mpIndex)
  1560. def showEvent(self, event):
  1561. if not self.fScrollAreaSetup:
  1562. self.fScrollAreaSetup = True
  1563. minHeight = self.ui.scrollArea.height()+2
  1564. self.ui.scrollArea.setMinimumHeight(minHeight)
  1565. self.ui.scrollArea.setMaximumHeight(minHeight)
  1566. QDialog.showEvent(self, event)
  1567. def done(self, r):
  1568. QDialog.done(self, r)
  1569. self.close()
  1570. # ------------------------------------------------------------------------------------------------------------
  1571. # Plugin Widget
  1572. class PluginWidget(QFrame):
  1573. def __init__(self, parent, pluginId):
  1574. QFrame.__init__(self, parent)
  1575. self.ui = ui_carla_plugin.Ui_PluginWidget()
  1576. self.ui.setupUi(self)
  1577. # -------------------------------------------------------------
  1578. # Internal stuff
  1579. self.fPluginId = pluginId
  1580. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId)
  1581. self.fPluginInfo['binary'] = cString(self.fPluginInfo['binary'])
  1582. self.fPluginInfo['name'] = cString(self.fPluginInfo['name'])
  1583. self.fPluginInfo['label'] = cString(self.fPluginInfo['label'])
  1584. self.fPluginInfo['maker'] = cString(self.fPluginInfo['maker'])
  1585. self.fPluginInfo['copyright'] = cString(self.fPluginInfo['copyright'])
  1586. self.fPluginInfo['iconName'] = cString(self.fPluginInfo['iconName'])
  1587. if not Carla.isLocal:
  1588. self.fPluginInfo['hints'] &= ~PLUGIN_HAS_GUI
  1589. self.fLastGreenLedState = False
  1590. self.fLastBlueLedState = False
  1591. self.fParameterIconTimer = ICON_STATE_NULL
  1592. if Carla.processMode == PROCESS_MODE_CONTINUOUS_RACK:
  1593. self.fPeaksInputCount = 2
  1594. self.fPeaksOutputCount = 2
  1595. else:
  1596. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  1597. self.fPeaksInputCount = int(audioCountInfo['ins'])
  1598. self.fPeaksOutputCount = int(audioCountInfo['outs'])
  1599. if self.fPeaksInputCount > 2:
  1600. self.fPeaksInputCount = 2
  1601. if self.fPeaksOutputCount > 2:
  1602. self.fPeaksOutputCount = 2
  1603. if self.palette().window().color().lightness() > 100:
  1604. # Light background
  1605. labelColor = "333"
  1606. isLight = True
  1607. self.fColorTop = QColor(60, 60, 60)
  1608. self.fColorBottom = QColor(47, 47, 47)
  1609. self.fColorSeprtr = QColor(70, 70, 70)
  1610. else:
  1611. # Dark background
  1612. labelColor = "BBB"
  1613. isLight = False
  1614. self.fColorTop = QColor(60, 60, 60)
  1615. self.fColorBottom = QColor(47, 47, 47)
  1616. self.fColorSeprtr = QColor(70, 70, 70)
  1617. # -------------------------------------------------------------
  1618. # Set-up GUI
  1619. self.setStyleSheet("""
  1620. QLabel#label_name {
  1621. color: #%s;
  1622. }""" % labelColor)
  1623. if isLight:
  1624. self.ui.b_enable.setPixmaps(":/bitmaps/button_off2.png", ":/bitmaps/button_on2.png", ":/bitmaps/button_off2.png")
  1625. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit2.png", ":/bitmaps/button_edit_down2.png", ":/bitmaps/button_edit_hover2.png")
  1626. if self.fPluginInfo['iconName'] == "distrho":
  1627. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho2.png", ":/bitmaps/button_distrho_down2.png", ":/bitmaps/button_distrho_hover2.png")
  1628. elif self.fPluginInfo['iconName'] == "file":
  1629. self.ui.b_gui.setPixmaps(":/bitmaps/button_file2.png", ":/bitmaps/button_file_down2.png", ":/bitmaps/button_file_hover2.png")
  1630. else:
  1631. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui2.png", ":/bitmaps/button_gui_down2.png", ":/bitmaps/button_gui_hover2.png")
  1632. else:
  1633. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  1634. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  1635. if self.fPluginInfo['iconName'] == "distrho":
  1636. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  1637. elif self.fPluginInfo['iconName'] == "file":
  1638. self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  1639. else:
  1640. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  1641. self.ui.led_control.setColor(self.ui.led_control.YELLOW)
  1642. self.ui.led_control.setEnabled(False)
  1643. self.ui.led_midi.setColor(self.ui.led_midi.RED)
  1644. self.ui.led_midi.setEnabled(False)
  1645. self.ui.led_audio_in.setColor(self.ui.led_audio_in.GREEN)
  1646. self.ui.led_audio_in.setEnabled(False)
  1647. self.ui.led_audio_out.setColor(self.ui.led_audio_out.BLUE)
  1648. self.ui.led_audio_out.setEnabled(False)
  1649. self.ui.peak_in.setColor(self.ui.peak_in.GREEN)
  1650. self.ui.peak_in.setChannels(self.fPeaksInputCount)
  1651. self.ui.peak_in.setOrientation(self.ui.peak_in.HORIZONTAL)
  1652. self.ui.peak_out.setColor(self.ui.peak_in.BLUE)
  1653. self.ui.peak_out.setChannels(self.fPeaksOutputCount)
  1654. self.ui.peak_out.setOrientation(self.ui.peak_out.HORIZONTAL)
  1655. self.ui.label_name.setText(self.fPluginInfo['name'])
  1656. self.ui.edit_dialog = PluginEdit(self, self.fPluginId)
  1657. self.ui.edit_dialog.hide()
  1658. self.setMinimumHeight(32)
  1659. self.setMaximumHeight(32)
  1660. # -------------------------------------------------------------
  1661. # Set-up connections
  1662. self.connect(self, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomMenu()"))
  1663. self.connect(self.ui.b_enable, SIGNAL("clicked(bool)"), SLOT("slot_enableClicked(bool)"))
  1664. self.connect(self.ui.b_gui, SIGNAL("clicked(bool)"), SLOT("slot_guiClicked(bool)"))
  1665. self.connect(self.ui.b_edit, SIGNAL("clicked(bool)"), SLOT("slot_editClicked(bool)"))
  1666. # -------------------------------------------------------------
  1667. def idleFast(self):
  1668. # Input peaks
  1669. if self.fPeaksInputCount > 0:
  1670. if self.fPeaksInputCount > 1:
  1671. peak1 = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1672. peak2 = Carla.host.get_input_peak_value(self.fPluginId, 2)
  1673. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1674. self.ui.peak_in.displayMeter(1, peak1)
  1675. self.ui.peak_in.displayMeter(2, peak2)
  1676. else:
  1677. peak = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1678. ledState = bool(peak != 0.0)
  1679. self.ui.peak_in.displayMeter(1, peak)
  1680. if self.fLastGreenLedState != ledState:
  1681. self.fLastGreenLedState = ledState
  1682. self.ui.led_audio_in.setChecked(ledState)
  1683. # Output peaks
  1684. if self.fPeaksOutputCount > 0:
  1685. if self.fPeaksOutputCount > 1:
  1686. peak1 = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1687. peak2 = Carla.host.get_output_peak_value(self.fPluginId, 2)
  1688. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1689. self.ui.peak_out.displayMeter(1, peak1)
  1690. self.ui.peak_out.displayMeter(2, peak2)
  1691. else:
  1692. peak = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1693. ledState = bool(peak != 0.0)
  1694. self.ui.peak_out.displayMeter(1, peak)
  1695. if self.fLastBlueLedState != ledState:
  1696. self.fLastBlueLedState = ledState
  1697. self.ui.led_audio_out.setChecked(ledState)
  1698. def idleSlow(self):
  1699. # Parameter Activity LED
  1700. if self.fParameterIconTimer == ICON_STATE_ON:
  1701. self.fParameterIconTimer = ICON_STATE_WAIT
  1702. self.ui.led_control.setChecked(True)
  1703. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  1704. self.fParameterIconTimer = ICON_STATE_OFF
  1705. elif self.fParameterIconTimer == ICON_STATE_OFF:
  1706. self.fParameterIconTimer = ICON_STATE_NULL
  1707. self.ui.led_control.setChecked(False)
  1708. # Update edit dialog
  1709. self.ui.edit_dialog.idleSlow()
  1710. def editClosed(self):
  1711. self.ui.b_edit.setChecked(False)
  1712. def recheckPluginHints(self, hints):
  1713. self.fPluginInfo['hints'] = hints
  1714. self.ui.b_gui.setEnabled(hints & PLUGIN_HAS_GUI)
  1715. def setActive(self, active, sendGui=False, sendCallback=True):
  1716. if sendGui: self.ui.b_enable.setChecked(active)
  1717. if sendCallback: Carla.host.set_active(self.fPluginId, active)
  1718. if active:
  1719. self.ui.edit_dialog.clearNotes()
  1720. self.ui.led_midi.setChecked(False)
  1721. def setParameterDefault(self, parameterId, value):
  1722. self.ui.edit_dialog.setParameterDefault(parameterId, value)
  1723. def setParameterValue(self, parameterId, value):
  1724. self.fParameterIconTimer = ICON_STATE_ON
  1725. if parameterId == PARAMETER_ACTIVE:
  1726. return self.setActive(bool(value), True, False)
  1727. self.ui.edit_dialog.setParameterValue(parameterId, value)
  1728. def setParameterMidiControl(self, parameterId, control):
  1729. self.ui.edit_dialog.setParameterMidiControl(parameterId, control)
  1730. def setParameterMidiChannel(self, parameterId, channel):
  1731. self.ui.edit_dialog.setParameterMidiChannel(parameterId, channel)
  1732. def setProgram(self, index):
  1733. self.fParameterIconTimer = ICON_STATE_ON
  1734. self.ui.edit_dialog.setProgram(index)
  1735. def setMidiProgram(self, index):
  1736. self.fParameterIconTimer = ICON_STATE_ON
  1737. self.ui.edit_dialog.setMidiProgram(index)
  1738. def sendNoteOn(self, channel, note):
  1739. self.ui.edit_dialog.sendNoteOn(channel, note)
  1740. def sendNoteOff(self, channel, note):
  1741. self.ui.edit_dialog.sendNoteOff(channel, note)
  1742. def setId(self, idx):
  1743. self.fPluginId = idx
  1744. self.ui.edit_dialog.fPluginId = idx
  1745. @pyqtSlot()
  1746. def slot_showCustomMenu(self):
  1747. menu = QMenu(self)
  1748. actActive = menu.addAction(self.tr("Disable") if self.ui.b_enable.isChecked() else self.tr("Enable"))
  1749. menu.addSeparator()
  1750. actGui = menu.addAction(self.tr("Show GUI"))
  1751. actGui.setCheckable(True)
  1752. actGui.setChecked(self.ui.b_gui.isChecked())
  1753. actGui.setEnabled(self.ui.b_gui.isEnabled())
  1754. actEdit = menu.addAction(self.tr("Edit"))
  1755. actEdit.setCheckable(True)
  1756. actEdit.setChecked(self.ui.b_edit.isChecked())
  1757. menu.addSeparator()
  1758. actClone = menu.addAction(self.tr("Clone"))
  1759. actRename = menu.addAction(self.tr("Rename..."))
  1760. actRemove = menu.addAction(self.tr("Remove"))
  1761. actSel = menu.exec_(QCursor.pos())
  1762. if not actSel:
  1763. return
  1764. if actSel == actActive:
  1765. self.setActive(not self.ui.b_enable.isChecked(), True, True)
  1766. elif actSel == actGui:
  1767. self.ui.b_gui.click()
  1768. elif actSel == actEdit:
  1769. self.ui.b_edit.click()
  1770. elif actSel == actClone:
  1771. if not Carla.host.clone_plugin(self.fPluginId):
  1772. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  1773. cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  1774. elif actSel == actRename:
  1775. oldName = self.fPluginInfo['name']
  1776. newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName)
  1777. if not (newNameTry[1] and newNameTry[0] and oldName != newNameTry[0]):
  1778. return
  1779. newName = newNameTry[0]
  1780. if Carla.host.rename_plugin(self.fPluginId, newName):
  1781. self.fPluginInfo['name'] = newName
  1782. self.ui.edit_dialog.fPluginInfo['name'] = newName
  1783. self.ui.edit_dialog.reloadInfo()
  1784. self.ui.label_name.setText(newName)
  1785. else:
  1786. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  1787. cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  1788. elif actSel == actRemove:
  1789. if not Carla.host.remove_plugin(self.fPluginId):
  1790. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  1791. cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  1792. @pyqtSlot(bool)
  1793. def slot_enableClicked(self, yesNo):
  1794. self.setActive(yesNo, False, True)
  1795. @pyqtSlot(bool)
  1796. def slot_guiClicked(self, show):
  1797. Carla.host.show_gui(self.fPluginId, show)
  1798. @pyqtSlot(bool)
  1799. def slot_editClicked(self, show):
  1800. self.ui.edit_dialog.setVisible(show)
  1801. def paintEvent(self, event):
  1802. painter = QPainter(self)
  1803. painter.save()
  1804. areaX = self.ui.area_right.x()+7
  1805. painter.setPen(self.fColorSeprtr.lighter(110))
  1806. painter.setBrush(self.fColorBottom)
  1807. painter.setRenderHint(QPainter.Antialiasing, True)
  1808. # name -> leds arc
  1809. path = QPainterPath()
  1810. path.moveTo(areaX-20, self.height()-4)
  1811. path.cubicTo(areaX, self.height()-5, areaX-20, 4.75, areaX, 4.75)
  1812. path.lineTo(areaX, self.height()-5)
  1813. painter.drawPath(path)
  1814. painter.setPen(self.fColorSeprtr)
  1815. painter.setRenderHint(QPainter.Antialiasing, False)
  1816. # separator lines
  1817. painter.drawLine(0, self.height()-5, areaX-20, self.height()-5)
  1818. painter.drawLine(areaX, 4, self.width(), 4)
  1819. painter.setPen(self.fColorBottom)
  1820. painter.setBrush(self.fColorBottom)
  1821. # top, bottom and left lines
  1822. painter.drawLine(0, 0, self.width(), 0)
  1823. painter.drawRect(0, self.height()-4, areaX, 4)
  1824. painter.drawRoundedRect(areaX-20, self.height()-5, areaX, 5, 22, 22)
  1825. painter.drawLine(0, 0, 0, self.height())
  1826. # fill the rest
  1827. painter.drawRect(areaX-1, 5, self.width(), self.height())
  1828. # bottom 1px line
  1829. painter.setPen(self.fColorSeprtr)
  1830. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  1831. painter.restore()
  1832. QFrame.paintEvent(self, event)
  1833. # ------------------------------------------------------------------------------------------------------------
  1834. # Separate Thread for Plugin Search
  1835. class SearchPluginsThread(QThread):
  1836. def __init__(self, parent):
  1837. QThread.__init__(self, parent)
  1838. self.fCheckNative = False
  1839. self.fCheckPosix32 = False
  1840. self.fCheckPosix64 = False
  1841. self.fCheckWin32 = False
  1842. self.fCheckWin64 = False
  1843. self.fCheckLADSPA = False
  1844. self.fCheckDSSI = False
  1845. self.fCheckLV2 = False
  1846. self.fCheckVST = False
  1847. self.fCheckGIG = False
  1848. self.fCheckSF2 = False
  1849. self.fCheckSFZ = False
  1850. self.fToolNative = carla_discovery_native
  1851. self.fCurCount = 0
  1852. self.fCurPercentValue = 0
  1853. self.fLastCheckValue = 0
  1854. self.fSomethingChanged = False
  1855. self.fLadspaPlugins = []
  1856. self.fDssiPlugins = []
  1857. self.fLv2Plugins = []
  1858. self.fVstPlugins = []
  1859. self.fKitPlugins = []
  1860. # -------------------------------------------------------------
  1861. def somethingChanged(self):
  1862. return self.fSomethingChanged
  1863. def skipPlugin(self):
  1864. # TODO - windows and mac support
  1865. apps = " carla-discovery"
  1866. apps += " carla-discovery-native"
  1867. apps += " carla-discovery-posix32"
  1868. apps += " carla-discovery-posix64"
  1869. apps += " carla-discovery-win32.exe"
  1870. apps += " carla-discovery-win64.exe"
  1871. if LINUX:
  1872. os.system("killall -KILL %s" % apps)
  1873. def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64):
  1874. self.fCheckNative = native
  1875. self.fCheckPosix32 = posix32
  1876. self.fCheckPosix64 = posix64
  1877. self.fCheckWin32 = win32
  1878. self.fCheckWin64 = win64
  1879. def setSearchPluginTypes(self, ladspa, dssi, lv2, vst, gig, sf2, sfz):
  1880. self.fCheckLADSPA = ladspa
  1881. self.fCheckDSSI = dssi
  1882. self.fCheckLV2 = lv2
  1883. self.fCheckVST = vst
  1884. self.fCheckGIG = gig
  1885. self.fCheckSF2 = sf2
  1886. self.fCheckSFZ = sfz
  1887. def setSearchToolNative(self, tool):
  1888. self.fToolNative = tool
  1889. def run(self):
  1890. self.fCurCount = 0
  1891. pluginCount = 0
  1892. settingsDB = QSettings("falkTX", "CarlaPlugins")
  1893. if self.fCheckLADSPA: pluginCount += 1
  1894. if self.fCheckDSSI: pluginCount += 1
  1895. if self.fCheckLV2: pluginCount += 1
  1896. if self.fCheckVST: pluginCount += 1
  1897. if self.fCheckNative:
  1898. self.fCurCount += pluginCount
  1899. if self.fCheckPosix32:
  1900. self.fCurCount += pluginCount
  1901. if self.fCheckPosix64:
  1902. self.fCurCount += pluginCount
  1903. if self.fCheckWin32:
  1904. self.fCurCount += pluginCount
  1905. if self.fCheckWin64:
  1906. self.fCurCount += pluginCount
  1907. if self.fToolNative:
  1908. if self.fCheckGIG: self.fCurCount += 1
  1909. if self.fCheckSF2: self.fCurCount += 1
  1910. if self.fCheckSFZ: self.fCurCount += 1
  1911. else:
  1912. self.fCheckGIG = False
  1913. self.fCheckSF2 = False
  1914. self.fCheckSFZ = False
  1915. if self.fCurCount == 0:
  1916. return
  1917. self.fCurPercentValue = 100 / self.fCurCount
  1918. self.fLastCheckValue = 0
  1919. if HAIKU:
  1920. OS = "HAIKU"
  1921. elif LINUX:
  1922. OS = "LINUX"
  1923. elif MACOS:
  1924. OS = "MACOS"
  1925. elif WINDOWS:
  1926. OS = "WINDOWS"
  1927. else:
  1928. OS = "UNKNOWN"
  1929. if self.fCheckLADSPA:
  1930. checkValue = 0
  1931. if haveLRDF:
  1932. if self.fCheckNative: checkValue += 0.1
  1933. if self.fCheckPosix32: checkValue += 0.1
  1934. if self.fCheckPosix64: checkValue += 0.1
  1935. if self.fCheckWin32: checkValue += 0.1
  1936. if self.fCheckWin64: checkValue += 0.1
  1937. rdfPadValue = self.fCurPercentValue * checkValue
  1938. if self.fCheckNative:
  1939. self._checkLADSPA(OS, self.fToolNative)
  1940. settingsDB.setValue("Plugins/LADSPA_native", self.fLadspaPlugins)
  1941. if self.fCheckPosix32:
  1942. self._checkLADSPA(OS, carla_discovery_posix32)
  1943. settingsDB.setValue("Plugins/LADSPA_posix32", self.fLadspaPlugins)
  1944. if self.fCheckPosix64:
  1945. self._checkLADSPA(OS, carla_discovery_posix64)
  1946. settingsDB.setValue("Plugins/LADSPA_posix64", self.fLadspaPlugins)
  1947. if self.fCheckWin32:
  1948. self._checkLADSPA("WINDOWS", carla_discovery_win32, not WINDOWS)
  1949. settingsDB.setValue("Plugins/LADSPA_win32", self.fLadspaPlugins)
  1950. if self.fCheckWin64:
  1951. self._checkLADSPA("WINDOWS", carla_discovery_win64, not WINDOWS)
  1952. settingsDB.setValue("Plugins/LADSPA_win64", self.fLadspaPlugins)
  1953. if haveLRDF and checkValue > 0:
  1954. startValue = self.fLastCheckValue - rdfPadValue
  1955. self._pluginLook(startValue, "LADSPA RDFs...")
  1956. ladspaRdfInfo = ladspa_rdf.recheck_all_plugins(self, startValue, self.fCurPercentValue, checkValue)
  1957. SettingsDir = os.path.join(HOME, ".config", "falkTX")
  1958. fLadspa = open(os.path.join(SettingsDir, "ladspa_rdf.db"), 'w')
  1959. json.dump(ladspaRdfInfo, fLadspa)
  1960. fLadspa.close()
  1961. if self.fCheckDSSI:
  1962. if self.fCheckNative:
  1963. self._checkDSSI(OS, self.fToolNative)
  1964. settingsDB.setValue("Plugins/DSSI_native", self.fDssiPlugins)
  1965. if self.fCheckPosix32:
  1966. self._checkDSSI(OS, carla_discovery_posix32)
  1967. settingsDB.setValue("Plugins/DSSI_posix32", self.fDssiPlugins)
  1968. if self.fCheckPosix64:
  1969. self._checkDSSI(OS, carla_discovery_posix64)
  1970. settingsDB.setValue("Plugins/DSSI_posix64", self.fDssiPlugins)
  1971. if self.fCheckWin32:
  1972. self._checkDSSI("WINDOWS", carla_discovery_win32, not WINDOWS)
  1973. settingsDB.setValue("Plugins/DSSI_win32", self.fDssiPlugins)
  1974. if self.fCheckWin64:
  1975. self._checkDSSI("WINDOWS", carla_discovery_win64, not WINDOWS)
  1976. settingsDB.setValue("Plugins/DSSI_win64", self.fDssiPlugins)
  1977. if self.fCheckLV2:
  1978. if self.fCheckNative:
  1979. self._checkLV2(self.fToolNative)
  1980. settingsDB.setValue("Plugins/LV2_native", self.fLv2Plugins)
  1981. if self.fCheckPosix32:
  1982. self._checkLV2(carla_discovery_posix32)
  1983. settingsDB.setValue("Plugins/LV2_posix32", self.fLv2Plugins)
  1984. if self.fCheckPosix64:
  1985. self._checkLV2(carla_discovery_posix64)
  1986. settingsDB.setValue("Plugins/LV2_posix64", self.fLv2Plugins)
  1987. if self.fCheckWin32:
  1988. self._checkLV2(carla_discovery_win32, not WINDOWS)
  1989. settingsDB.setValue("Plugins/LV2_win32", self.fLv2Plugins)
  1990. if self.fCheckWin64:
  1991. self._checkLV2(carla_discovery_win64, not WINDOWS)
  1992. settingsDB.setValue("Plugins/LV2_win64", self.fLv2Plugins)
  1993. if self.fCheckVST:
  1994. if self.fCheckNative:
  1995. self._checkVST(OS, self.fToolNative)
  1996. settingsDB.setValue("Plugins/VST_native", self.fVstPlugins)
  1997. if self.fCheckPosix32:
  1998. self._checkVST(OS, carla_discovery_posix32)
  1999. settingsDB.setValue("Plugins/VST_posix32", self.fVstPlugins)
  2000. if self.fCheckPosix64:
  2001. self._checkVST(OS, carla_discovery_posix64)
  2002. settingsDB.setValue("Plugins/VST_posix64", self.fVstPlugins)
  2003. if self.fCheckWin32:
  2004. self._checkVST("WINDOWS", carla_discovery_win32, not WINDOWS)
  2005. settingsDB.setValue("Plugins/VST_win32", self.fVstPlugins)
  2006. if self.fCheckWin64:
  2007. self._checkVST("WINDOWS", carla_discovery_win64, not WINDOWS)
  2008. settingsDB.setValue("Plugins/VST_win64", self.fVstPlugins)
  2009. if self.fCheckGIG:
  2010. self._checkKIT(Carla.GIG_PATH, "gig")
  2011. settingsDB.setValue("Plugins/GIG", self.fKitPlugins)
  2012. if self.fCheckSF2:
  2013. self._checkKIT(Carla.SF2_PATH, "sf2")
  2014. settingsDB.setValue("Plugins/SF2", self.fKitPlugins)
  2015. if self.fCheckSFZ:
  2016. self._checkKIT(Carla.SFZ_PATH, "sfz")
  2017. settingsDB.setValue("Plugins/SFZ", self.fKitPlugins)
  2018. settingsDB.sync()
  2019. def _checkLADSPA(self, OS, tool, isWine=False):
  2020. ladspaBinaries = []
  2021. self.fLadspaPlugins = []
  2022. for iPATH in Carla.LADSPA_PATH:
  2023. binaries = findBinaries(iPATH, OS)
  2024. for binary in binaries:
  2025. if binary not in ladspaBinaries:
  2026. ladspaBinaries.append(binary)
  2027. ladspaBinaries.sort()
  2028. for i in range(len(ladspaBinaries)):
  2029. ladspa = ladspaBinaries[i]
  2030. percent = ( float(i) / len(ladspaBinaries) ) * self.fCurPercentValue
  2031. self._pluginLook((self.fLastCheckValue + percent) * 0.9, ladspa)
  2032. plugins = checkPluginLADSPA(ladspa, tool, isWine)
  2033. if plugins:
  2034. self.fLadspaPlugins.append(plugins)
  2035. self.fSomethingChanged = True
  2036. self.fLastCheckValue += self.fCurPercentValue
  2037. def _checkDSSI(self, OS, tool, isWine=False):
  2038. dssiBinaries = []
  2039. self.fDssiPlugins = []
  2040. for iPATH in Carla.DSSI_PATH:
  2041. binaries = findBinaries(iPATH, OS)
  2042. for binary in binaries:
  2043. if binary not in dssiBinaries:
  2044. dssiBinaries.append(binary)
  2045. dssiBinaries.sort()
  2046. for i in range(len(dssiBinaries)):
  2047. dssi = dssiBinaries[i]
  2048. percent = ( float(i) / len(dssiBinaries) ) * self.fCurPercentValue
  2049. self._pluginLook(self.fLastCheckValue + percent, dssi)
  2050. plugins = checkPluginDSSI(dssi, tool, isWine)
  2051. if plugins:
  2052. self.fDssiPlugins.append(plugins)
  2053. self.fSomethingChanged = True
  2054. self.fLastCheckValue += self.fCurPercentValue
  2055. def _checkLV2(self, tool, isWine=False):
  2056. lv2Bundles = []
  2057. self.fLv2Plugins = []
  2058. self._pluginLook(self.fLastCheckValue, "LV2 bundles...")
  2059. for iPATH in Carla.LV2_PATH:
  2060. bundles = findLV2Bundles(iPATH)
  2061. for bundle in bundles:
  2062. if bundle not in lv2Bundles:
  2063. lv2Bundles.append(bundle)
  2064. lv2Bundles.sort()
  2065. for i in range(len(lv2Bundles)):
  2066. lv2 = lv2Bundles[i]
  2067. percent = ( float(i) / len(lv2Bundles) ) * self.fCurPercentValue
  2068. self._pluginLook(self.fLastCheckValue + percent, lv2)
  2069. plugins = checkPluginLV2(lv2, tool, isWine)
  2070. if plugins:
  2071. self.fLv2Plugins.append(plugins)
  2072. self.fSomethingChanged = True
  2073. self.fLastCheckValue += self.fCurPercentValue
  2074. def _checkVST(self, OS, tool, isWine=False):
  2075. vstBinaries = []
  2076. self.fVstPlugins = []
  2077. for iPATH in Carla.VST_PATH:
  2078. binaries = findBinaries(iPATH, OS)
  2079. for binary in binaries:
  2080. if binary not in vstBinaries:
  2081. vstBinaries.append(binary)
  2082. vstBinaries.sort()
  2083. for i in range(len(vstBinaries)):
  2084. vst = vstBinaries[i]
  2085. percent = ( float(i) / len(vstBinaries) ) * self.fCurPercentValue
  2086. self._pluginLook(self.fLastCheckValue + percent, vst)
  2087. plugins = checkPluginVST(vst, tool, isWine)
  2088. if plugins:
  2089. self.fVstPlugins.append(plugins)
  2090. self.fSomethingChanged = True
  2091. self.fLastCheckValue += self.fCurPercentValue
  2092. def _checkKIT(self, kPATH, kType):
  2093. kitFiles = []
  2094. self.fKitPlugins = []
  2095. for iPATH in kPATH:
  2096. files = findSoundKits(iPATH, kType)
  2097. for file_ in files:
  2098. if file_ not in kitFiles:
  2099. kitFiles.append(file_)
  2100. kitFiles.sort()
  2101. for i in range(len(kitFiles)):
  2102. kit = kitFiles[i]
  2103. percent = ( float(i) / len(kitFiles) ) * self.fCurPercentValue
  2104. self._pluginLook(self.fLastCheckValue + percent, kit)
  2105. if kType == "gig":
  2106. plugins = checkPluginGIG(kit, self.fToolNative)
  2107. elif kType == "sf2":
  2108. plugins = checkPluginSF2(kit, self.fToolNative)
  2109. elif kType == "sfz":
  2110. plugins = checkPluginSFZ(kit, self.fToolNative)
  2111. else:
  2112. plugins = None
  2113. if plugins:
  2114. self.fKitPlugins.append(plugins)
  2115. self.fSomethingChanged = True
  2116. self.fLastCheckValue += self.fCurPercentValue
  2117. def _pluginLook(self, percent, plugin):
  2118. self.emit(SIGNAL("pluginLook(int, QString)"), percent, plugin)
  2119. # ------------------------------------------------------------------------------------------------------------
  2120. # Plugin Refresh Dialog
  2121. class PluginRefreshW(QDialog):
  2122. def __init__(self, parent):
  2123. QDialog.__init__(self, parent)
  2124. self.ui = ui_carla_refresh.Ui_PluginRefreshW()
  2125. self.ui.setupUi(self)
  2126. # -------------------------------------------------------------
  2127. # Internal stuff
  2128. self.fThread = SearchPluginsThread(self)
  2129. # -------------------------------------------------------------
  2130. # Set-up GUI
  2131. self.fIconYes = getIcon("dialog-ok-apply").pixmap(16, 16)
  2132. self.fIconNo = getIcon("dialog-error").pixmap(16, 16)
  2133. self.ui.b_skip.setVisible(False)
  2134. if HAIKU:
  2135. self.ui.ch_posix32.setText("Haiku 32bit")
  2136. self.ui.ch_posix64.setText("Haiku 64bit")
  2137. elif LINUX:
  2138. self.ui.ch_posix32.setText("Linux 32bit")
  2139. self.ui.ch_posix64.setText("Linux 64bit")
  2140. elif MACOS:
  2141. self.ui.ch_posix32.setText("MacOS 32bit")
  2142. self.ui.ch_posix64.setText("MacOS 64bit")
  2143. if carla_discovery_posix32 and not WINDOWS:
  2144. self.ui.ico_posix32.setPixmap(self.fIconYes)
  2145. else:
  2146. self.ui.ico_posix32.setPixmap(self.fIconNo)
  2147. self.ui.ch_posix32.setChecked(False)
  2148. self.ui.ch_posix32.setEnabled(False)
  2149. if carla_discovery_posix64 and not WINDOWS:
  2150. self.ui.ico_posix64.setPixmap(self.fIconYes)
  2151. else:
  2152. self.ui.ico_posix64.setPixmap(self.fIconNo)
  2153. self.ui.ch_posix64.setChecked(False)
  2154. self.ui.ch_posix64.setEnabled(False)
  2155. if carla_discovery_win32:
  2156. self.ui.ico_win32.setPixmap(self.fIconYes)
  2157. else:
  2158. self.ui.ico_win32.setPixmap(self.fIconNo)
  2159. self.ui.ch_win32.setChecked(False)
  2160. self.ui.ch_win32.setEnabled(False)
  2161. if carla_discovery_win64:
  2162. self.ui.ico_win64.setPixmap(self.fIconYes)
  2163. else:
  2164. self.ui.ico_win64.setPixmap(self.fIconNo)
  2165. self.ui.ch_win64.setChecked(False)
  2166. self.ui.ch_win64.setEnabled(False)
  2167. if haveLRDF:
  2168. self.ui.ico_rdflib.setPixmap(self.fIconYes)
  2169. else:
  2170. self.ui.ico_rdflib.setPixmap(self.fIconNo)
  2171. hasNative = bool(carla_discovery_native)
  2172. hasNonNative = False
  2173. if WINDOWS:
  2174. if kIs64bit:
  2175. hasNative = bool(carla_discovery_win64)
  2176. hasNonNative = bool(carla_discovery_win32)
  2177. self.fThread.setSearchToolNative(carla_discovery_win64)
  2178. self.ui.ch_win64.setChecked(False)
  2179. self.ui.ch_win64.setVisible(False)
  2180. self.ui.ico_win64.setVisible(False)
  2181. self.ui.label_win64.setVisible(False)
  2182. else:
  2183. hasNative = bool(carla_discovery_win32)
  2184. hasNonNative = bool(carla_discovery_win64)
  2185. self.fThread.setSearchToolNative(carla_discovery_win32)
  2186. self.ui.ch_win32.setChecked(False)
  2187. self.ui.ch_win32.setVisible(False)
  2188. self.ui.ico_win32.setVisible(False)
  2189. self.ui.label_win32.setVisible(False)
  2190. elif LINUX or MACOS:
  2191. if kIs64bit:
  2192. hasNonNative = bool(carla_discovery_posix32 or carla_discovery_win32 or carla_discovery_win64)
  2193. self.ui.ch_posix64.setChecked(False)
  2194. self.ui.ch_posix64.setVisible(False)
  2195. self.ui.ico_posix64.setVisible(False)
  2196. self.ui.label_posix64.setVisible(False)
  2197. else:
  2198. hasNonNative = bool(carla_discovery_posix64 or carla_discovery_win32 or carla_discovery_win64)
  2199. self.ui.ch_posix32.setChecked(False)
  2200. self.ui.ch_posix32.setVisible(False)
  2201. self.ui.ico_posix32.setVisible(False)
  2202. self.ui.label_posix32.setVisible(False)
  2203. if hasNative:
  2204. self.ui.ico_native.setPixmap(self.fIconYes)
  2205. else:
  2206. self.ui.ico_native.setPixmap(self.fIconNo)
  2207. self.ui.ch_native.setChecked(False)
  2208. self.ui.ch_native.setEnabled(False)
  2209. self.ui.ch_gig.setChecked(False)
  2210. self.ui.ch_gig.setEnabled(False)
  2211. self.ui.ch_sf2.setChecked(False)
  2212. self.ui.ch_sf2.setEnabled(False)
  2213. self.ui.ch_sfz.setChecked(False)
  2214. self.ui.ch_sfz.setEnabled(False)
  2215. if not hasNonNative:
  2216. self.ui.ch_ladspa.setChecked(False)
  2217. self.ui.ch_ladspa.setEnabled(False)
  2218. self.ui.ch_dssi.setChecked(False)
  2219. self.ui.ch_dssi.setEnabled(False)
  2220. self.ui.ch_lv2.setChecked(False)
  2221. self.ui.ch_lv2.setEnabled(False)
  2222. self.ui.ch_vst.setChecked(False)
  2223. self.ui.ch_vst.setEnabled(False)
  2224. self.ui.b_start.setEnabled(False)
  2225. # -------------------------------------------------------------
  2226. # Load settings
  2227. self.loadSettings()
  2228. # -------------------------------------------------------------
  2229. # Set-up connections
  2230. self.connect(self.ui.b_start, SIGNAL("clicked()"), SLOT("slot_start()"))
  2231. self.connect(self.ui.b_skip, SIGNAL("clicked()"), SLOT("slot_skip()"))
  2232. self.connect(self.ui.ch_native, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2233. self.connect(self.ui.ch_posix32, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2234. self.connect(self.ui.ch_posix64, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2235. self.connect(self.ui.ch_win32, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2236. self.connect(self.ui.ch_win64, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2237. self.connect(self.ui.ch_ladspa, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2238. self.connect(self.ui.ch_dssi, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2239. self.connect(self.ui.ch_lv2, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2240. self.connect(self.ui.ch_vst, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2241. self.connect(self.ui.ch_gig, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2242. self.connect(self.ui.ch_sf2, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2243. self.connect(self.ui.ch_sfz, SIGNAL("clicked()"), SLOT("slot_checkTools()"))
  2244. self.connect(self.fThread, SIGNAL("pluginLook(int, QString)"), SLOT("slot_handlePluginLook(int, QString)"))
  2245. self.connect(self.fThread, SIGNAL("finished()"), SLOT("slot_handlePluginThreadFinished()"))
  2246. @pyqtSlot()
  2247. def slot_start(self):
  2248. self.ui.progressBar.setMinimum(0)
  2249. self.ui.progressBar.setMaximum(100)
  2250. self.ui.progressBar.setValue(0)
  2251. self.ui.b_start.setEnabled(False)
  2252. self.ui.b_skip.setVisible(True)
  2253. self.ui.b_close.setVisible(False)
  2254. 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())
  2255. 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(),
  2256. self.ui.ch_gig.isChecked(), self.ui.ch_sf2.isChecked(), self.ui.ch_sfz.isChecked())
  2257. self.fThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64)
  2258. self.fThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, gig, sf2, sfz)
  2259. self.fThread.start()
  2260. @pyqtSlot()
  2261. def slot_skip(self):
  2262. self.fThread.skipPlugin()
  2263. @pyqtSlot()
  2264. def slot_checkTools(self):
  2265. enabled1 = bool(self.ui.ch_native.isChecked() or self.ui.ch_posix32.isChecked() or self.ui.ch_posix64.isChecked() or self.ui.ch_win32.isChecked() or self.ui.ch_win64.isChecked())
  2266. enabled2 = bool(self.ui.ch_ladspa.isChecked() or self.ui.ch_dssi.isChecked() or self.ui.ch_lv2.isChecked() or self.ui.ch_vst.isChecked() or
  2267. self.ui.ch_gig.isChecked() or self.ui.ch_sf2.isChecked() or self.ui.ch_sfz.isChecked())
  2268. self.ui.b_start.setEnabled(enabled1 and enabled2)
  2269. @pyqtSlot(int, str)
  2270. def slot_handlePluginLook(self, percent, plugin):
  2271. self.ui.progressBar.setFormat("%s" % plugin)
  2272. self.ui.progressBar.setValue(percent)
  2273. @pyqtSlot()
  2274. def slot_handlePluginThreadFinished(self):
  2275. self.ui.progressBar.setMinimum(0)
  2276. self.ui.progressBar.setMaximum(1)
  2277. self.ui.progressBar.setValue(1)
  2278. self.ui.progressBar.setFormat(self.tr("Done"))
  2279. self.ui.b_start.setEnabled(True)
  2280. self.ui.b_skip.setVisible(False)
  2281. self.ui.b_close.setVisible(True)
  2282. def loadSettings(self):
  2283. settings = QSettings()
  2284. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/SearchLADSPA", True, type=bool))
  2285. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/SearchDSSI", True, type=bool))
  2286. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/SearchLV2", True, type=bool))
  2287. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/SearchVST", True, type=bool))
  2288. self.ui.ch_gig.setChecked(settings.value("PluginDatabase/SearchGIG", False, type=bool))
  2289. self.ui.ch_sf2.setChecked(settings.value("PluginDatabase/SearchSF2", False, type=bool))
  2290. self.ui.ch_sfz.setChecked(settings.value("PluginDatabase/SearchSFZ", False, type=bool))
  2291. self.ui.ch_native.setChecked(settings.value("PluginDatabase/SearchNative", True, type=bool))
  2292. self.ui.ch_posix32.setChecked(settings.value("PluginDatabase/SearchPOSIX32", False, type=bool))
  2293. self.ui.ch_posix64.setChecked(settings.value("PluginDatabase/SearchPOSIX64", False, type=bool))
  2294. self.ui.ch_win32.setChecked(settings.value("PluginDatabase/SearchWin32", False, type=bool))
  2295. self.ui.ch_win64.setChecked(settings.value("PluginDatabase/SearchWin64", False, type=bool))
  2296. def saveSettings(self):
  2297. settings = QSettings()
  2298. settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked())
  2299. settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked())
  2300. settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked())
  2301. settings.setValue("PluginDatabase/SearchVST", self.ui.ch_vst.isChecked())
  2302. settings.setValue("PluginDatabase/SearchGIG", self.ui.ch_gig.isChecked())
  2303. settings.setValue("PluginDatabase/SearchSF2", self.ui.ch_sf2.isChecked())
  2304. settings.setValue("PluginDatabase/SearchSFZ", self.ui.ch_sfz.isChecked())
  2305. settings.setValue("PluginDatabase/SearchNative", self.ui.ch_native.isChecked())
  2306. settings.setValue("PluginDatabase/SearchPOSIX32", self.ui.ch_posix32.isChecked())
  2307. settings.setValue("PluginDatabase/SearchPOSIX64", self.ui.ch_posix64.isChecked())
  2308. settings.setValue("PluginDatabase/SearchWin32", self.ui.ch_win32.isChecked())
  2309. settings.setValue("PluginDatabase/SearchWin64", self.ui.ch_win64.isChecked())
  2310. def closeEvent(self, event):
  2311. self.saveSettings()
  2312. if self.fThread.isRunning():
  2313. self.fThread.terminate()
  2314. self.fThread.wait()
  2315. if self.fThread.somethingChanged():
  2316. self.accept()
  2317. else:
  2318. self.reject()
  2319. QDialog.closeEvent(self, event)
  2320. def done(self, r):
  2321. QDialog.done(self, r)
  2322. self.close()
  2323. # ------------------------------------------------------------------------------------------------------------
  2324. # Plugin Database Dialog
  2325. class PluginDatabaseW(QDialog):
  2326. def __init__(self, parent):
  2327. QDialog.__init__(self, parent)
  2328. self.ui = ui_carla_database.Ui_PluginDatabaseW()
  2329. self.ui.setupUi(self)
  2330. # -------------------------------------------------------------
  2331. # Internal stuff
  2332. self.fLastTableIndex = 0
  2333. self.fRetPlugin = None
  2334. self.fRealParent = parent
  2335. # -------------------------------------------------------------
  2336. # Set-up GUI
  2337. self.ui.b_add.setEnabled(False)
  2338. if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32):
  2339. self.ui.ch_bridged.setText(self.tr("Bridged (64bit)"))
  2340. else:
  2341. self.ui.ch_bridged.setText(self.tr("Bridged (32bit)"))
  2342. if not (LINUX or MACOS):
  2343. self.ui.ch_bridged_wine.setChecked(False)
  2344. self.ui.ch_bridged_wine.setEnabled(False)
  2345. # -------------------------------------------------------------
  2346. # Load settings
  2347. self.loadSettings()
  2348. # -------------------------------------------------------------
  2349. # Set-up connections
  2350. self.connect(self.ui.b_add, SIGNAL("clicked()"), SLOT("slot_addPlugin()"))
  2351. self.connect(self.ui.b_refresh, SIGNAL("clicked()"), SLOT("slot_refreshPlugins()"))
  2352. self.connect(self.ui.tb_filters, SIGNAL("clicked()"), SLOT("slot_maybeShowFilters()"))
  2353. self.connect(self.ui.lineEdit, SIGNAL("textChanged(QString)"), SLOT("slot_checkFilters()"))
  2354. self.connect(self.ui.tableWidget, SIGNAL("currentCellChanged(int, int, int, int)"), SLOT("slot_checkPlugin(int)"))
  2355. self.connect(self.ui.tableWidget, SIGNAL("cellDoubleClicked(int, int)"), SLOT("slot_addPlugin()"))
  2356. self.connect(self.ui.ch_effects, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2357. self.connect(self.ui.ch_instruments, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2358. self.connect(self.ui.ch_midi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2359. self.connect(self.ui.ch_other, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2360. self.connect(self.ui.ch_kits, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2361. self.connect(self.ui.ch_internal, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2362. self.connect(self.ui.ch_ladspa, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2363. self.connect(self.ui.ch_dssi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2364. self.connect(self.ui.ch_lv2, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2365. self.connect(self.ui.ch_vst, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2366. self.connect(self.ui.ch_native, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2367. self.connect(self.ui.ch_bridged, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2368. self.connect(self.ui.ch_bridged_wine, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2369. self.connect(self.ui.ch_gui, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2370. self.connect(self.ui.ch_stereo, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2371. # -------------------------------------------------------------
  2372. @pyqtSlot()
  2373. def slot_addPlugin(self):
  2374. if self.ui.tableWidget.currentRow() >= 0:
  2375. self.fRetPlugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(), 0).data(Qt.UserRole)
  2376. self.accept()
  2377. else:
  2378. self.reject()
  2379. @pyqtSlot(int)
  2380. def slot_checkPlugin(self, row):
  2381. self.ui.b_add.setEnabled(row >= 0)
  2382. @pyqtSlot()
  2383. def slot_checkFilters(self):
  2384. self._checkFilters()
  2385. @pyqtSlot()
  2386. def slot_maybeShowFilters(self):
  2387. self._showFilters(not self.ui.frame.isVisible())
  2388. @pyqtSlot()
  2389. def slot_refreshPlugins(self):
  2390. if PluginRefreshW(self).exec_():
  2391. self._reAddPlugins()
  2392. if self.fRealParent:
  2393. self.fRealParent.loadRDFsNeeded()
  2394. def _checkFilters(self):
  2395. text = self.ui.lineEdit.text().lower()
  2396. hideEffects = not self.ui.ch_effects.isChecked()
  2397. hideInstruments = not self.ui.ch_instruments.isChecked()
  2398. hideMidi = not self.ui.ch_midi.isChecked()
  2399. hideOther = not self.ui.ch_other.isChecked()
  2400. hideInternal = not self.ui.ch_internal.isChecked()
  2401. hideLadspa = not self.ui.ch_ladspa.isChecked()
  2402. hideDssi = not self.ui.ch_dssi.isChecked()
  2403. hideLV2 = not self.ui.ch_lv2.isChecked()
  2404. hideVST = not self.ui.ch_vst.isChecked()
  2405. hideKits = not self.ui.ch_kits.isChecked()
  2406. hideNative = not self.ui.ch_native.isChecked()
  2407. hideBridged = not self.ui.ch_bridged.isChecked()
  2408. hideBridgedWine = not self.ui.ch_bridged_wine.isChecked()
  2409. hideNonGui = self.ui.ch_gui.isChecked()
  2410. hideNonStereo = self.ui.ch_stereo.isChecked()
  2411. if HAIKU or LINUX or MACOS:
  2412. nativeBins = [BINARY_POSIX32, BINARY_POSIX64]
  2413. wineBins = [BINARY_WIN32, BINARY_WIN64]
  2414. elif WINDOWS:
  2415. nativeBins = [BINARY_WIN32, BINARY_WIN64]
  2416. wineBins = []
  2417. else:
  2418. nativeBins = []
  2419. wineBins = []
  2420. rowCount = self.ui.tableWidget.rowCount()
  2421. for i in range(rowCount):
  2422. self.ui.tableWidget.showRow(i)
  2423. plugin = self.ui.tableWidget.item(i, 0).data(Qt.UserRole)
  2424. aIns = plugin['audio.ins']
  2425. aOuts = plugin['audio.outs']
  2426. mIns = plugin['midi.ins']
  2427. mOuts = plugin['midi.outs']
  2428. ptype = self.ui.tableWidget.item(i, 12).text()
  2429. isSynth = bool(plugin['hints'] & PLUGIN_IS_SYNTH)
  2430. isEffect = bool(aIns > 0 < aOuts and not isSynth)
  2431. isMidi = bool(aIns == 0 and aOuts == 0 and mIns > 0 < mOuts)
  2432. isKit = bool(ptype in ("GIG", "SF2", "SFZ"))
  2433. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  2434. isNative = bool(plugin['build'] == BINARY_NATIVE)
  2435. isStereo = bool(aIns == 2 and aOuts == 2) or (isSynth and aOuts == 2)
  2436. hasGui = bool(plugin['hints'] & PLUGIN_HAS_GUI)
  2437. isBridged = bool(not isNative and plugin['build'] in nativeBins)
  2438. isBridgedWine = bool(not isNative and plugin['build'] in wineBins)
  2439. if (hideEffects and isEffect):
  2440. self.ui.tableWidget.hideRow(i)
  2441. elif (hideInstruments and isSynth):
  2442. self.ui.tableWidget.hideRow(i)
  2443. elif (hideMidi and isMidi):
  2444. self.ui.tableWidget.hideRow(i)
  2445. elif (hideOther and isOther):
  2446. self.ui.tableWidget.hideRow(i)
  2447. elif (hideKits and isKit):
  2448. self.ui.tableWidget.hideRow(i)
  2449. elif (hideInternal and ptype == self.tr("Internal")):
  2450. self.ui.tableWidget.hideRow(i)
  2451. elif (hideLadspa and ptype == "LADSPA"):
  2452. self.ui.tableWidget.hideRow(i)
  2453. elif (hideDssi and ptype == "DSSI"):
  2454. self.ui.tableWidget.hideRow(i)
  2455. elif (hideLV2 and ptype == "LV2"):
  2456. self.ui.tableWidget.hideRow(i)
  2457. elif (hideVST and ptype == "VST"):
  2458. self.ui.tableWidget.hideRow(i)
  2459. elif (hideNative and isNative):
  2460. self.ui.tableWidget.hideRow(i)
  2461. elif (hideBridged and isBridged):
  2462. self.ui.tableWidget.hideRow(i)
  2463. elif (hideBridgedWine and isBridgedWine):
  2464. self.ui.tableWidget.hideRow(i)
  2465. elif (hideNonGui and not hasGui):
  2466. self.ui.tableWidget.hideRow(i)
  2467. elif (hideNonStereo and not isStereo):
  2468. self.ui.tableWidget.hideRow(i)
  2469. elif (text and not (
  2470. text in self.ui.tableWidget.item(i, 0).text().lower() or
  2471. text in self.ui.tableWidget.item(i, 1).text().lower() or
  2472. text in self.ui.tableWidget.item(i, 2).text().lower() or
  2473. text in self.ui.tableWidget.item(i, 3).text().lower() or
  2474. text in self.ui.tableWidget.item(i, 13).text().lower())):
  2475. self.ui.tableWidget.hideRow(i)
  2476. def _showFilters(self, yesNo):
  2477. self.ui.tb_filters.setArrowType(Qt.UpArrow if yesNo else Qt.DownArrow)
  2478. self.ui.frame.setVisible(yesNo)
  2479. def _addPluginToTable(self, plugin, ptype):
  2480. index = self.fLastTableIndex
  2481. if plugin['build'] == BINARY_NATIVE:
  2482. bridgeText = self.tr("No")
  2483. else:
  2484. if LINUX or MACOS:
  2485. if plugin['build'] == BINARY_WIN32:
  2486. typeText = "32bit"
  2487. elif plugin['build'] == BINARY_WIN64:
  2488. typeText = "64bit"
  2489. else:
  2490. typeText = self.tr("Unknown")
  2491. else:
  2492. if plugin['build'] == BINARY_POSIX32:
  2493. typeText = "32bit"
  2494. elif plugin['build'] == BINARY_POSIX64:
  2495. typeText = "64bit"
  2496. elif plugin['build'] == BINARY_WIN32:
  2497. typeText = "Windows 32bit"
  2498. elif plugin['build'] == BINARY_WIN64:
  2499. typeText = "Windows 64bit"
  2500. else:
  2501. typeText = self.tr("Unknown")
  2502. bridgeText = self.tr("Yes (%s)" % typeText)
  2503. self.ui.tableWidget.insertRow(index)
  2504. self.ui.tableWidget.setItem(index, 0, QTableWidgetItem(str(plugin['name'])))
  2505. self.ui.tableWidget.setItem(index, 1, QTableWidgetItem(str(plugin['label'])))
  2506. self.ui.tableWidget.setItem(index, 2, QTableWidgetItem(str(plugin['maker'])))
  2507. self.ui.tableWidget.setItem(index, 3, QTableWidgetItem(str(plugin['uniqueId'])))
  2508. self.ui.tableWidget.setItem(index, 4, QTableWidgetItem(str(plugin['audio.ins'])))
  2509. self.ui.tableWidget.setItem(index, 5, QTableWidgetItem(str(plugin['audio.outs'])))
  2510. self.ui.tableWidget.setItem(index, 6, QTableWidgetItem(str(plugin['parameters.ins'])))
  2511. self.ui.tableWidget.setItem(index, 7, QTableWidgetItem(str(plugin['parameters.outs'])))
  2512. self.ui.tableWidget.setItem(index, 8, QTableWidgetItem(str(plugin['programs.total'])))
  2513. self.ui.tableWidget.setItem(index, 9, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_HAS_GUI) else self.tr("No")))
  2514. self.ui.tableWidget.setItem(index, 10, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_IS_SYNTH) else self.tr("No")))
  2515. self.ui.tableWidget.setItem(index, 11, QTableWidgetItem(bridgeText))
  2516. self.ui.tableWidget.setItem(index, 12, QTableWidgetItem(ptype))
  2517. self.ui.tableWidget.setItem(index, 13, QTableWidgetItem(str(plugin['binary'])))
  2518. self.ui.tableWidget.item(index, 0).setData(Qt.UserRole, plugin)
  2519. self.fLastTableIndex += 1
  2520. def _reAddPlugins(self):
  2521. settingsDB = QSettings("falkTX", "CarlaPlugins")
  2522. for x in range(self.ui.tableWidget.rowCount()):
  2523. self.ui.tableWidget.removeRow(0)
  2524. self.fLastTableIndex = 0
  2525. self.ui.tableWidget.setSortingEnabled(False)
  2526. internalCount = 0
  2527. ladspaCount = 0
  2528. dssiCount = 0
  2529. lv2Count = 0
  2530. vstCount = 0
  2531. kitCount = 0
  2532. # ---------------------------------------------------------------------------
  2533. # Internal
  2534. internalPlugins = toList(settingsDB.value("Plugins/Internal", []))
  2535. for plugins in internalPlugins:
  2536. for plugin in plugins:
  2537. internalCount += 1
  2538. if (not Carla.isControl) and internalCount != Carla.host.get_internal_plugin_count():
  2539. internalCount = Carla.host.get_internal_plugin_count()
  2540. internalPlugins = []
  2541. for i in range(Carla.host.get_internal_plugin_count()):
  2542. descInfo = Carla.host.get_internal_plugin_info(i)
  2543. plugins = checkPluginInternal(descInfo)
  2544. if plugins:
  2545. internalPlugins.append(plugins)
  2546. settingsDB.setValue("Plugins/Internal", internalPlugins)
  2547. for plugins in internalPlugins:
  2548. for plugin in plugins:
  2549. self._addPluginToTable(plugin, self.tr("Internal"))
  2550. # ---------------------------------------------------------------------------
  2551. # LADSPA
  2552. ladspaPlugins = []
  2553. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_native", []))
  2554. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix32", []))
  2555. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix64", []))
  2556. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win32", []))
  2557. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win64", []))
  2558. for plugins in ladspaPlugins:
  2559. for plugin in plugins:
  2560. self._addPluginToTable(plugin, "LADSPA")
  2561. ladspaCount += 1
  2562. # ---------------------------------------------------------------------------
  2563. # DSSI
  2564. dssiPlugins = []
  2565. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_native", []))
  2566. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix32", []))
  2567. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix64", []))
  2568. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win32", []))
  2569. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win64", []))
  2570. for plugins in dssiPlugins:
  2571. for plugin in plugins:
  2572. self._addPluginToTable(plugin, "DSSI")
  2573. dssiCount += 1
  2574. # ---------------------------------------------------------------------------
  2575. # LV2
  2576. lv2Plugins = []
  2577. lv2Plugins += toList(settingsDB.value("Plugins/LV2_native", []))
  2578. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix32", []))
  2579. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix64", []))
  2580. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win32", []))
  2581. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win64", []))
  2582. for plugins in lv2Plugins:
  2583. for plugin in plugins:
  2584. self._addPluginToTable(plugin, "LV2")
  2585. lv2Count += 1
  2586. # ---------------------------------------------------------------------------
  2587. # VST
  2588. vstPlugins = []
  2589. vstPlugins += toList(settingsDB.value("Plugins/VST_native", []))
  2590. vstPlugins += toList(settingsDB.value("Plugins/VST_posix32", []))
  2591. vstPlugins += toList(settingsDB.value("Plugins/VST_posix64", []))
  2592. vstPlugins += toList(settingsDB.value("Plugins/VST_win32", []))
  2593. vstPlugins += toList(settingsDB.value("Plugins/VST_win64", []))
  2594. for plugins in vstPlugins:
  2595. for plugin in plugins:
  2596. self._addPluginToTable(plugin, "VST")
  2597. vstCount += 1
  2598. # ---------------------------------------------------------------------------
  2599. # Kits
  2600. gigs = toList(settingsDB.value("Plugins/GIG", []))
  2601. sf2s = toList(settingsDB.value("Plugins/SF2", []))
  2602. sfzs = toList(settingsDB.value("Plugins/SFZ", []))
  2603. for gig in gigs:
  2604. for gig_i in gig:
  2605. self._addPluginToTable(gig_i, "GIG")
  2606. kitCount += 1
  2607. for sf2 in sf2s:
  2608. for sf2_i in sf2:
  2609. self._addPluginToTable(sf2_i, "SF2")
  2610. kitCount += 1
  2611. for sfz in sfzs:
  2612. for sfz_i in sfz:
  2613. self._addPluginToTable(sfz_i, "SFZ")
  2614. kitCount += 1
  2615. # ---------------------------------------------------------------------------
  2616. self.ui.tableWidget.setSortingEnabled(True)
  2617. self.ui.tableWidget.sortByColumn(0, Qt.AscendingOrder)
  2618. 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)))
  2619. self._checkFilters()
  2620. def loadSettings(self):
  2621. settings = QSettings()
  2622. self.restoreGeometry(settings.value("PluginDatabase/Geometry", ""))
  2623. self.ui.tableWidget.horizontalHeader().restoreState(settings.value("PluginDatabase/TableGeometry", ""))
  2624. self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, type=bool))
  2625. self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, type=bool))
  2626. self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, type=bool))
  2627. self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, type=bool))
  2628. self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, type=bool))
  2629. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, type=bool))
  2630. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, type=bool))
  2631. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, type=bool))
  2632. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST", True, type=bool))
  2633. self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, type=bool))
  2634. self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, type=bool))
  2635. self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, type=bool))
  2636. self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, type=bool))
  2637. self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, type=bool))
  2638. self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, type=bool))
  2639. self._showFilters(settings.value("PluginDatabase/ShowFilters", False, type=bool))
  2640. self._reAddPlugins()
  2641. def saveSettings(self):
  2642. settings = QSettings()
  2643. settings.setValue("PluginDatabase/Geometry", self.saveGeometry())
  2644. settings.setValue("PluginDatabase/TableGeometry", self.ui.tableWidget.horizontalHeader().saveState())
  2645. settings.setValue("PluginDatabase/ShowFilters", (self.ui.tb_filters.arrowType() == Qt.UpArrow))
  2646. settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked())
  2647. settings.setValue("PluginDatabase/ShowInstruments", self.ui.ch_instruments.isChecked())
  2648. settings.setValue("PluginDatabase/ShowMIDI", self.ui.ch_midi.isChecked())
  2649. settings.setValue("PluginDatabase/ShowOther", self.ui.ch_other.isChecked())
  2650. settings.setValue("PluginDatabase/ShowInternal", self.ui.ch_internal.isChecked())
  2651. settings.setValue("PluginDatabase/ShowLADSPA", self.ui.ch_ladspa.isChecked())
  2652. settings.setValue("PluginDatabase/ShowDSSI", self.ui.ch_dssi.isChecked())
  2653. settings.setValue("PluginDatabase/ShowLV2", self.ui.ch_lv2.isChecked())
  2654. settings.setValue("PluginDatabase/ShowVST", self.ui.ch_vst.isChecked())
  2655. settings.setValue("PluginDatabase/ShowKits", self.ui.ch_kits.isChecked())
  2656. settings.setValue("PluginDatabase/ShowNative", self.ui.ch_native.isChecked())
  2657. settings.setValue("PluginDatabase/ShowBridged", self.ui.ch_bridged.isChecked())
  2658. settings.setValue("PluginDatabase/ShowBridgedWine", self.ui.ch_bridged_wine.isChecked())
  2659. settings.setValue("PluginDatabase/ShowHasGUI", self.ui.ch_gui.isChecked())
  2660. settings.setValue("PluginDatabase/ShowStereoOnly", self.ui.ch_stereo.isChecked())
  2661. def closeEvent(self, event):
  2662. self.saveSettings()
  2663. QDialog.closeEvent(self, event)
  2664. def done(self, r):
  2665. QDialog.done(self, r)
  2666. self.close()