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_skin.py 71KB

10 years ago
10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
9 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin/slot skin code
  4. # Copyright (C) 2013-2018 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Config)
  19. from carla_config import *
  20. # ------------------------------------------------------------------------------------------------------------
  21. # Imports (Global)
  22. if config_UseQt5:
  23. from PyQt5.QtCore import Qt, QRectF
  24. from PyQt5.QtGui import QFont, QFontDatabase, QPen, QPixmap
  25. from PyQt5.QtWidgets import QFrame, QPushButton
  26. else:
  27. from PyQt4.QtCore import Qt, QRectF
  28. from PyQt4.QtGui import QFont, QFontDatabase, QFrame, QPen, QPixmap, QPushButton
  29. # ------------------------------------------------------------------------------------------------------------
  30. # Imports (Custom)
  31. import ui_carla_plugin_calf
  32. import ui_carla_plugin_classic
  33. import ui_carla_plugin_compact
  34. import ui_carla_plugin_default
  35. import ui_carla_plugin_presets
  36. from carla_widgets import *
  37. from digitalpeakmeter import DigitalPeakMeter
  38. from pixmapdial import PixmapDial
  39. # ------------------------------------------------------------------------------------------------------------
  40. # Plugin Skin Rules (WORK IN PROGRESS)
  41. # Base is a QFrame (NoFrame, Plain, 0-size lines), with "PluginWidget" as object name.
  42. # Spacing of the top-most layout must be 1px.
  43. # Top and bottom margins must be 3px (can be splitted between different qt layouts).
  44. # Left and right margins must be 6px (can be splitted between different qt layouts).
  45. # If the left or right side has built-in margins, say a transparent png border,
  46. # those margins must be taken into consideration.
  47. #
  48. # There's a top and bottom layout, separated by a horizontal line.
  49. # Compacted skins do not have the bottom layout and separating line.
  50. # T O P A R E A
  51. #
  52. # -----------------------------------------------------------------
  53. # | <> | <> [ WIDGETS ] [ LEDS ] |
  54. # | BUTTONS <> | <> PLUGIN NAME < spacer > [ WIDGETS ] [ LEDS ] |
  55. # | <> | <> [ WIDGETS ] [ LEDS ] |
  56. # -----------------------------------------------------------------
  57. #
  58. # Buttons area has size fixed. (TBA)
  59. # Spacers at the left of the plugin name must be 8x1 in size (fixed).
  60. # The line before the plugin name must be height-10px (fixed).
  61. # WIDGETS area can be extended to the left, if using meters they should have 80px.
  62. # WIDGETS margins are 4px for left+right and 2px for top+bottom, with 4px spacing.
  63. # ------------------------------------------------------------------------------------------------------------
  64. # Try to "shortify" a parameter name
  65. def getParameterShortName(paramName):
  66. paramName = paramName.split("/",1)[0].split(" (",1)[0].split(" [",1)[0].strip()
  67. paramLow = paramName.lower()
  68. # Cut useless prefix
  69. if paramLow.startswith("compressor "):
  70. paramName = paramName.replace("ompressor ", ".", 1)
  71. paramLow = paramName.lower()
  72. elif paramLow.startswith("room "):
  73. paramName = paramName.split(" ",1)[1]
  74. paramLow = paramName.lower()
  75. # Cut useless suffix
  76. if paramLow.endswith(" level"):
  77. paramName = paramName.rsplit(" ",1)[0]
  78. paramLow = paramName.lower()
  79. elif paramLow.endswith(" time"):
  80. paramName = paramName.rsplit(" ",1)[0]
  81. paramLow = paramName.lower()
  82. # Cut generic names
  83. if "attack" in paramLow:
  84. paramName = paramName.replace("ttack", "tk")
  85. elif "bandwidth" in paramLow:
  86. paramName = paramName.replace("andwidth", "w")
  87. elif "damping" in paramLow:
  88. paramName = paramName.replace("amping", "amp")
  89. elif "distortion" in paramLow:
  90. paramName = paramName.replace("istortion", "ist")
  91. elif "feedback" in paramLow:
  92. paramName = paramName.replace("eedback", "b")
  93. elif "frequency" in paramLow:
  94. paramName = paramName.replace("requency", "req")
  95. elif "input" in paramLow:
  96. paramName = paramName.replace("nput", "n")
  97. elif "makeup" in paramLow:
  98. paramName = paramName.replace("akeup", "kUp" if "Make" in paramName else "kup")
  99. elif "output" in paramLow:
  100. paramName = paramName.replace("utput", "ut")
  101. elif "random" in paramLow:
  102. paramName = paramName.replace("andom", "nd")
  103. elif "threshold" in paramLow:
  104. paramName = paramName.replace("hreshold", "hres")
  105. # remove space if last char from 1st word is lowercase and the first char from the 2nd is uppercase,
  106. # or if 2nd is a number
  107. if " " in paramName:
  108. name1, name2 = paramName.split(" ", 1)
  109. if (name1[-1].islower() and name2[0].isupper()) or name2.isdigit():
  110. paramName = paramName.replace(" ", "", 1)
  111. # cut stuff if too big
  112. if len(paramName) > 7:
  113. paramName = paramName.replace("a","").replace("e","").replace("i","").replace("o","").replace("u","")
  114. if len(paramName) > 7:
  115. paramName = paramName[:7]
  116. return paramName.strip()
  117. # ------------------------------------------------------------------------------------------------------------
  118. # Get RGB colors for a plugin category
  119. def getColorFromCategory(category):
  120. r = 40
  121. g = 40
  122. b = 40
  123. if category == PLUGIN_CATEGORY_MODULATOR:
  124. r += 10
  125. elif category == PLUGIN_CATEGORY_EQ:
  126. g += 10
  127. elif category == PLUGIN_CATEGORY_FILTER:
  128. b += 10
  129. elif category == PLUGIN_CATEGORY_DELAY:
  130. r += 15
  131. b -= 15
  132. elif category == PLUGIN_CATEGORY_DISTORTION:
  133. g += 10
  134. b += 10
  135. elif category == PLUGIN_CATEGORY_DYNAMICS:
  136. r += 10
  137. b += 10
  138. elif category == PLUGIN_CATEGORY_UTILITY:
  139. r += 10
  140. g += 10
  141. return (r, g, b)
  142. def getModColorFromCategory(category):
  143. if category == PLUGIN_CATEGORY_NONE:
  144. return (40, 40, 40)
  145. if category == PLUGIN_CATEGORY_SYNTH:
  146. return (30, 150, 49)
  147. if category == PLUGIN_CATEGORY_DELAY:
  148. return (47, 47, 47)
  149. if category in (PLUGIN_CATEGORY_EQ, PLUGIN_CATEGORY_FILTER):
  150. return (255, 220, 25)
  151. if category == PLUGIN_CATEGORY_DISTORTION:
  152. return (255, 127, 25)
  153. if category == PLUGIN_CATEGORY_DYNAMICS:
  154. return (255, 25, 25)
  155. if category == PLUGIN_CATEGORY_MODULATOR:
  156. return (109, 31, 142)
  157. if category == PLUGIN_CATEGORY_UTILITY:
  158. return (95, 95, 95)
  159. if category == PLUGIN_CATEGORY_OTHER:
  160. return (92, 210, 254)
  161. return (40, 40, 40)
  162. # ------------------------------------------------------------------------------------------------------------
  163. #
  164. def setPixmapDialStyle(widget, parameterId, parameterCount, skinStyle):
  165. if skinStyle.startswith("calf"):
  166. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  167. widget.setPixmap(7)
  168. elif skinStyle.startswith("openav"):
  169. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  170. if parameterId == PARAMETER_DRYWET:
  171. widget.setPixmap(13)
  172. elif parameterId == PARAMETER_VOLUME:
  173. widget.setPixmap(12)
  174. else:
  175. widget.setPixmap(11)
  176. else:
  177. if parameterId == PARAMETER_DRYWET:
  178. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  179. elif parameterId == PARAMETER_VOLUME:
  180. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  181. else:
  182. _r = 255 - int((float(parameterId)/float(parameterCount))*200.0)
  183. _g = 55 + int((float(parameterId)/float(parameterCount))*200.0)
  184. _b = 0 #(r-40)*4
  185. widget.setCustomPaintColor(QColor(_r, _g, _b))
  186. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  187. widget.setPixmap(3)
  188. widget.forceWhiteLabelGradientText()
  189. # ------------------------------------------------------------------------------------------------------------
  190. # Abstract plugin slot
  191. class AbstractPluginSlot(QFrame, PluginEditParentMeta):
  192. #class AbstractPluginSlot(QFrame, PluginEditParentMeta, metaclass=PyQtMetaClass):
  193. def __init__(self, parent, host, pluginId, skinStyle):
  194. QFrame.__init__(self, parent)
  195. self.host = host
  196. self.fParent = parent
  197. if False:
  198. # kdevelop likes this :)
  199. host = CarlaHostNull()
  200. self.host = host
  201. # -------------------------------------------------------------
  202. # Get plugin info
  203. self.fPluginId = pluginId
  204. self.fPluginInfo = host.get_plugin_info(self.fPluginId)
  205. self.fSkinStyle = skinStyle
  206. # -------------------------------------------------------------
  207. # Internal stuff
  208. self.fIsActive = False
  209. self.fIsSelected = False
  210. self.fLastGreenLedState = False
  211. self.fLastBlueLedState = False
  212. self.fParameterIconTimer = ICON_STATE_NULL
  213. self.fParameterList = [] # index, widget
  214. audioCountInfo = host.get_audio_port_count_info(self.fPluginId)
  215. self.fPeaksInputCount = audioCountInfo['ins']
  216. self.fPeaksOutputCount = audioCountInfo['outs']
  217. if self.fPeaksInputCount > 2:
  218. self.fPeaksInputCount = 2
  219. if self.fPeaksOutputCount > 2:
  220. self.fPeaksOutputCount = 2
  221. # used during testing
  222. self.fIdleTimerId = 0
  223. # -------------------------------------------------------------
  224. # Set-up GUI
  225. self.fEditDialog = PluginEdit(self, host, self.fPluginId)
  226. # -------------------------------------------------------------
  227. # Set-up common widgets (as none)
  228. self.b_enable = None
  229. self.b_gui = None
  230. self.b_edit = None
  231. self.b_remove = None
  232. self.cb_presets = None
  233. self.label_name = None
  234. self.label_presets = None
  235. self.label_type = None
  236. self.led_control = None
  237. self.led_midi = None
  238. self.led_audio_in = None
  239. self.led_audio_out = None
  240. self.peak_in = None
  241. self.peak_out = None
  242. self.w_knobs_left = None
  243. self.w_knobs_right = None
  244. # -------------------------------------------------------------
  245. # Set-up connections
  246. self.customContextMenuRequested.connect(self.slot_showCustomMenu)
  247. host.PluginRenamedCallback.connect(self.slot_handlePluginRenamedCallback)
  248. host.PluginUnavailableCallback.connect(self.slot_handlePluginUnavailableCallback)
  249. host.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback)
  250. host.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback)
  251. host.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback)
  252. host.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback)
  253. host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback)
  254. host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback)
  255. host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback)
  256. host.UiStateChangedCallback.connect(self.slot_handleUiStateChangedCallback)
  257. # -----------------------------------------------------------------
  258. @pyqtSlot(int, str)
  259. def slot_handlePluginRenamedCallback(self, pluginId, newName):
  260. if self.fPluginId == pluginId:
  261. self.setName(newName)
  262. @pyqtSlot(int, str)
  263. def slot_handlePluginUnavailableCallback(self, pluginId, errorMsg):
  264. if self.fPluginId == pluginId:
  265. pass
  266. @pyqtSlot(int, int, float)
  267. def slot_handleParameterValueChangedCallback(self, pluginId, index, value):
  268. if self.fPluginId == pluginId:
  269. self.setParameterValue(index, value, True)
  270. @pyqtSlot(int, int, float)
  271. def slot_handleParameterDefaultChangedCallback(self, pluginId, index, value):
  272. if self.fPluginId == pluginId:
  273. self.setParameterDefault(index, value)
  274. @pyqtSlot(int, int, int)
  275. def slot_handleParameterMidiCcChangedCallback(self, pluginId, index, cc):
  276. if self.fPluginId == pluginId:
  277. self.setParameterMidiControl(index, cc)
  278. @pyqtSlot(int, int, int)
  279. def slot_handleParameterMidiChannelChangedCallback(self, pluginId, index, channel):
  280. if self.fPluginId == pluginId:
  281. self.setParameterMidiChannel(index, channel)
  282. @pyqtSlot(int, int)
  283. def slot_handleProgramChangedCallback(self, pluginId, index):
  284. if self.fPluginId == pluginId:
  285. self.setProgram(index, True)
  286. @pyqtSlot(int, int)
  287. def slot_handleMidiProgramChangedCallback(self, pluginId, index):
  288. if self.fPluginId == pluginId:
  289. self.setMidiProgram(index, True)
  290. @pyqtSlot(int, int, bool)
  291. def slot_handleOptionChangedCallback(self, pluginId, option, yesNo):
  292. if self.fPluginId == pluginId:
  293. self.setOption(option, yesNo)
  294. @pyqtSlot(int, int)
  295. def slot_handleUiStateChangedCallback(self, pluginId, state):
  296. if self.fPluginId == pluginId:
  297. self.customUiStateChanged(state)
  298. #------------------------------------------------------------------
  299. def ready(self):
  300. self.fIsActive = bool(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_ACTIVE) >= 0.5)
  301. isCalfSkin = self.fSkinStyle.startswith("calf") and not isinstance(self, PluginSlot_Compact)
  302. if self.b_enable is not None:
  303. self.b_enable.setChecked(self.fIsActive)
  304. self.b_enable.clicked.connect(self.slot_enableClicked)
  305. if isCalfSkin:
  306. self.b_enable.setPixmaps(":/bitmaps/button_calf3.png", ":/bitmaps/button_calf3_down.png", ":/bitmaps/button_calf3.png")
  307. else:
  308. self.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  309. if self.b_gui is not None:
  310. self.b_gui.clicked.connect(self.slot_showCustomUi)
  311. self.b_gui.setEnabled(bool(self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI))
  312. if isCalfSkin:
  313. self.b_gui.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  314. elif self.fPluginInfo['iconName'] == "distrho" or self.fSkinStyle in ("3bandeq","3bandsplitter","pingpongpan"):
  315. self.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  316. elif self.fPluginInfo['iconName'] == "file":
  317. self.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  318. else:
  319. self.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  320. if self.b_edit is not None:
  321. self.b_edit.clicked.connect(self.slot_showEditDialog)
  322. if isCalfSkin:
  323. self.b_edit.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  324. else:
  325. self.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  326. else:
  327. # Edit button *must* be available
  328. self.b_edit = QPushButton(self)
  329. self.b_edit.setCheckable(True)
  330. self.b_edit.hide()
  331. if self.b_remove is not None:
  332. self.b_remove.clicked.connect(self.slot_removePlugin)
  333. if self.label_name is not None:
  334. self.label_name.setEnabled(self.fIsActive)
  335. self.label_name.setText(self.fPluginInfo['name'])
  336. nameFont = self.label_name.font()
  337. if self.fSkinStyle.startswith("calf"):
  338. nameFont.setBold(True)
  339. nameFont.setPixelSize(12)
  340. elif self.fSkinStyle.startswith("openav"):
  341. QFontDatabase.addApplicationFont(":/fonts/uranium.ttf")
  342. nameFont.setFamily("Uranium")
  343. nameFont.setPixelSize(15)
  344. nameFont.setCapitalization(QFont.AllUppercase)
  345. else:
  346. nameFont.setBold(True)
  347. nameFont.setPixelSize(11)
  348. self.label_name.setFont(nameFont)
  349. if self.label_presets is not None:
  350. presetFont = self.label_presets.font()
  351. presetFont.setBold(True)
  352. presetFont.setPixelSize(10)
  353. self.label_presets.setFont(presetFont)
  354. if self.label_type is not None:
  355. self.label_type.setText(getPluginTypeAsString(self.fPluginInfo['type']))
  356. if self.led_control is not None:
  357. self.led_control.setColor(self.led_control.YELLOW)
  358. self.led_control.setEnabled(False)
  359. if self.led_midi is not None:
  360. self.led_midi.setColor(self.led_midi.RED)
  361. self.led_midi.setEnabled(False)
  362. if self.led_audio_in is not None:
  363. self.led_audio_in.setColor(self.led_audio_in.GREEN)
  364. self.led_audio_in.setEnabled(False)
  365. if self.led_audio_out is not None:
  366. self.led_audio_out.setColor(self.led_audio_out.BLUE)
  367. self.led_audio_out.setEnabled(False)
  368. if self.peak_in is not None:
  369. self.peak_in.setChannelCount(self.fPeaksInputCount)
  370. self.peak_in.setMeterColor(DigitalPeakMeter.COLOR_GREEN)
  371. self.peak_in.setMeterOrientation(DigitalPeakMeter.HORIZONTAL)
  372. if self.fSkinStyle.startswith("calf"):
  373. self.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_CALF)
  374. elif self.fSkinStyle == "rncbc":
  375. self.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_RNCBC)
  376. elif self.fSkinStyle.startswith("openav") or self.fSkinStyle == "zynfx":
  377. self.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV)
  378. if self.fPeaksInputCount == 0 and not isinstance(self, PluginSlot_Classic):
  379. self.peak_in.hide()
  380. if self.peak_out is not None:
  381. self.peak_out.setChannelCount(self.fPeaksOutputCount)
  382. self.peak_out.setMeterColor(DigitalPeakMeter.COLOR_BLUE)
  383. self.peak_out.setMeterOrientation(DigitalPeakMeter.HORIZONTAL)
  384. if self.fSkinStyle.startswith("calf"):
  385. self.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_CALF)
  386. elif self.fSkinStyle == "rncbc":
  387. self.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_RNCBC)
  388. elif self.fSkinStyle.startswith("openav") or self.fSkinStyle == "zynfx":
  389. self.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV)
  390. if self.fPeaksOutputCount == 0 and not isinstance(self, PluginSlot_Classic):
  391. self.peak_out.hide()
  392. # -------------------------------------------------------------
  393. if self.fSkinStyle == "openav":
  394. styleSheet = """
  395. QFrame#PluginWidget {
  396. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  397. stop: 0 #383838, stop: %f #111111, stop: 1.0 #111111);
  398. }
  399. QLabel#label_name { color: #FFFFFF; }
  400. QLabel#label_name:disabled { color: #505050; }
  401. """ % (0.95 if isinstance(self, PluginSlot_Compact) else 0.35)
  402. elif self.fSkinStyle == "openav-old":
  403. styleSheet = """
  404. QFrame#PluginWidget {
  405. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  406. stop: 0 #303030, stop: %f #111111, stop: 1.0 #111111);
  407. }
  408. QLabel#label_name { color: #FF5100; }
  409. QLabel#label_name:disabled { color: #505050; }
  410. """ % (0.95 if isinstance(self, PluginSlot_Compact) else 0.35)
  411. else:
  412. if self.fSkinStyle in ("3bandeq", "calf_black", "calf_blue", "nekobi", "zynfx"):
  413. styleSheet2 = "background-image: url(:/bitmaps/background_%s.png);" % self.fSkinStyle
  414. else:
  415. styleSheet2 = "background-color: rgb(%i, %i, %i);" % getColorFromCategory(self.fPluginInfo['category'])
  416. styleSheet2 += "background-image: url(:/bitmaps/background_noise1.png);"
  417. styleSheet = """
  418. QFrame#PluginWidget {
  419. %s
  420. background-repeat: repeat-xy;
  421. }
  422. QLabel#label_name,
  423. QLabel#label_audio_in,
  424. QLabel#label_audio_out,
  425. QLabel#label_midi,
  426. QLabel#label_presets { color: #BBB; }
  427. QLabel#label_name:disabled { color: #555; }
  428. """ % styleSheet2
  429. self.setStyleSheet(styleSheet)
  430. # -------------------------------------------------------------
  431. # Set-up parameters
  432. if self.w_knobs_left is not None:
  433. parameterCount = self.host.get_parameter_count(self.fPluginId)
  434. if "calf" in self.fSkinStyle:
  435. maxWidgets = 7
  436. else:
  437. maxWidgets = 8
  438. index = 0
  439. for i in range(parameterCount):
  440. if index >= maxWidgets:
  441. break
  442. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  443. paramData = self.host.get_parameter_data(self.fPluginId, i)
  444. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  445. isInteger = (paramData['hints'] & PARAMETER_IS_INTEGER) != 0
  446. if paramData['type'] != PARAMETER_INPUT:
  447. continue
  448. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  449. continue
  450. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  451. continue
  452. if (paramData['hints'] & PARAMETER_USES_SCALEPOINTS) != 0 and not isInteger:
  453. # NOTE: we assume integer scalepoints are continuous
  454. continue
  455. if isInteger and paramRanges['max']-paramRanges['min'] <= 3:
  456. continue
  457. if paramInfo['name'].startswith("unused"):
  458. continue
  459. paramName = getParameterShortName(paramInfo['name'])
  460. widget = PixmapDial(self, i)
  461. widget.setLabel(paramName)
  462. widget.setMinimum(paramRanges['min'])
  463. widget.setMaximum(paramRanges['max'])
  464. if isInteger:
  465. widget.setPrecision(paramRanges['max']-paramRanges['min'], True)
  466. setPixmapDialStyle(widget, i, parameterCount, self.fSkinStyle)
  467. index += 1
  468. self.fParameterList.append([i, widget])
  469. self.w_knobs_left.layout().addWidget(widget)
  470. if self.w_knobs_right is not None and (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) != 0:
  471. widget = PixmapDial(self, PARAMETER_DRYWET)
  472. widget.setLabel("Dry/Wet")
  473. widget.setMinimum(0.0)
  474. widget.setMaximum(1.0)
  475. setPixmapDialStyle(widget, PARAMETER_DRYWET, 0, self.fSkinStyle)
  476. self.fParameterList.append([PARAMETER_DRYWET, widget])
  477. self.w_knobs_right.layout().addWidget(widget)
  478. if self.w_knobs_right is not None and (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) != 0:
  479. widget = PixmapDial(self, PARAMETER_VOLUME)
  480. widget.setLabel("Volume")
  481. widget.setMinimum(0.0)
  482. widget.setMaximum(1.27)
  483. setPixmapDialStyle(widget, PARAMETER_VOLUME, 0, self.fSkinStyle)
  484. self.fParameterList.append([PARAMETER_VOLUME, widget])
  485. self.w_knobs_right.layout().addWidget(widget)
  486. for paramIndex, paramWidget in self.fParameterList:
  487. paramWidget.setContextMenuPolicy(Qt.CustomContextMenu)
  488. paramWidget.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  489. paramWidget.realValueChanged.connect(self.slot_parameterValueChanged)
  490. paramWidget.blockSignals(True)
  491. paramWidget.setValue(self.host.get_internal_parameter_value(self.fPluginId, paramIndex))
  492. paramWidget.blockSignals(False)
  493. # -------------------------------------------------------------
  494. self.setWindowTitle(self.fPluginInfo['name'])
  495. #------------------------------------------------------------------
  496. def getFixedHeight(self):
  497. return 32
  498. def getHints(self):
  499. return self.fPluginInfo['hints']
  500. def getPluginId(self):
  501. return self.fPluginId
  502. #------------------------------------------------------------------
  503. def setPluginId(self, idx):
  504. self.fPluginId = idx
  505. self.fEditDialog.setPluginId(idx)
  506. def setName(self, name):
  507. self.fPluginInfo['name'] = name
  508. self.fEditDialog.setName(name)
  509. if self.label_name is not None:
  510. self.label_name.setText(name)
  511. def setSelected(self, yesNo):
  512. if self.fIsSelected == yesNo:
  513. return
  514. self.fIsSelected = yesNo
  515. self.update()
  516. #------------------------------------------------------------------
  517. def setActive(self, active, sendCallback=False, sendHost=True):
  518. self.fIsActive = active
  519. if sendCallback:
  520. self.fParameterIconTimer = ICON_STATE_ON
  521. self.activeChanged(active)
  522. if sendHost:
  523. self.host.set_active(self.fPluginId, active)
  524. if active:
  525. self.fEditDialog.clearNotes()
  526. self.midiActivityChanged(False)
  527. if self.label_name is not None:
  528. self.label_name.setEnabled(self.fIsActive)
  529. # called from rack, checks if param is possible first
  530. def setInternalParameter(self, parameterId, value):
  531. if parameterId <= PARAMETER_MAX or parameterId >= PARAMETER_NULL:
  532. return
  533. elif parameterId == PARAMETER_ACTIVE:
  534. return self.setActive(bool(value), True, True)
  535. elif parameterId == PARAMETER_DRYWET:
  536. if (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) == 0: return
  537. self.host.set_drywet(self.fPluginId, value)
  538. elif parameterId == PARAMETER_VOLUME:
  539. if (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) == 0: return
  540. self.host.set_volume(self.fPluginId, value)
  541. elif parameterId == PARAMETER_BALANCE_LEFT:
  542. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  543. self.host.set_balance_left(self.fPluginId, value)
  544. elif parameterId == PARAMETER_BALANCE_RIGHT:
  545. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  546. self.host.set_balance_right(self.fPluginId, value)
  547. elif parameterId == PARAMETER_PANNING:
  548. if (self.fPluginInfo['hints'] & PLUGIN_CAN_PANNING) == 0: return
  549. self.host.set_panning(self.fPluginId, value)
  550. elif parameterId == PARAMETER_CTRL_CHANNEL:
  551. self.host.set_ctrl_channel(self.fPluginId, value)
  552. self.fEditDialog.setParameterValue(parameterId, value)
  553. #------------------------------------------------------------------
  554. def setParameterValue(self, parameterId, value, sendCallback):
  555. if parameterId == PARAMETER_ACTIVE:
  556. return self.setActive(bool(value), True, False)
  557. self.fEditDialog.setParameterValue(parameterId, value)
  558. if sendCallback:
  559. self.fParameterIconTimer = ICON_STATE_ON
  560. self.editDialogParameterValueChanged(self.fPluginId, parameterId, value)
  561. def setParameterDefault(self, parameterId, value):
  562. self.fEditDialog.setParameterDefault(parameterId, value)
  563. def setParameterMidiControl(self, parameterId, control):
  564. self.fEditDialog.setParameterMidiControl(parameterId, control)
  565. def setParameterMidiChannel(self, parameterId, channel):
  566. self.fEditDialog.setParameterMidiChannel(parameterId, channel)
  567. #------------------------------------------------------------------
  568. def setProgram(self, index, sendCallback):
  569. self.fEditDialog.setProgram(index)
  570. if sendCallback:
  571. self.fParameterIconTimer = ICON_STATE_ON
  572. self.editDialogProgramChanged(self.fPluginId, index)
  573. self.updateParameterValues()
  574. def setMidiProgram(self, index, sendCallback):
  575. self.fEditDialog.setMidiProgram(index)
  576. if sendCallback:
  577. self.fParameterIconTimer = ICON_STATE_ON
  578. self.editDialogMidiProgramChanged(self.fPluginId, index)
  579. self.updateParameterValues()
  580. #------------------------------------------------------------------
  581. def setOption(self, option, yesNo):
  582. self.fEditDialog.setOption(option, yesNo)
  583. #------------------------------------------------------------------
  584. def showCustomUI(self):
  585. self.host.show_custom_ui(self.fPluginId, True)
  586. if self.b_gui is not None:
  587. self.b_gui.setChecked(True)
  588. def showEditDialog(self):
  589. self.fEditDialog.show()
  590. self.fEditDialog.activateWindow()
  591. if self.b_edit is not None:
  592. self.b_edit.setChecked(True)
  593. def showRenameDialog(self):
  594. oldName = self.fPluginInfo['name']
  595. newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName)
  596. if not (newNameTry[1] and newNameTry[0] and oldName != newNameTry[0]):
  597. return
  598. newName = newNameTry[0]
  599. if not self.host.rename_plugin(self.fPluginId, newName):
  600. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  601. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  602. return
  603. self.setName(newName)
  604. def showReplaceDialog(self):
  605. data = gCarla.gui.showAddPluginDialog()
  606. if data is None:
  607. return
  608. btype, ptype, filename, label, uniqueId, extraPtr = data
  609. if not self.host.replace_plugin(self.fPluginId):
  610. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to replace plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  611. return
  612. ok = self.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr, 0x0)
  613. self.host.replace_plugin(self.host.get_max_plugin_number())
  614. if not ok:
  615. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  616. #------------------------------------------------------------------
  617. def activeChanged(self, onOff):
  618. self.fIsActive = onOff
  619. if self.b_enable is None:
  620. return
  621. self.b_enable.blockSignals(True)
  622. self.b_enable.setChecked(onOff)
  623. self.b_enable.blockSignals(False)
  624. def customUiStateChanged(self, state):
  625. if self.b_gui is None:
  626. return
  627. self.b_gui.blockSignals(True)
  628. if state == 0:
  629. self.b_gui.setChecked(False)
  630. self.b_gui.setEnabled(True)
  631. elif state == 1:
  632. self.b_gui.setChecked(True)
  633. self.b_gui.setEnabled(True)
  634. elif state == -1:
  635. self.b_gui.setChecked(False)
  636. self.b_gui.setEnabled(False)
  637. self.b_gui.blockSignals(False)
  638. def parameterActivityChanged(self, onOff):
  639. if self.led_control is None:
  640. return
  641. self.led_control.setChecked(onOff)
  642. def midiActivityChanged(self, onOff):
  643. if self.led_midi is None:
  644. return
  645. self.led_midi.setChecked(onOff)
  646. def optionChanged(self, option, yesNo):
  647. pass
  648. # -----------------------------------------------------------------
  649. # PluginEdit callbacks
  650. def editDialogVisibilityChanged(self, pluginId, visible):
  651. if self.b_edit is None:
  652. return
  653. self.b_edit.blockSignals(True)
  654. self.b_edit.setChecked(visible)
  655. self.b_edit.blockSignals(False)
  656. def editDialogPluginHintsChanged(self, pluginId, hints):
  657. self.fPluginInfo['hints'] = hints
  658. for paramIndex, paramWidget in self.fParameterList:
  659. if paramIndex == PARAMETER_DRYWET:
  660. paramWidget.setVisible(hints & PLUGIN_CAN_DRYWET)
  661. elif paramIndex == PARAMETER_VOLUME:
  662. paramWidget.setVisible(hints & PLUGIN_CAN_VOLUME)
  663. if self.b_gui is not None:
  664. self.b_gui.setEnabled(bool(hints & PLUGIN_HAS_CUSTOM_UI))
  665. def editDialogParameterValueChanged(self, pluginId, parameterId, value):
  666. for paramIndex, paramWidget in self.fParameterList:
  667. if paramIndex != parameterId:
  668. continue
  669. paramWidget.blockSignals(True)
  670. paramWidget.setValue(value)
  671. paramWidget.blockSignals(False)
  672. break
  673. def editDialogProgramChanged(self, pluginId, index):
  674. if self.cb_presets is None:
  675. return
  676. self.cb_presets.blockSignals(True)
  677. self.cb_presets.setCurrentIndex(index)
  678. self.cb_presets.blockSignals(False)
  679. # FIXME
  680. self.updateParameterValues()
  681. def editDialogMidiProgramChanged(self, pluginId, index):
  682. if self.cb_presets is None:
  683. return
  684. self.cb_presets.blockSignals(True)
  685. self.cb_presets.setCurrentIndex(index)
  686. self.cb_presets.blockSignals(False)
  687. # FIXME
  688. self.updateParameterValues()
  689. def editDialogNotePressed(self, pluginId, note):
  690. pass
  691. def editDialogNoteReleased(self, pluginId, note):
  692. pass
  693. def editDialogMidiActivityChanged(self, pluginId, onOff):
  694. self.midiActivityChanged(onOff)
  695. #------------------------------------------------------------------
  696. def idleFast(self):
  697. # Input peaks
  698. if self.fPeaksInputCount > 0:
  699. if self.fPeaksInputCount > 1:
  700. peak1 = self.host.get_input_peak_value(self.fPluginId, True)
  701. peak2 = self.host.get_input_peak_value(self.fPluginId, False)
  702. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  703. if self.peak_in is not None:
  704. self.peak_in.displayMeter(1, peak1)
  705. self.peak_in.displayMeter(2, peak2)
  706. else:
  707. peak = self.host.get_input_peak_value(self.fPluginId, True)
  708. ledState = bool(peak != 0.0)
  709. if self.peak_in is not None:
  710. self.peak_in.displayMeter(1, peak)
  711. if self.fLastGreenLedState != ledState and self.led_audio_in is not None:
  712. self.fLastGreenLedState = ledState
  713. self.led_audio_in.setChecked(ledState)
  714. # Output peaks
  715. if self.fPeaksOutputCount > 0:
  716. if self.fPeaksOutputCount > 1:
  717. peak1 = self.host.get_output_peak_value(self.fPluginId, True)
  718. peak2 = self.host.get_output_peak_value(self.fPluginId, False)
  719. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  720. if self.peak_out is not None:
  721. self.peak_out.displayMeter(1, peak1)
  722. self.peak_out.displayMeter(2, peak2)
  723. else:
  724. peak = self.host.get_output_peak_value(self.fPluginId, True)
  725. ledState = bool(peak != 0.0)
  726. if self.peak_out is not None:
  727. self.peak_out.displayMeter(1, peak)
  728. if self.fLastBlueLedState != ledState and self.led_audio_out is not None:
  729. self.fLastBlueLedState = ledState
  730. self.led_audio_out.setChecked(ledState)
  731. def idleSlow(self):
  732. if self.fParameterIconTimer == ICON_STATE_ON:
  733. self.parameterActivityChanged(True)
  734. self.fParameterIconTimer = ICON_STATE_WAIT
  735. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  736. self.fParameterIconTimer = ICON_STATE_OFF
  737. elif self.fParameterIconTimer == ICON_STATE_OFF:
  738. self.parameterActivityChanged(False)
  739. self.fParameterIconTimer = ICON_STATE_NULL
  740. self.fEditDialog.idleSlow()
  741. #------------------------------------------------------------------
  742. def drawOutline(self):
  743. painter = QPainter(self)
  744. if self.fIsSelected:
  745. painter.setPen(QPen(Qt.cyan, 4))
  746. painter.setBrush(Qt.transparent)
  747. painter.drawRect(0, 0, self.width(), self.height())
  748. else:
  749. painter.setPen(QPen(Qt.black, 1))
  750. painter.setBrush(Qt.black)
  751. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  752. def updateParameterValues(self):
  753. for paramIndex, paramWidget in self.fParameterList:
  754. if paramIndex < 0:
  755. continue
  756. paramWidget.blockSignals(True)
  757. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramIndex))
  758. paramWidget.blockSignals(False)
  759. #------------------------------------------------------------------
  760. @pyqtSlot(bool)
  761. def slot_enableClicked(self, yesNo):
  762. self.setActive(yesNo, False, True)
  763. @pyqtSlot()
  764. def slot_showCustomMenu(self):
  765. menu = QMenu(self)
  766. # -------------------------------------------------------------
  767. # Expand/Minimize
  768. actCompact = menu.addAction(self.tr("Expand") if isinstance(self, PluginSlot_Compact) else self.tr("Minimize"))
  769. menu.addSeparator()
  770. # -------------------------------------------------------------
  771. # Move up and down
  772. actMoveUp = menu.addAction(self.tr("Move Up"))
  773. actMoveDown = menu.addAction(self.tr("Move Down"))
  774. if self.fPluginId == 0:
  775. actMoveUp.setEnabled(False)
  776. if self.fPluginId >= self.fParent.getPluginCount():
  777. actMoveDown.setEnabled(False)
  778. # -------------------------------------------------------------
  779. # Bypass and Enable/Disable
  780. actBypass = menu.addAction(self.tr("Bypass"))
  781. actEnable = menu.addAction(self.tr("Disable") if self.fIsActive else self.tr("Enable"))
  782. menu.addSeparator()
  783. if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET:
  784. actBypass.setCheckable(True)
  785. actBypass.setChecked(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_DRYWET) == 0.0)
  786. else:
  787. actBypass.setVisible(False)
  788. # -------------------------------------------------------------
  789. # Reset and Randomize parameters
  790. actReset = menu.addAction(self.tr("Reset parameters"))
  791. actRandom = menu.addAction(self.tr("Randomize parameters"))
  792. menu.addSeparator()
  793. # -------------------------------------------------------------
  794. # Edit and Show Custom UI
  795. actEdit = menu.addAction(self.tr("Edit"))
  796. actGui = menu.addAction(self.tr("Show Custom UI"))
  797. menu.addSeparator()
  798. if self.b_edit is not None:
  799. actEdit.setCheckable(True)
  800. actEdit.setChecked(self.b_edit.isChecked())
  801. else:
  802. actEdit.setVisible(False)
  803. if self.b_gui is not None:
  804. actGui.setCheckable(True)
  805. actGui.setChecked(self.b_gui.isChecked())
  806. actGui.setEnabled(self.b_gui.isEnabled())
  807. else:
  808. actGui.setVisible(False)
  809. # -------------------------------------------------------------
  810. # Other stuff
  811. actClone = menu.addAction(self.tr("Clone"))
  812. actRename = menu.addAction(self.tr("Rename..."))
  813. actReplace = menu.addAction(self.tr("Replace..."))
  814. actRemove = menu.addAction(self.tr("Remove"))
  815. if self.fIdleTimerId != 0:
  816. actRemove.setVisible(False)
  817. if self.host.exportLV2:
  818. menu.addSeparator()
  819. actExportLV2 = menu.addAction(self.tr("Export LV2..."))
  820. else:
  821. actExportLV2 = None
  822. # -------------------------------------------------------------
  823. # exec
  824. actSel = menu.exec_(QCursor.pos())
  825. if not actSel:
  826. return
  827. # -------------------------------------------------------------
  828. # Expand/Minimize
  829. elif actSel == actCompact:
  830. # FIXME
  831. gCarla.gui.compactPlugin(self.fPluginId)
  832. # -------------------------------------------------------------
  833. # Move up and down
  834. elif actSel == actMoveUp:
  835. gCarla.gui.switchPlugins(self.fPluginId, self.fPluginId-1)
  836. elif actSel == actMoveDown:
  837. gCarla.gui.switchPlugins(self.fPluginId, self.fPluginId+1)
  838. # -------------------------------------------------------------
  839. # Bypass and Enable/Disable
  840. elif actSel == actBypass:
  841. value = 0.0 if actBypass.isChecked() else 1.0
  842. self.host.set_drywet(self.fPluginId, value)
  843. self.setParameterValue(PARAMETER_DRYWET, value, True)
  844. elif actSel == actEnable:
  845. self.setActive(not self.fIsActive, True, True)
  846. # -------------------------------------------------------------
  847. # Reset and Randomize parameters
  848. elif actSel == actReset:
  849. self.host.reset_parameters(self.fPluginId)
  850. elif actSel == actRandom:
  851. self.host.randomize_parameters(self.fPluginId)
  852. # -------------------------------------------------------------
  853. # Edit and Show Custom UI
  854. elif actSel == actEdit:
  855. self.b_edit.click()
  856. elif actSel == actGui:
  857. self.b_gui.click()
  858. # -------------------------------------------------------------
  859. # Clone
  860. elif actSel == actClone:
  861. if not self.host.clone_plugin(self.fPluginId):
  862. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  863. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  864. # -------------------------------------------------------------
  865. # Rename
  866. elif actSel == actRename:
  867. self.showRenameDialog()
  868. # -------------------------------------------------------------
  869. # Replace
  870. elif actSel == actReplace:
  871. self.showReplaceDialog()
  872. # -------------------------------------------------------------
  873. # Remove
  874. elif actSel == actRemove:
  875. if not self.host.remove_plugin(self.fPluginId):
  876. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  877. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  878. # -------------------------------------------------------------
  879. # Export LV2
  880. elif actSel == actExportLV2:
  881. filepath = QInputDialog.getItem(self, self.tr("Export LV2 Plugin"),
  882. self.tr("Select LV2 Path where plugin will be exported to:"),
  883. CARLA_DEFAULT_LV2_PATH, editable=False)
  884. if not all(filepath):
  885. return
  886. plugname = self.fPluginInfo['name']
  887. filepath = os.path.join(filepath[0], plugname.replace(" ","_"))
  888. if not filepath.endswith(".lv2"):
  889. filepath += ".lv2"
  890. if os.path.exists(filepath):
  891. if QMessageBox.question(self, self.tr("Export to LV2"),
  892. self.tr("Plugin bundle already exists, overwrite?")) == QMessageBox.Ok:
  893. return
  894. if not self.host.export_plugin_lv2(self.fPluginId, filepath):
  895. return CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  896. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  897. QMessageBox.information(self, self.tr("Plugin exported"),
  898. self.tr("Plugin exported successfully, saved in folder:\n%s" % filepath))
  899. # -------------------------------------------------------------
  900. @pyqtSlot()
  901. def slot_knobCustomMenu(self):
  902. sender = self.sender()
  903. index = sender.fIndex
  904. minimum = sender.fMinimum
  905. maximum = sender.fMaximum
  906. current = sender.fRealValue
  907. label = sender.fLabel
  908. if index in (PARAMETER_NULL, PARAMETER_CTRL_CHANNEL) or index <= PARAMETER_MAX:
  909. return
  910. elif index in (PARAMETER_DRYWET, PARAMETER_VOLUME):
  911. default = 1.0
  912. elif index == PARAMETER_BALANCE_LEFT:
  913. default = -1.0
  914. elif index == PARAMETER_BALANCE_RIGHT:
  915. default = 1.0
  916. elif index == PARAMETER_PANNING:
  917. default = 0.0
  918. else:
  919. default = self.host.get_default_parameter_value(self.fPluginId, index)
  920. if index < PARAMETER_NULL:
  921. # show in integer percentage
  922. textReset = self.tr("Reset (%i%%)" % round(default*100.0))
  923. textMinim = self.tr("Set to Minimum (%i%%)" % round(minimum*100.0))
  924. textMaxim = self.tr("Set to Maximum (%i%%)" % round(maximum*100.0))
  925. else:
  926. # show in full float value
  927. textReset = self.tr("Reset (%f)" % default)
  928. textMinim = self.tr("Set to Minimum (%f)" % minimum)
  929. textMaxim = self.tr("Set to Maximum (%f)" % maximum)
  930. menu = QMenu(self)
  931. actReset = menu.addAction(textReset)
  932. menu.addSeparator()
  933. actMinimum = menu.addAction(textMinim)
  934. actCenter = menu.addAction(self.tr("Set to Center"))
  935. actMaximum = menu.addAction(textMaxim)
  936. menu.addSeparator()
  937. actSet = menu.addAction(self.tr("Set value..."))
  938. if index > PARAMETER_NULL or index not in (PARAMETER_BALANCE_LEFT, PARAMETER_BALANCE_RIGHT, PARAMETER_PANNING):
  939. menu.removeAction(actCenter)
  940. actSelected = menu.exec_(QCursor.pos())
  941. if actSelected == actSet:
  942. if index < PARAMETER_NULL:
  943. value, ok = QInputDialog.getInt(self, self.tr("Set value"), label, round(current*100), round(minimum*100), round(maximum*100), 1)
  944. if not ok:
  945. return
  946. value = float(value)/100.0
  947. else:
  948. paramInfo = self.host.get_parameter_info(self.fPluginId, index)
  949. paramRanges = self.host.get_parameter_ranges(self.fPluginId, index)
  950. scalePoints = []
  951. for i in range(paramInfo['scalePointCount']):
  952. scalePoints.append(self.host.get_parameter_scalepoint_info(self.fPluginId, index, i))
  953. dialog = CustomInputDialog(self, label, current, minimum, maximum,
  954. paramRanges['step'], paramRanges['stepSmall'], scalePoints)
  955. if not dialog.exec_():
  956. return
  957. value = dialog.returnValue()
  958. elif actSelected == actMinimum:
  959. value = minimum
  960. elif actSelected == actMaximum:
  961. value = maximum
  962. elif actSelected == actReset:
  963. value = default
  964. elif actSelected == actCenter:
  965. value = 0.0
  966. else:
  967. return
  968. sender.setValue(value, True)
  969. #------------------------------------------------------------------
  970. @pyqtSlot(bool)
  971. def slot_showCustomUi(self, show):
  972. self.host.show_custom_ui(self.fPluginId, show)
  973. @pyqtSlot(bool)
  974. def slot_showEditDialog(self, show):
  975. self.fEditDialog.setVisible(show)
  976. @pyqtSlot()
  977. def slot_removePlugin(self):
  978. if not self.host.remove_plugin(self.fPluginId):
  979. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  980. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  981. #------------------------------------------------------------------
  982. @pyqtSlot(float)
  983. def slot_parameterValueChanged(self, value):
  984. index = self.sender().getIndex()
  985. if index < 0:
  986. self.setInternalParameter(index, value)
  987. else:
  988. self.host.set_parameter_value(self.fPluginId, index, value)
  989. self.setParameterValue(index, value, False)
  990. @pyqtSlot(int)
  991. def slot_programChanged(self, index):
  992. self.host.set_program(self.fPluginId, index)
  993. self.setProgram(index, False)
  994. @pyqtSlot(int)
  995. def slot_midiProgramChanged(self, index):
  996. self.host.set_midi_program(self.fPluginId, index)
  997. self.setMidiProgram(index, False)
  998. #------------------------------------------------------------------
  999. def testTimer(self):
  1000. self.fIdleTimerId = self.startTimer(25)
  1001. #------------------------------------------------------------------
  1002. def mouseDoubleClickEvent(self, event):
  1003. QFrame.mouseDoubleClickEvent(self, event)
  1004. # FIXME
  1005. gCarla.gui.compactPlugin(self.fPluginId)
  1006. def closeEvent(self, event):
  1007. if self.fIdleTimerId != 0:
  1008. self.killTimer(self.fIdleTimerId)
  1009. self.fIdleTimerId = 0
  1010. self.host.engine_close()
  1011. QFrame.closeEvent(self, event)
  1012. def timerEvent(self, event):
  1013. if event.timerId() == self.fIdleTimerId:
  1014. self.host.engine_idle()
  1015. self.idleFast()
  1016. self.idleSlow()
  1017. QFrame.timerEvent(self, event)
  1018. def paintEvent(self, event):
  1019. self.drawOutline()
  1020. QFrame.paintEvent(self, event)
  1021. # ------------------------------------------------------------------------------------------------------------
  1022. class PluginSlot_Calf(AbstractPluginSlot):
  1023. def __init__(self, parent, host, pluginId, skinStyle):
  1024. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1025. self.ui = ui_carla_plugin_calf.Ui_PluginWidget()
  1026. self.ui.setupUi(self)
  1027. audioCount = self.host.get_audio_port_count_info(self.fPluginId)
  1028. midiCount = self.host.get_midi_port_count_info(self.fPluginId)
  1029. # -------------------------------------------------------------
  1030. # Internal stuff
  1031. self.fButtonFont = self.ui.b_gui.font()
  1032. self.fButtonFont.setBold(False)
  1033. self.fButtonFont.setPixelSize(10)
  1034. self.fButtonColorOn = QColor( 18, 41, 87)
  1035. self.fButtonColorOff = QColor(150, 150, 150)
  1036. # -------------------------------------------------------------
  1037. # Set-up GUI
  1038. self.ui.label_active.setFont(self.fButtonFont)
  1039. self.ui.b_remove.setPixmaps(":/bitmaps/button_calf1.png", ":/bitmaps/button_calf1_down.png", ":/bitmaps/button_calf1_hover.png")
  1040. self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont)
  1041. self.ui.b_remove.setTopText(self.tr("Remove"), self.fButtonColorOn, self.fButtonFont)
  1042. if self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI:
  1043. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  1044. else:
  1045. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  1046. if audioCount['ins'] == 0:
  1047. self.ui.label_audio_in.hide()
  1048. if audioCount['outs'] == 0:
  1049. self.ui.label_audio_out.hide()
  1050. if midiCount['ins'] == 0:
  1051. self.ui.label_midi.hide()
  1052. self.ui.led_midi.hide()
  1053. if self.fIdleTimerId != 0:
  1054. self.ui.b_remove.setEnabled(False)
  1055. self.ui.b_remove.setVisible(False)
  1056. # -------------------------------------------------------------
  1057. self.b_enable = self.ui.b_enable
  1058. self.b_gui = self.ui.b_gui
  1059. self.b_edit = self.ui.b_edit
  1060. self.b_remove = self.ui.b_remove
  1061. self.label_name = self.ui.label_name
  1062. self.led_midi = self.ui.led_midi
  1063. self.peak_in = self.ui.peak_in
  1064. self.peak_out = self.ui.peak_out
  1065. self.w_knobs_left = self.ui.w_knobs
  1066. self.ready()
  1067. self.ui.led_midi.setColor(self.ui.led_midi.CALF)
  1068. #------------------------------------------------------------------
  1069. def getFixedHeight(self):
  1070. return 94 if max(self.peak_in.channelCount(), self.peak_out.channelCount()) < 2 else 106
  1071. #------------------------------------------------------------------
  1072. def editDialogPluginHintsChanged(self, pluginId, hints):
  1073. if hints & PLUGIN_HAS_CUSTOM_UI:
  1074. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  1075. else:
  1076. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  1077. AbstractPluginSlot.editDialogPluginHintsChanged(self, pluginId, hints)
  1078. #------------------------------------------------------------------
  1079. def paintEvent(self, event):
  1080. isBlack = bool(self.fSkinStyle == "calf_black")
  1081. painter = QPainter(self)
  1082. painter.setBrush(Qt.transparent)
  1083. painter.setPen(QPen(QColor(20, 20, 20) if isBlack else QColor(75, 86, 99), 1))
  1084. painter.drawRect(0, 1, self.width()-1, self.height()-3)
  1085. painter.setPen(QPen(QColor(45, 45, 45) if isBlack else QColor(86, 99, 114), 1))
  1086. painter.drawLine(0, 0, self.width(), 0)
  1087. AbstractPluginSlot.paintEvent(self, event)
  1088. # ------------------------------------------------------------------------------------------------------------
  1089. class PluginSlot_Classic(AbstractPluginSlot):
  1090. def __init__(self, parent, host, pluginId):
  1091. AbstractPluginSlot.__init__(self, parent, host, pluginId, "classic")
  1092. self.ui = ui_carla_plugin_classic.Ui_PluginWidget()
  1093. self.ui.setupUi(self)
  1094. # -------------------------------------------------------------
  1095. # Internal stuff
  1096. self.fColorTop = QColor(60, 60, 60)
  1097. self.fColorBottom = QColor(47, 47, 47)
  1098. self.fColorSeprtr = QColor(70, 70, 70)
  1099. # -------------------------------------------------------------
  1100. self.b_enable = self.ui.b_enable
  1101. self.b_gui = self.ui.b_gui
  1102. self.b_edit = self.ui.b_edit
  1103. self.label_name = self.ui.label_name
  1104. self.led_control = self.ui.led_control
  1105. self.led_midi = self.ui.led_midi
  1106. self.led_audio_in = self.ui.led_audio_in
  1107. self.led_audio_out = self.ui.led_audio_out
  1108. self.peak_in = self.ui.peak_in
  1109. self.peak_out = self.ui.peak_out
  1110. self.ready()
  1111. #------------------------------------------------------------------
  1112. def getFixedHeight(self):
  1113. return 36
  1114. #------------------------------------------------------------------
  1115. def paintEvent(self, event):
  1116. painter = QPainter(self)
  1117. painter.save()
  1118. areaX = self.ui.area_right.x()+7
  1119. width = self.width()
  1120. height = self.height()
  1121. painter.setPen(QPen(QColor(17, 17, 17), 1))
  1122. painter.setBrush(QColor(17, 17, 17))
  1123. painter.drawRect(0, 0, width, height)
  1124. painter.setPen(self.fColorSeprtr.lighter(110))
  1125. painter.setBrush(self.fColorBottom)
  1126. painter.setRenderHint(QPainter.Antialiasing, True)
  1127. # name -> leds arc
  1128. path = QPainterPath()
  1129. path.moveTo(areaX-20, height-4)
  1130. path.cubicTo(areaX, height-5, areaX-20, 4.75, areaX, 4.75)
  1131. path.lineTo(areaX, height-5)
  1132. painter.drawPath(path)
  1133. painter.setPen(self.fColorSeprtr)
  1134. painter.setRenderHint(QPainter.Antialiasing, False)
  1135. # separator lines
  1136. painter.drawLine(0, height-5, areaX-20, height-5)
  1137. painter.drawLine(areaX, 4, width, 4)
  1138. painter.setPen(self.fColorBottom)
  1139. painter.setBrush(self.fColorBottom)
  1140. # top, bottom and left lines
  1141. painter.drawLine(0, 0, width, 0)
  1142. painter.drawRect(0, height-4, areaX, 4)
  1143. painter.drawRoundedRect(areaX-20, height-5, areaX, 5, 22, 22)
  1144. painter.drawLine(0, 0, 0, height)
  1145. # fill the rest
  1146. painter.drawRect(areaX-1, 5, width, height)
  1147. # bottom 1px line
  1148. painter.setPen(self.fColorSeprtr)
  1149. painter.drawLine(0, height-1, width, height-1)
  1150. painter.restore()
  1151. AbstractPluginSlot.paintEvent(self, event)
  1152. # ------------------------------------------------------------------------------------------------------------
  1153. class PluginSlot_Compact(AbstractPluginSlot):
  1154. def __init__(self, parent, host, pluginId, skinStyle):
  1155. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1156. self.ui = ui_carla_plugin_compact.Ui_PluginWidget()
  1157. self.ui.setupUi(self)
  1158. self.b_enable = self.ui.b_enable
  1159. self.b_gui = self.ui.b_gui
  1160. self.b_edit = self.ui.b_edit
  1161. self.label_name = self.ui.label_name
  1162. self.led_control = self.ui.led_control
  1163. self.led_midi = self.ui.led_midi
  1164. self.led_audio_in = self.ui.led_audio_in
  1165. self.led_audio_out = self.ui.led_audio_out
  1166. self.peak_in = self.ui.peak_in
  1167. self.peak_out = self.ui.peak_out
  1168. self.ready()
  1169. #------------------------------------------------------------------
  1170. def getFixedHeight(self):
  1171. if self.fSkinStyle == "calf_blue":
  1172. return 36
  1173. return 30
  1174. # ------------------------------------------------------------------------------------------------------------
  1175. class PluginSlot_Default(AbstractPluginSlot):
  1176. def __init__(self, parent, host, pluginId, skinStyle):
  1177. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1178. self.ui = ui_carla_plugin_default.Ui_PluginWidget()
  1179. self.ui.setupUi(self)
  1180. # -------------------------------------------------------------
  1181. self.b_enable = self.ui.b_enable
  1182. self.b_gui = self.ui.b_gui
  1183. self.b_edit = self.ui.b_edit
  1184. self.label_name = self.ui.label_name
  1185. self.led_control = self.ui.led_control
  1186. self.led_midi = self.ui.led_midi
  1187. self.led_audio_in = self.ui.led_audio_in
  1188. self.led_audio_out = self.ui.led_audio_out
  1189. self.peak_in = self.ui.peak_in
  1190. self.peak_out = self.ui.peak_out
  1191. self.w_knobs_left = self.ui.w_knobs_left
  1192. self.w_knobs_right = self.ui.w_knobs_right
  1193. self.ready()
  1194. #------------------------------------------------------------------
  1195. def getFixedHeight(self):
  1196. return 80
  1197. #------------------------------------------------------------------
  1198. def paintEvent(self, event):
  1199. painter = QPainter(self)
  1200. painter.setBrush(Qt.transparent)
  1201. painter.setPen(QPen(QColor(42, 42, 42), 1))
  1202. painter.drawRect(0, 1, self.width()-1, self.getFixedHeight()-3)
  1203. painter.setPen(QPen(QColor(60, 60, 60), 1))
  1204. painter.drawLine(0, 0, self.width(), 0)
  1205. AbstractPluginSlot.paintEvent(self, event)
  1206. # ------------------------------------------------------------------------------------------------------------
  1207. class PluginSlot_Presets(AbstractPluginSlot):
  1208. def __init__(self, parent, host, pluginId, skinStyle):
  1209. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1210. self.ui = ui_carla_plugin_presets.Ui_PluginWidget()
  1211. self.ui.setupUi(self)
  1212. usingMidiPrograms = bool(skinStyle != "presets")
  1213. # -------------------------------------------------------------
  1214. # Set-up programs
  1215. if usingMidiPrograms:
  1216. programCount = self.host.get_midi_program_count(self.fPluginId)
  1217. else:
  1218. programCount = self.host.get_program_count(self.fPluginId)
  1219. if programCount > 0:
  1220. self.ui.cb_presets.setEnabled(True)
  1221. self.ui.label_presets.setEnabled(True)
  1222. for i in range(programCount):
  1223. if usingMidiPrograms:
  1224. progName = self.host.get_midi_program_data(self.fPluginId, i)['name']
  1225. else:
  1226. progName = self.host.get_program_name(self.fPluginId, i)
  1227. self.ui.cb_presets.addItem(progName)
  1228. if usingMidiPrograms:
  1229. curProg = self.host.get_current_midi_program_index(self.fPluginId)
  1230. else:
  1231. curProg = self.host.get_current_program_index(self.fPluginId)
  1232. self.ui.cb_presets.setCurrentIndex(curProg)
  1233. else:
  1234. self.ui.cb_presets.setEnabled(False)
  1235. self.ui.cb_presets.setVisible(False)
  1236. self.ui.label_presets.setEnabled(False)
  1237. self.ui.label_presets.setVisible(False)
  1238. # -------------------------------------------------------------
  1239. self.b_enable = self.ui.b_enable
  1240. self.b_gui = self.ui.b_gui
  1241. self.b_edit = self.ui.b_edit
  1242. self.cb_presets = self.ui.cb_presets
  1243. self.label_name = self.ui.label_name
  1244. self.label_presets = self.ui.label_presets
  1245. self.led_control = self.ui.led_control
  1246. self.led_midi = self.ui.led_midi
  1247. self.led_audio_in = self.ui.led_audio_in
  1248. self.led_audio_out = self.ui.led_audio_out
  1249. self.peak_in = self.ui.peak_in
  1250. self.peak_out = self.ui.peak_out
  1251. if skinStyle == "zynfx":
  1252. self.setupZynFxParams()
  1253. else:
  1254. self.w_knobs_left = self.ui.w_knobs_left
  1255. self.w_knobs_right = self.ui.w_knobs_right
  1256. self.ready()
  1257. if usingMidiPrograms:
  1258. self.ui.cb_presets.currentIndexChanged.connect(self.slot_midiProgramChanged)
  1259. else:
  1260. self.ui.cb_presets.currentIndexChanged.connect(self.slot_programChanged)
  1261. # -------------------------------------------------------------
  1262. def setupZynFxParams(self):
  1263. parameterCount = self.host.get_parameter_count(self.fPluginId)
  1264. index = 0
  1265. for i in range(parameterCount):
  1266. if index >= 8:
  1267. break
  1268. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  1269. paramData = self.host.get_parameter_data(self.fPluginId, i)
  1270. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  1271. if paramData['type'] != PARAMETER_INPUT:
  1272. continue
  1273. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  1274. continue
  1275. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1276. continue
  1277. paramName = paramInfo['name']
  1278. if paramName.startswith("unused"):
  1279. continue
  1280. # real zyn fx plugins
  1281. if self.fPluginInfo['label'] == "zynalienwah":
  1282. if i == 0: paramName = "Freq"
  1283. elif i == 1: paramName = "Rnd"
  1284. elif i == 2: paramName = "L type" # combobox
  1285. elif i == 3: paramName = "St.df"
  1286. elif i == 5: paramName = "Fb"
  1287. elif i == 7: paramName = "L/R"
  1288. elif self.fPluginInfo['label'] == "zynchorus":
  1289. if i == 0: paramName = "Freq"
  1290. elif i == 1: paramName = "Rnd"
  1291. elif i == 2: paramName = "L type" # combobox
  1292. elif i == 3: paramName = "St.df"
  1293. elif i == 6: paramName = "Fb"
  1294. elif i == 7: paramName = "L/R"
  1295. elif i == 8: paramName = "Flngr" # button
  1296. elif i == 9: paramName = "Subst" # button
  1297. elif self.fPluginInfo['label'] == "zyndistortion":
  1298. if i == 0: paramName = "LRc."
  1299. elif i == 4: paramName = "Neg." # button
  1300. elif i == 5: paramName = "LPF"
  1301. elif i == 6: paramName = "HPF"
  1302. elif i == 7: paramName = "St." # button
  1303. elif i == 8: paramName = "PF" # button
  1304. elif self.fPluginInfo['label'] == "zyndynamicfilter":
  1305. if i == 0: paramName = "Freq"
  1306. elif i == 1: paramName = "Rnd"
  1307. elif i == 2: paramName = "L type" # combobox
  1308. elif i == 3: paramName = "St.df"
  1309. elif i == 4: paramName = "LfoD"
  1310. elif i == 5: paramName = "A.S."
  1311. elif i == 6: paramName = "A.Inv." # button
  1312. elif i == 7: paramName = "A.M."
  1313. elif self.fPluginInfo['label'] == "zynecho":
  1314. if i == 1: paramName = "LRdl."
  1315. elif i == 2: paramName = "LRc."
  1316. elif i == 3: paramName = "Fb."
  1317. elif i == 4: paramName = "Damp"
  1318. elif self.fPluginInfo['label'] == "zynphaser":
  1319. if i == 0: paramName = "Freq"
  1320. elif i == 1: paramName = "Rnd"
  1321. elif i == 2: paramName = "L type" # combobox
  1322. elif i == 3: paramName = "St.df"
  1323. elif i == 5: paramName = "Fb"
  1324. elif i == 7: paramName = "L/R"
  1325. elif i == 8: paramName = "Subst" # button
  1326. elif i == 9: paramName = "Phase"
  1327. elif i == 11: paramName = "Dist"
  1328. elif self.fPluginInfo['label'] == "zynreverb":
  1329. if i == 2: paramName = "I.delfb"
  1330. elif i == 5: paramName = "LPF"
  1331. elif i == 6: paramName = "HPF"
  1332. elif i == 9: paramName = "R.S."
  1333. elif i == 10: paramName = "I.del"
  1334. else:
  1335. paramName = getParameterShortName(paramName)
  1336. widget = PixmapDial(self, i)
  1337. widget.setLabel(paramName)
  1338. widget.setMinimum(paramRanges['min'])
  1339. widget.setMaximum(paramRanges['max'])
  1340. widget.setPixmap(3)
  1341. widget.setCustomPaintColor(QColor(83, 173, 10))
  1342. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  1343. widget.forceWhiteLabelGradientText()
  1344. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1345. widget.setEnabled(False)
  1346. self.fParameterList.append([i, widget])
  1347. self.ui.w_knobs_left.layout().addWidget(widget)
  1348. if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET:
  1349. widget = PixmapDial(self, PARAMETER_DRYWET)
  1350. widget.setLabel("Wet")
  1351. widget.setMinimum(0.0)
  1352. widget.setMaximum(1.0)
  1353. widget.setPixmap(3)
  1354. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  1355. widget.forceWhiteLabelGradientText()
  1356. self.fParameterList.append([PARAMETER_DRYWET, widget])
  1357. self.ui.w_knobs_right.layout().addWidget(widget)
  1358. if self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME:
  1359. widget = PixmapDial(self, PARAMETER_VOLUME)
  1360. widget.setLabel("Volume")
  1361. widget.setMinimum(0.0)
  1362. widget.setMaximum(1.27)
  1363. widget.setPixmap(3)
  1364. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  1365. widget.forceWhiteLabelGradientText()
  1366. self.fParameterList.append([PARAMETER_VOLUME, widget])
  1367. self.ui.w_knobs_right.layout().addWidget(widget)
  1368. #------------------------------------------------------------------
  1369. def getFixedHeight(self):
  1370. return 80
  1371. #------------------------------------------------------------------
  1372. def paintEvent(self, event):
  1373. painter = QPainter(self)
  1374. painter.setBrush(Qt.transparent)
  1375. painter.setPen(QPen(QColor(50, 50, 50), 1))
  1376. painter.drawRect(0, 1, self.width()-1, self.height()-3)
  1377. painter.setPen(QPen(QColor(64, 64, 64), 1))
  1378. painter.drawLine(0, 0, self.width(), 0)
  1379. AbstractPluginSlot.paintEvent(self, event)
  1380. # ------------------------------------------------------------------------------------------------------------
  1381. def getSkinStyle(host, pluginId):
  1382. if False:
  1383. # kdevelop likes this :)
  1384. host = CarlaHostNull()
  1385. progCount = 0
  1386. pluginInfo = PyCarlaPluginInfo
  1387. pluginName = ""
  1388. pluginInfo = host.get_plugin_info(pluginId)
  1389. pluginName = host.get_real_plugin_name(pluginId)
  1390. pluginLabel = pluginInfo['label'].lower()
  1391. pluginMaker = pluginInfo['maker']
  1392. uniqueId = pluginInfo['uniqueId']
  1393. if pluginInfo['type'] == PLUGIN_VST2:
  1394. progCount = host.get_program_count(pluginId)
  1395. else:
  1396. progCount = host.get_midi_program_count(pluginId)
  1397. # Samplers
  1398. if pluginInfo['type'] == PLUGIN_SF2:
  1399. return "sf2"
  1400. if pluginInfo['type'] == PLUGIN_SFZ:
  1401. return "sfz"
  1402. # Calf
  1403. if pluginName.split(" ", 1)[0].lower() == "calf":
  1404. return "calf_black" if "mono" in pluginLabel else "calf_blue"
  1405. # OpenAV
  1406. if pluginMaker == "OpenAV Productions":
  1407. return "openav-old"
  1408. if pluginMaker == "OpenAV":
  1409. return "openav"
  1410. # ZynFX
  1411. if pluginInfo['type'] == PLUGIN_INTERNAL:
  1412. if pluginLabel.startswith("zyn") and pluginInfo['category'] != PLUGIN_CATEGORY_SYNTH:
  1413. return "zynfx"
  1414. if pluginInfo['type'] == PLUGIN_LADSPA:
  1415. if pluginLabel.startswith("zyn") and pluginMaker.startswith("Josep Andreu"):
  1416. return "zynfx"
  1417. if pluginInfo['type'] == PLUGIN_LV2:
  1418. if pluginLabel.startswith("http://kxstudio.sf.net/carla/plugins/zyn") and pluginName != "ZynAddSubFX":
  1419. return "zynfx"
  1420. # Presets
  1421. if progCount > 1 and (pluginInfo['hints'] & PLUGIN_USES_MULTI_PROGS) == 0:
  1422. if pluginInfo['type'] == PLUGIN_VST2:
  1423. return "presets"
  1424. return "mpresets"
  1425. # DISTRHO Plugins (needs to be last)
  1426. if pluginMaker.startswith("falkTX, ") or pluginMaker == "DISTRHO" or pluginLabel.startswith("http://distrho.sf.net/plugins/"):
  1427. return pluginLabel.replace("http://distrho.sf.net/plugins/","")
  1428. return "default"
  1429. def createPluginSlot(parent, host, pluginId, options):
  1430. if not options['useSkins']:
  1431. return PluginSlot_Classic(parent, host, pluginId)
  1432. skinStyle = getSkinStyle(host, pluginId)
  1433. if "compact" in skinStyle or options['compact']:
  1434. return PluginSlot_Compact(parent, host, pluginId, skinStyle)
  1435. if skinStyle.startswith("calf"):
  1436. return PluginSlot_Calf(parent, host, pluginId, skinStyle)
  1437. if skinStyle in ("mpresets", "presets", "zynfx"):
  1438. return PluginSlot_Presets(parent, host, pluginId, skinStyle)
  1439. return PluginSlot_Default(parent, host, pluginId, skinStyle)
  1440. # ------------------------------------------------------------------------------------------------------------
  1441. # Main Testing
  1442. if __name__ == '__main__':
  1443. from carla_app import CarlaApplication
  1444. from carla_host import initHost, loadHostSettings
  1445. import resources_rc
  1446. app = CarlaApplication("Carla-Skins")
  1447. host = initHost("Skins", None, False, False, False)
  1448. loadHostSettings(host)
  1449. host.engine_init("JACK", "Carla-Widgets")
  1450. host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, "", "", "zynreverb", 0, None, 0x0)
  1451. #host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None, 0x0)
  1452. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://www.openavproductions.com/sorcer", 0, None, 0x0)
  1453. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://calf.sourceforge.net/plugins/Compressor", 0, None, 0x0)
  1454. host.set_active(0, True)
  1455. #gui = createPluginSlot(None, host, 0, True)
  1456. gui = PluginSlot_Compact(None, host, 0, "default")
  1457. gui.testTimer()
  1458. gui.show()
  1459. app.exec_()