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

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