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

10 years ago
10 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
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
9 years ago
10 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin/slot skin code
  4. # Copyright (C) 2013-2014 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 "calf" in skinStyle:
  166. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  167. widget.setPixmap(7)
  168. elif skinStyle == "mod":
  169. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  170. widget.setPixmap(14)
  171. elif skinStyle == "openav":
  172. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  173. if parameterId == PARAMETER_DRYWET:
  174. widget.setPixmap(13)
  175. elif parameterId == PARAMETER_VOLUME:
  176. widget.setPixmap(12)
  177. else:
  178. widget.setPixmap(11)
  179. else:
  180. if parameterId == PARAMETER_DRYWET:
  181. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  182. elif parameterId == PARAMETER_VOLUME:
  183. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  184. else:
  185. _r = 255 - int((float(parameterId)/float(parameterCount))*200.0)
  186. _g = 55 + int((float(parameterId)/float(parameterCount))*200.0)
  187. _b = 0 #(r-40)*4
  188. widget.setCustomPaintColor(QColor(_r, _g, _b))
  189. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  190. widget.setPixmap(3)
  191. widget.forceWhiteLabelGradientText()
  192. # ------------------------------------------------------------------------------------------------------------
  193. # Abstract plugin slot
  194. class AbstractPluginSlot(QFrame, PluginEditParentMeta):
  195. #class AbstractPluginSlot(QFrame, PluginEditParentMeta, metaclass=PyQtMetaClass):
  196. def __init__(self, parent, host, pluginId, skinStyle):
  197. QFrame.__init__(self, parent)
  198. self.host = host
  199. if False:
  200. # kdevelop likes this :)
  201. host = CarlaHostNull()
  202. self.host = host
  203. # -------------------------------------------------------------
  204. # Get plugin info
  205. self.fPluginId = pluginId
  206. self.fPluginInfo = host.get_plugin_info(self.fPluginId)
  207. self.fSkinStyle = skinStyle
  208. # -------------------------------------------------------------
  209. # Internal stuff
  210. self.fIsActive = False
  211. self.fIsSelected = False
  212. self.fLastGreenLedState = False
  213. self.fLastBlueLedState = False
  214. self.fParameterIconTimer = ICON_STATE_NULL
  215. self.fParameterList = [] # index, widget
  216. audioCountInfo = host.get_audio_port_count_info(self.fPluginId)
  217. self.fPeaksInputCount = audioCountInfo['ins']
  218. self.fPeaksOutputCount = audioCountInfo['outs']
  219. if self.fPeaksInputCount > 2:
  220. self.fPeaksInputCount = 2
  221. if self.fPeaksOutputCount > 2:
  222. self.fPeaksOutputCount = 2
  223. # used during testing
  224. self.fIdleTimerId = 0
  225. # -------------------------------------------------------------
  226. # Set-up GUI
  227. self.fEditDialog = PluginEdit(self, host, self.fPluginId)
  228. # -------------------------------------------------------------
  229. # Set-up common widgets (as none)
  230. self.b_enable = None
  231. self.b_gui = None
  232. self.b_edit = None
  233. self.b_remove = None
  234. self.cb_presets = None
  235. self.label_name = None
  236. self.label_presets = None
  237. self.label_type = None
  238. self.led_control = None
  239. self.led_midi = None
  240. self.led_audio_in = None
  241. self.led_audio_out = None
  242. self.peak_in = None
  243. self.peak_out = None
  244. self.w_knobs_left = None
  245. self.w_knobs_right = None
  246. # -------------------------------------------------------------
  247. # Set-up connections
  248. host.PluginRenamedCallback.connect(self.slot_handlePluginRenamedCallback)
  249. host.PluginUnavailableCallback.connect(self.slot_handlePluginUnavailableCallback)
  250. host.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback)
  251. host.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback)
  252. host.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback)
  253. host.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback)
  254. host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback)
  255. host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback)
  256. host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback)
  257. host.UiStateChangedCallback.connect(self.slot_handleUiStateChangedCallback)
  258. # -----------------------------------------------------------------
  259. @pyqtSlot(int, str)
  260. def slot_handlePluginRenamedCallback(self, pluginId, newName):
  261. if self.fPluginId == pluginId:
  262. self.setName(newName)
  263. @pyqtSlot(int, str)
  264. def slot_handlePluginUnavailableCallback(self, pluginId, errorMsg):
  265. if self.fPluginId == pluginId:
  266. pass
  267. @pyqtSlot(int, int, float)
  268. def slot_handleParameterValueChangedCallback(self, pluginId, index, value):
  269. if self.fPluginId == pluginId:
  270. self.setParameterValue(index, value, True)
  271. @pyqtSlot(int, int, float)
  272. def slot_handleParameterDefaultChangedCallback(self, pluginId, index, value):
  273. if self.fPluginId == pluginId:
  274. self.setParameterDefault(index, value)
  275. @pyqtSlot(int, int, int)
  276. def slot_handleParameterMidiCcChangedCallback(self, pluginId, index, cc):
  277. if self.fPluginId == pluginId:
  278. self.setParameterMidiControl(index, cc)
  279. @pyqtSlot(int, int, int)
  280. def slot_handleParameterMidiChannelChangedCallback(self, pluginId, index, channel):
  281. if self.fPluginId == pluginId:
  282. self.setParameterMidiChannel(index, channel)
  283. @pyqtSlot(int, int)
  284. def slot_handleProgramChangedCallback(self, pluginId, index):
  285. if self.fPluginId == pluginId:
  286. self.setProgram(index, True)
  287. @pyqtSlot(int, int)
  288. def slot_handleMidiProgramChangedCallback(self, pluginId, index):
  289. if self.fPluginId == pluginId:
  290. self.setMidiProgram(index, True)
  291. @pyqtSlot(int, int, bool)
  292. def slot_handleOptionChangedCallback(self, pluginId, option, yesNo):
  293. if self.fPluginId == pluginId:
  294. self.setOption(option, yesNo)
  295. @pyqtSlot(int, int)
  296. def slot_handleUiStateChangedCallback(self, pluginId, state):
  297. if self.fPluginId == pluginId:
  298. self.customUiStateChanged(state)
  299. #------------------------------------------------------------------
  300. def ready(self):
  301. self.fIsActive = bool(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_ACTIVE) >= 0.5)
  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 "calf" in self.fSkinStyle and not isinstance(self, PluginSlot_Compact):
  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 "calf" in self.fSkinStyle and not isinstance(self, PluginSlot_Compact):
  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 "calf" in self.fSkinStyle and not isinstance(self, PluginSlot_Compact):
  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 == "openav":
  338. QFontDatabase.addApplicationFont(":/fonts/uranium.ttf")
  339. nameFont.setFamily("Uranium")
  340. nameFont.setPixelSize(15)
  341. nameFont.setCapitalization(QFont.AllUppercase)
  342. elif "calf" in self.fSkinStyle:
  343. nameFont.setBold(True)
  344. nameFont.setPixelSize(12)
  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 "calf" in self.fSkinStyle:
  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 in ("mod", "openav", "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 "calf" in self.fSkinStyle:
  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 in ("mod", "openav", "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 == "mod":
  394. styleSheet = """
  395. QFrame#PluginWidget {
  396. background-color: rgb(%i, %i, %i);
  397. }
  398. QLabel#label_name { color: #FFFFFF; }
  399. QLabel#label_name:disabled { color: #505050; }
  400. """ % getModColorFromCategory(self.fPluginInfo['category'])
  401. elif self.fSkinStyle == "openav":
  402. styleSheet = """
  403. QFrame#PluginWidget {
  404. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  405. stop: 0 #303030, stop: %f #111111, stop: 1.0 #111111);
  406. }
  407. QLabel#label_name { color: #FF5100; }
  408. QLabel#label_name:disabled { color: #505050; }
  409. """ % (0.95 if isinstance(self, PluginSlot_Compact) else 0.35)
  410. else:
  411. if self.fSkinStyle in ("3bandeq", "calf_black", "calf_blue", "nekobi", "zynfx"):
  412. styleSheet2 = "background-image: url(:/bitmaps/background_%s.png);" % self.fSkinStyle
  413. else:
  414. styleSheet2 = "background-color: rgb(%i, %i, %i);" % getColorFromCategory(self.fPluginInfo['category'])
  415. styleSheet2 += "background-image: url(:/bitmaps/background_noise1.png);"
  416. styleSheet = """
  417. QFrame#PluginWidget {
  418. %s
  419. background-repeat: repeat-xy;
  420. }
  421. QLabel#label_name,
  422. QLabel#label_audio_in,
  423. QLabel#label_audio_out,
  424. QLabel#label_midi,
  425. QLabel#label_presets { color: #BBB; }
  426. QLabel#label_name:disabled { color: #555; }
  427. """ % styleSheet2
  428. self.setStyleSheet(styleSheet)
  429. # -------------------------------------------------------------
  430. # Set-up parameters
  431. if self.w_knobs_left is not None:
  432. parameterCount = self.host.get_parameter_count(self.fPluginId)
  433. if "calf" in self.fSkinStyle:
  434. maxWidgets = 7
  435. else:
  436. maxWidgets = 8
  437. index = 0
  438. for i in range(parameterCount):
  439. if index >= maxWidgets:
  440. break
  441. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  442. paramData = self.host.get_parameter_data(self.fPluginId, i)
  443. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  444. if paramData['type'] != PARAMETER_INPUT:
  445. continue
  446. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  447. continue
  448. if (paramData['hints'] & PARAMETER_IS_INTEGER) != 0 and paramRanges['max']-paramRanges['min'] <= 10.0:
  449. continue
  450. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  451. continue
  452. if paramInfo['name'].startswith("unused"):
  453. continue
  454. paramName = getParameterShortName(paramInfo['name'])
  455. widget = PixmapDial(self, i)
  456. widget.setLabel(paramName)
  457. widget.setMinimum(paramRanges['min'])
  458. widget.setMaximum(paramRanges['max'])
  459. setPixmapDialStyle(widget, i, parameterCount, self.fSkinStyle)
  460. index += 1
  461. self.fParameterList.append([i, widget])
  462. self.w_knobs_left.layout().addWidget(widget)
  463. if self.w_knobs_right is not None and (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) != 0:
  464. widget = PixmapDial(self, PARAMETER_DRYWET)
  465. widget.setLabel("Dry/Wet")
  466. widget.setMinimum(0.0)
  467. widget.setMaximum(1.0)
  468. setPixmapDialStyle(widget, PARAMETER_DRYWET, 0, self.fSkinStyle)
  469. self.fParameterList.append([PARAMETER_DRYWET, widget])
  470. self.w_knobs_right.layout().addWidget(widget)
  471. if self.w_knobs_right is not None and (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) != 0:
  472. widget = PixmapDial(self, PARAMETER_VOLUME)
  473. widget.setLabel("Volume")
  474. widget.setMinimum(0.0)
  475. widget.setMaximum(1.27)
  476. setPixmapDialStyle(widget, PARAMETER_VOLUME, 0, self.fSkinStyle)
  477. self.fParameterList.append([PARAMETER_VOLUME, widget])
  478. self.w_knobs_right.layout().addWidget(widget)
  479. for paramIndex, paramWidget in self.fParameterList:
  480. paramWidget.setContextMenuPolicy(Qt.CustomContextMenu)
  481. paramWidget.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  482. paramWidget.realValueChanged.connect(self.slot_parameterValueChanged)
  483. paramWidget.blockSignals(True)
  484. paramWidget.setValue(self.host.get_internal_parameter_value(self.fPluginId, paramIndex))
  485. paramWidget.blockSignals(False)
  486. # -------------------------------------------------------------
  487. self.setWindowTitle(self.fPluginInfo['name'])
  488. #------------------------------------------------------------------
  489. def getFixedHeight(self):
  490. return 32
  491. def getHints(self):
  492. return self.fPluginInfo['hints']
  493. def getPluginId(self):
  494. return self.fPluginId
  495. #------------------------------------------------------------------
  496. def setPluginId(self, idx):
  497. self.fPluginId = idx
  498. self.fEditDialog.setPluginId(idx)
  499. def setName(self, name):
  500. self.fPluginInfo['name'] = name
  501. self.fEditDialog.setName(name)
  502. if self.label_name is not None:
  503. self.label_name.setText(name)
  504. def setSelected(self, yesNo):
  505. if self.fIsSelected == yesNo:
  506. return
  507. self.fIsSelected = yesNo
  508. self.update()
  509. #------------------------------------------------------------------
  510. def setActive(self, active, sendCallback=False, sendHost=True):
  511. self.fIsActive = active
  512. if sendCallback:
  513. self.fParameterIconTimer = ICON_STATE_ON
  514. self.activeChanged(active)
  515. if sendHost:
  516. self.host.set_active(self.fPluginId, active)
  517. if active:
  518. self.fEditDialog.clearNotes()
  519. self.midiActivityChanged(False)
  520. if self.label_name is not None:
  521. self.label_name.setEnabled(self.fIsActive)
  522. # called from rack, checks if param is possible first
  523. def setInternalParameter(self, parameterId, value):
  524. if parameterId <= PARAMETER_MAX or parameterId >= PARAMETER_NULL:
  525. return
  526. elif parameterId == PARAMETER_ACTIVE:
  527. return self.setActive(bool(value), True, True)
  528. elif parameterId == PARAMETER_DRYWET:
  529. if (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) == 0: return
  530. self.host.set_drywet(self.fPluginId, value)
  531. elif parameterId == PARAMETER_VOLUME:
  532. if (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) == 0: return
  533. self.host.set_volume(self.fPluginId, value)
  534. elif parameterId == PARAMETER_BALANCE_LEFT:
  535. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  536. self.host.set_balance_left(self.fPluginId, value)
  537. elif parameterId == PARAMETER_BALANCE_RIGHT:
  538. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  539. self.host.set_balance_right(self.fPluginId, value)
  540. elif parameterId == PARAMETER_PANNING:
  541. if (self.fPluginInfo['hints'] & PLUGIN_CAN_PANNING) == 0: return
  542. self.host.set_panning(self.fPluginId, value)
  543. elif parameterId == PARAMETER_CTRL_CHANNEL:
  544. self.host.set_ctrl_channel(self.fPluginId, value)
  545. self.fEditDialog.setParameterValue(parameterId, value)
  546. #------------------------------------------------------------------
  547. def setParameterValue(self, parameterId, value, sendCallback):
  548. if parameterId == PARAMETER_ACTIVE:
  549. return self.setActive(bool(value), True, False)
  550. self.fEditDialog.setParameterValue(parameterId, value)
  551. if sendCallback:
  552. self.fParameterIconTimer = ICON_STATE_ON
  553. self.editDialogParameterValueChanged(self.fPluginId, parameterId, value)
  554. def setParameterDefault(self, parameterId, value):
  555. self.fEditDialog.setParameterDefault(parameterId, value)
  556. def setParameterMidiControl(self, parameterId, control):
  557. self.fEditDialog.setParameterMidiControl(parameterId, control)
  558. def setParameterMidiChannel(self, parameterId, channel):
  559. self.fEditDialog.setParameterMidiChannel(parameterId, channel)
  560. #------------------------------------------------------------------
  561. def setProgram(self, index, sendCallback):
  562. self.fEditDialog.setProgram(index)
  563. if sendCallback:
  564. self.fParameterIconTimer = ICON_STATE_ON
  565. self.editDialogProgramChanged(self.fPluginId, index)
  566. self.updateParameterValues()
  567. def setMidiProgram(self, index, sendCallback):
  568. self.fEditDialog.setMidiProgram(index)
  569. if sendCallback:
  570. self.fParameterIconTimer = ICON_STATE_ON
  571. self.editDialogMidiProgramChanged(self.fPluginId, index)
  572. self.updateParameterValues()
  573. #------------------------------------------------------------------
  574. def setOption(self, option, yesNo):
  575. self.fEditDialog.setOption(option, yesNo)
  576. #------------------------------------------------------------------
  577. def showCustomUI(self):
  578. self.host.show_custom_ui(self.fPluginId, True)
  579. if self.b_gui is not None:
  580. self.b_gui.setChecked(True)
  581. def showEditDialog(self):
  582. self.fEditDialog.show()
  583. self.fEditDialog.activateWindow()
  584. if self.b_edit is not None:
  585. self.b_edit.setChecked(True)
  586. def showRenameDialog(self):
  587. oldName = self.fPluginInfo['name']
  588. newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName)
  589. if not (newNameTry[1] and newNameTry[0] and oldName != newNameTry[0]):
  590. return
  591. newName = newNameTry[0]
  592. if not self.host.rename_plugin(self.fPluginId, newName):
  593. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  594. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  595. return
  596. self.setName(newName)
  597. def showReplaceDialog(self):
  598. data = gCarla.gui.showAddPluginDialog()
  599. if data is None:
  600. return
  601. btype, ptype, filename, label, uniqueId, extraPtr = data
  602. if not self.host.replace_plugin(self.fPluginId):
  603. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to replace plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  604. return
  605. ok = self.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr, 0x0)
  606. self.host.replace_plugin(self.host.get_max_plugin_number())
  607. if not ok:
  608. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  609. #------------------------------------------------------------------
  610. def activeChanged(self, onOff):
  611. self.fIsActive = onOff
  612. if self.b_enable is None:
  613. return
  614. self.b_enable.blockSignals(True)
  615. self.b_enable.setChecked(onOff)
  616. self.b_enable.blockSignals(False)
  617. def customUiStateChanged(self, state):
  618. if self.b_gui is None:
  619. return
  620. self.b_gui.blockSignals(True)
  621. if state == 0:
  622. self.b_gui.setChecked(False)
  623. self.b_gui.setEnabled(True)
  624. elif state == 1:
  625. self.b_gui.setChecked(True)
  626. self.b_gui.setEnabled(True)
  627. elif state == -1:
  628. self.b_gui.setChecked(False)
  629. self.b_gui.setEnabled(False)
  630. self.b_gui.blockSignals(False)
  631. def parameterActivityChanged(self, onOff):
  632. if self.led_control is None:
  633. return
  634. self.led_control.setChecked(onOff)
  635. def midiActivityChanged(self, onOff):
  636. if self.led_midi is None:
  637. return
  638. self.led_midi.setChecked(onOff)
  639. def optionChanged(self, option, yesNo):
  640. pass
  641. # -----------------------------------------------------------------
  642. # PluginEdit callbacks
  643. def editDialogVisibilityChanged(self, pluginId, visible):
  644. if self.b_edit is None:
  645. return
  646. self.b_edit.blockSignals(True)
  647. self.b_edit.setChecked(visible)
  648. self.b_edit.blockSignals(False)
  649. def editDialogPluginHintsChanged(self, pluginId, hints):
  650. self.fPluginInfo['hints'] = hints
  651. for paramIndex, paramWidget in self.fParameterList:
  652. if paramIndex == PARAMETER_DRYWET:
  653. paramWidget.setVisible(hints & PLUGIN_CAN_DRYWET)
  654. elif paramIndex == PARAMETER_VOLUME:
  655. paramWidget.setVisible(hints & PLUGIN_CAN_VOLUME)
  656. if self.b_gui is not None:
  657. self.b_gui.setEnabled(bool(hints & PLUGIN_HAS_CUSTOM_UI))
  658. def editDialogParameterValueChanged(self, pluginId, parameterId, value):
  659. for paramIndex, paramWidget in self.fParameterList:
  660. if paramIndex != parameterId:
  661. continue
  662. paramWidget.blockSignals(True)
  663. paramWidget.setValue(value)
  664. paramWidget.blockSignals(False)
  665. break
  666. def editDialogProgramChanged(self, pluginId, index):
  667. if self.cb_presets is None:
  668. return
  669. self.cb_presets.blockSignals(True)
  670. self.cb_presets.setCurrentIndex(index)
  671. self.cb_presets.blockSignals(False)
  672. # FIXME
  673. self.updateParameterValues()
  674. def editDialogMidiProgramChanged(self, pluginId, index):
  675. if self.cb_presets is None:
  676. return
  677. self.cb_presets.blockSignals(True)
  678. self.cb_presets.setCurrentIndex(index)
  679. self.cb_presets.blockSignals(False)
  680. # FIXME
  681. self.updateParameterValues()
  682. def editDialogNotePressed(self, pluginId, note):
  683. pass
  684. def editDialogNoteReleased(self, pluginId, note):
  685. pass
  686. def editDialogMidiActivityChanged(self, pluginId, onOff):
  687. self.midiActivityChanged(onOff)
  688. #------------------------------------------------------------------
  689. def idleFast(self):
  690. # Input peaks
  691. if self.fPeaksInputCount > 0:
  692. if self.fPeaksInputCount > 1:
  693. peak1 = self.host.get_input_peak_value(self.fPluginId, True)
  694. peak2 = self.host.get_input_peak_value(self.fPluginId, False)
  695. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  696. if self.peak_in is not None:
  697. self.peak_in.displayMeter(1, peak1)
  698. self.peak_in.displayMeter(2, peak2)
  699. else:
  700. peak = self.host.get_input_peak_value(self.fPluginId, True)
  701. ledState = bool(peak != 0.0)
  702. if self.peak_in is not None:
  703. self.peak_in.displayMeter(1, peak)
  704. if self.fLastGreenLedState != ledState and self.led_audio_in is not None:
  705. self.fLastGreenLedState = ledState
  706. self.led_audio_in.setChecked(ledState)
  707. # Output peaks
  708. if self.fPeaksOutputCount > 0:
  709. if self.fPeaksOutputCount > 1:
  710. peak1 = self.host.get_output_peak_value(self.fPluginId, True)
  711. peak2 = self.host.get_output_peak_value(self.fPluginId, False)
  712. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  713. if self.peak_out is not None:
  714. self.peak_out.displayMeter(1, peak1)
  715. self.peak_out.displayMeter(2, peak2)
  716. else:
  717. peak = self.host.get_output_peak_value(self.fPluginId, True)
  718. ledState = bool(peak != 0.0)
  719. if self.peak_out is not None:
  720. self.peak_out.displayMeter(1, peak)
  721. if self.fLastBlueLedState != ledState and self.led_audio_out is not None:
  722. self.fLastBlueLedState = ledState
  723. self.led_audio_out.setChecked(ledState)
  724. def idleSlow(self):
  725. if self.fParameterIconTimer == ICON_STATE_ON:
  726. self.parameterActivityChanged(True)
  727. self.fParameterIconTimer = ICON_STATE_WAIT
  728. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  729. self.fParameterIconTimer = ICON_STATE_OFF
  730. elif self.fParameterIconTimer == ICON_STATE_OFF:
  731. self.parameterActivityChanged(False)
  732. self.fParameterIconTimer = ICON_STATE_NULL
  733. self.fEditDialog.idleSlow()
  734. #------------------------------------------------------------------
  735. def drawOutline(self):
  736. painter = QPainter(self)
  737. if self.fIsSelected:
  738. painter.setPen(QPen(Qt.cyan, 4))
  739. painter.setBrush(Qt.transparent)
  740. painter.drawRect(0, 0, self.width(), self.height())
  741. else:
  742. painter.setPen(QPen(Qt.black, 1))
  743. painter.setBrush(Qt.black)
  744. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  745. def updateParameterValues(self):
  746. for paramIndex, paramWidget in self.fParameterList:
  747. if paramIndex < 0:
  748. continue
  749. paramWidget.blockSignals(True)
  750. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramIndex))
  751. paramWidget.blockSignals(False)
  752. #------------------------------------------------------------------
  753. @pyqtSlot(bool)
  754. def slot_enableClicked(self, yesNo):
  755. self.setActive(yesNo, False, True)
  756. @pyqtSlot()
  757. def slot_showDefaultCustomMenu(self):
  758. menu = QMenu(self)
  759. # -------------------------------------------------------------
  760. # Expand/Minimize
  761. actCompact = menu.addAction(self.tr("Expand") if isinstance(self, PluginSlot_Compact) else self.tr("Minimize"))
  762. menu.addSeparator()
  763. # -------------------------------------------------------------
  764. # Bypass and Enable/Disable
  765. actBypass = menu.addAction(self.tr("Bypass"))
  766. actEnable = menu.addAction(self.tr("Disable") if self.fIsActive else self.tr("Enable"))
  767. menu.addSeparator()
  768. if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET:
  769. actBypass.setCheckable(True)
  770. actBypass.setChecked(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_DRYWET) == 0.0)
  771. else:
  772. actBypass.setVisible(False)
  773. # -------------------------------------------------------------
  774. # Reset and Randomize parameters
  775. actReset = menu.addAction(self.tr("Reset parameters"))
  776. actRandom = menu.addAction(self.tr("Randomize parameters"))
  777. menu.addSeparator()
  778. # -------------------------------------------------------------
  779. # Edit and Show Custom UI
  780. actEdit = menu.addAction(self.tr("Edit"))
  781. actGui = menu.addAction(self.tr("Show Custom UI"))
  782. menu.addSeparator()
  783. if self.b_edit is not None:
  784. actEdit.setCheckable(True)
  785. actEdit.setChecked(self.b_edit.isChecked())
  786. else:
  787. actEdit.setVisible(False)
  788. if self.b_gui is not None:
  789. actGui.setCheckable(True)
  790. actGui.setChecked(self.b_gui.isChecked())
  791. actGui.setEnabled(self.b_gui.isEnabled())
  792. else:
  793. actGui.setVisible(False)
  794. # -------------------------------------------------------------
  795. # Other stuff
  796. actClone = menu.addAction(self.tr("Clone"))
  797. actRename = menu.addAction(self.tr("Rename..."))
  798. actReplace = menu.addAction(self.tr("Replace..."))
  799. actRemove = menu.addAction(self.tr("Remove"))
  800. if self.fIdleTimerId != 0:
  801. actRemove.setVisible(False)
  802. # -------------------------------------------------------------
  803. # exec
  804. actSel = menu.exec_(QCursor.pos())
  805. if not actSel:
  806. return
  807. # -------------------------------------------------------------
  808. # Expand/Minimize
  809. elif actSel == actCompact:
  810. # FIXME
  811. gCarla.gui.compactPlugin(self.fPluginId)
  812. # -------------------------------------------------------------
  813. # Bypass and Enable/Disable
  814. elif actSel == actBypass:
  815. value = 0.0 if actBypass.isChecked() else 1.0
  816. self.host.set_drywet(self.fPluginId, value)
  817. self.setParameterValue(PARAMETER_DRYWET, value, True)
  818. elif actSel == actEnable:
  819. self.setActive(not self.fIsActive, True, True)
  820. # -------------------------------------------------------------
  821. # Reset and Randomize parameters
  822. elif actSel == actReset:
  823. self.host.reset_parameters(self.fPluginId)
  824. elif actSel == actRandom:
  825. self.host.randomize_parameters(self.fPluginId)
  826. # -------------------------------------------------------------
  827. # Edit and Show Custom UI
  828. elif actSel == actEdit:
  829. self.b_edit.click()
  830. elif actSel == actGui:
  831. self.b_gui.click()
  832. # -------------------------------------------------------------
  833. # Clone
  834. elif actSel == actClone:
  835. if not self.host.clone_plugin(self.fPluginId):
  836. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  837. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  838. # -------------------------------------------------------------
  839. # Rename
  840. elif actSel == actRename:
  841. self.showRenameDialog()
  842. # -------------------------------------------------------------
  843. # Replace
  844. elif actSel == actReplace:
  845. self.showReplaceDialog()
  846. # -------------------------------------------------------------
  847. # Remove
  848. elif actSel == actRemove:
  849. if not self.host.remove_plugin(self.fPluginId):
  850. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  851. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  852. # -------------------------------------------------------------
  853. @pyqtSlot()
  854. def slot_knobCustomMenu(self):
  855. sender = self.sender()
  856. index = sender.fIndex
  857. minimum = sender.fMinimum
  858. maximum = sender.fMaximum
  859. current = sender.fRealValue
  860. label = sender.fLabel
  861. if index in (PARAMETER_NULL, PARAMETER_CTRL_CHANNEL) or index <= PARAMETER_MAX:
  862. return
  863. elif index in (PARAMETER_DRYWET, PARAMETER_VOLUME):
  864. default = 1.0
  865. elif index == PARAMETER_BALANCE_LEFT:
  866. default = -1.0
  867. elif index == PARAMETER_BALANCE_RIGHT:
  868. default = 1.0
  869. elif index == PARAMETER_PANNING:
  870. default = 0.0
  871. else:
  872. default = self.host.get_default_parameter_value(self.fPluginId, index)
  873. if index < PARAMETER_NULL:
  874. # show in integer percentage
  875. textReset = self.tr("Reset (%i%%)" % round(default*100.0))
  876. textMinim = self.tr("Set to Minimum (%i%%)" % round(minimum*100.0))
  877. textMaxim = self.tr("Set to Maximum (%i%%)" % round(maximum*100.0))
  878. else:
  879. # show in full float value
  880. textReset = self.tr("Reset (%f)" % default)
  881. textMinim = self.tr("Set to Minimum (%f)" % minimum)
  882. textMaxim = self.tr("Set to Maximum (%f)" % maximum)
  883. menu = QMenu(self)
  884. actReset = menu.addAction(textReset)
  885. menu.addSeparator()
  886. actMinimum = menu.addAction(textMinim)
  887. actCenter = menu.addAction(self.tr("Set to Center"))
  888. actMaximum = menu.addAction(textMaxim)
  889. menu.addSeparator()
  890. actSet = menu.addAction(self.tr("Set value..."))
  891. if index > PARAMETER_NULL or index not in (PARAMETER_BALANCE_LEFT, PARAMETER_BALANCE_RIGHT, PARAMETER_PANNING):
  892. menu.removeAction(actCenter)
  893. actSelected = menu.exec_(QCursor.pos())
  894. if actSelected == actSet:
  895. if index < PARAMETER_NULL:
  896. value, ok = QInputDialog.getInt(self, self.tr("Set value"), label, round(current*100), round(minimum*100), round(maximum*100), 1)
  897. if not ok:
  898. return
  899. value = float(value)/100.0
  900. else:
  901. paramInfo = self.host.get_parameter_info(self.fPluginId, index)
  902. paramRanges = self.host.get_parameter_ranges(self.fPluginId, index)
  903. scalePoints = []
  904. for i in range(paramInfo['scalePointCount']):
  905. scalePoints.append(self.host.get_parameter_scalepoint_info(self.fPluginId, index, i))
  906. dialog = CustomInputDialog(self, label, current, minimum, maximum,
  907. paramRanges['step'], paramRanges['stepSmall'], scalePoints)
  908. if not dialog.exec_():
  909. return
  910. value = dialog.returnValue()
  911. elif actSelected == actMinimum:
  912. value = minimum
  913. elif actSelected == actMaximum:
  914. value = maximum
  915. elif actSelected == actReset:
  916. value = default
  917. elif actSelected == actCenter:
  918. value = 0.0
  919. else:
  920. return
  921. self.sender().setValue(value)
  922. #------------------------------------------------------------------
  923. @pyqtSlot(bool)
  924. def slot_showCustomUi(self, show):
  925. self.host.show_custom_ui(self.fPluginId, show)
  926. @pyqtSlot(bool)
  927. def slot_showEditDialog(self, show):
  928. self.fEditDialog.setVisible(show)
  929. @pyqtSlot()
  930. def slot_removePlugin(self):
  931. if not self.host.remove_plugin(self.fPluginId):
  932. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  933. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  934. #------------------------------------------------------------------
  935. @pyqtSlot(int)
  936. def slot_parameterValueChanged(self, value):
  937. index = self.sender().getIndex()
  938. if index < 0:
  939. self.setInternalParameter(index, value)
  940. else:
  941. self.host.set_parameter_value(self.fPluginId, index, value)
  942. self.setParameterValue(index, value, False)
  943. @pyqtSlot(int)
  944. def slot_programChanged(self, index):
  945. self.host.set_program(self.fPluginId, index)
  946. self.setProgram(index, False)
  947. @pyqtSlot(int)
  948. def slot_midiProgramChanged(self, index):
  949. self.host.set_midi_program(self.fPluginId, index)
  950. self.setMidiProgram(index, False)
  951. #------------------------------------------------------------------
  952. def testTimer(self):
  953. self.fIdleTimerId = self.startTimer(25)
  954. #------------------------------------------------------------------
  955. def mouseDoubleClickEvent(self, event):
  956. QFrame.mouseDoubleClickEvent(self, event)
  957. # FIXME
  958. gCarla.gui.compactPlugin(self.fPluginId)
  959. def closeEvent(self, event):
  960. if self.fIdleTimerId != 0:
  961. self.killTimer(self.fIdleTimerId)
  962. self.fIdleTimerId = 0
  963. self.host.engine_close()
  964. QFrame.closeEvent(self, event)
  965. def timerEvent(self, event):
  966. if event.timerId() == self.fIdleTimerId:
  967. self.host.engine_idle()
  968. self.idleFast()
  969. self.idleSlow()
  970. QFrame.timerEvent(self, event)
  971. def paintEvent(self, event):
  972. self.drawOutline()
  973. QFrame.paintEvent(self, event)
  974. # ------------------------------------------------------------------------------------------------------------
  975. class PluginSlot_Calf(AbstractPluginSlot):
  976. def __init__(self, parent, host, pluginId, skinStyle):
  977. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  978. self.ui = ui_carla_plugin_calf.Ui_PluginWidget()
  979. self.ui.setupUi(self)
  980. audioCount = self.host.get_audio_port_count_info(self.fPluginId)
  981. midiCount = self.host.get_midi_port_count_info(self.fPluginId)
  982. # -------------------------------------------------------------
  983. # Internal stuff
  984. self.fButtonFont = self.ui.b_gui.font()
  985. self.fButtonFont.setBold(False)
  986. self.fButtonFont.setPixelSize(10)
  987. self.fButtonColorOn = QColor( 18, 41, 87)
  988. self.fButtonColorOff = QColor(150, 150, 150)
  989. # -------------------------------------------------------------
  990. # Set-up GUI
  991. self.ui.label_active.setFont(self.fButtonFont)
  992. self.ui.b_remove.setPixmaps(":/bitmaps/button_calf1.png", ":/bitmaps/button_calf1_down.png", ":/bitmaps/button_calf1_hover.png")
  993. self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont)
  994. self.ui.b_remove.setTopText(self.tr("Remove"), self.fButtonColorOn, self.fButtonFont)
  995. if self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI:
  996. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  997. else:
  998. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  999. if audioCount['ins'] == 0:
  1000. self.ui.label_audio_in.hide()
  1001. if audioCount['outs'] == 0:
  1002. self.ui.label_audio_out.hide()
  1003. if midiCount['ins'] == 0:
  1004. self.ui.label_midi.hide()
  1005. self.ui.led_midi.hide()
  1006. if self.fIdleTimerId != 0:
  1007. self.ui.b_remove.setEnabled(False)
  1008. self.ui.b_remove.setVisible(False)
  1009. # -------------------------------------------------------------
  1010. self.b_enable = self.ui.b_enable
  1011. self.b_gui = self.ui.b_gui
  1012. self.b_edit = self.ui.b_edit
  1013. self.b_remove = self.ui.b_remove
  1014. self.label_name = self.ui.label_name
  1015. self.led_midi = self.ui.led_midi
  1016. self.peak_in = self.ui.peak_in
  1017. self.peak_out = self.ui.peak_out
  1018. self.w_knobs_left = self.ui.w_knobs
  1019. self.ready()
  1020. self.ui.led_midi.setColor(self.ui.led_midi.CALF)
  1021. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1022. #------------------------------------------------------------------
  1023. def getFixedHeight(self):
  1024. return 94 if max(self.peak_in.channelCount(), self.peak_out.channelCount()) < 2 else 106
  1025. #------------------------------------------------------------------
  1026. def editDialogPluginHintsChanged(self, pluginId, hints):
  1027. if hints & PLUGIN_HAS_CUSTOM_UI:
  1028. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  1029. else:
  1030. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  1031. AbstractPluginSlot.editDialogPluginHintsChanged(self, pluginId, hints)
  1032. #------------------------------------------------------------------
  1033. def paintEvent(self, event):
  1034. isBlack = bool(self.fSkinStyle == "calf_black")
  1035. painter = QPainter(self)
  1036. painter.setBrush(Qt.transparent)
  1037. painter.setPen(QPen(QColor(20, 20, 20) if isBlack else QColor(75, 86, 99), 1))
  1038. painter.drawRect(0, 1, self.width()-1, self.height()-3)
  1039. painter.setPen(QPen(QColor(45, 45, 45) if isBlack else QColor(86, 99, 114), 1))
  1040. painter.drawLine(0, 0, self.width(), 0)
  1041. AbstractPluginSlot.paintEvent(self, event)
  1042. # ------------------------------------------------------------------------------------------------------------
  1043. class PluginSlot_Classic(AbstractPluginSlot):
  1044. def __init__(self, parent, host, pluginId):
  1045. AbstractPluginSlot.__init__(self, parent, host, pluginId, "classic")
  1046. self.ui = ui_carla_plugin_classic.Ui_PluginWidget()
  1047. self.ui.setupUi(self)
  1048. # -------------------------------------------------------------
  1049. # Internal stuff
  1050. self.fColorTop = QColor(60, 60, 60)
  1051. self.fColorBottom = QColor(47, 47, 47)
  1052. self.fColorSeprtr = QColor(70, 70, 70)
  1053. # -------------------------------------------------------------
  1054. self.b_enable = self.ui.b_enable
  1055. self.b_gui = self.ui.b_gui
  1056. self.b_edit = self.ui.b_edit
  1057. self.label_name = self.ui.label_name
  1058. self.led_control = self.ui.led_control
  1059. self.led_midi = self.ui.led_midi
  1060. self.led_audio_in = self.ui.led_audio_in
  1061. self.led_audio_out = self.ui.led_audio_out
  1062. self.peak_in = self.ui.peak_in
  1063. self.peak_out = self.ui.peak_out
  1064. self.ready()
  1065. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1066. #------------------------------------------------------------------
  1067. def getFixedHeight(self):
  1068. return 36
  1069. #------------------------------------------------------------------
  1070. def paintEvent(self, event):
  1071. painter = QPainter(self)
  1072. painter.save()
  1073. areaX = self.ui.area_right.x()+7
  1074. width = self.width()
  1075. height = self.height()
  1076. painter.setPen(QPen(QColor(17, 17, 17), 1))
  1077. painter.setBrush(QColor(17, 17, 17))
  1078. painter.drawRect(0, 0, width, height)
  1079. painter.setPen(self.fColorSeprtr.lighter(110))
  1080. painter.setBrush(self.fColorBottom)
  1081. painter.setRenderHint(QPainter.Antialiasing, True)
  1082. # name -> leds arc
  1083. path = QPainterPath()
  1084. path.moveTo(areaX-20, height-4)
  1085. path.cubicTo(areaX, height-5, areaX-20, 4.75, areaX, 4.75)
  1086. path.lineTo(areaX, height-5)
  1087. painter.drawPath(path)
  1088. painter.setPen(self.fColorSeprtr)
  1089. painter.setRenderHint(QPainter.Antialiasing, False)
  1090. # separator lines
  1091. painter.drawLine(0, height-5, areaX-20, height-5)
  1092. painter.drawLine(areaX, 4, width, 4)
  1093. painter.setPen(self.fColorBottom)
  1094. painter.setBrush(self.fColorBottom)
  1095. # top, bottom and left lines
  1096. painter.drawLine(0, 0, width, 0)
  1097. painter.drawRect(0, height-4, areaX, 4)
  1098. painter.drawRoundedRect(areaX-20, height-5, areaX, 5, 22, 22)
  1099. painter.drawLine(0, 0, 0, height)
  1100. # fill the rest
  1101. painter.drawRect(areaX-1, 5, width, height)
  1102. # bottom 1px line
  1103. painter.setPen(self.fColorSeprtr)
  1104. painter.drawLine(0, height-1, width, height-1)
  1105. painter.restore()
  1106. AbstractPluginSlot.paintEvent(self, event)
  1107. # ------------------------------------------------------------------------------------------------------------
  1108. class PluginSlot_Compact(AbstractPluginSlot):
  1109. def __init__(self, parent, host, pluginId, skinStyle):
  1110. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1111. self.ui = ui_carla_plugin_compact.Ui_PluginWidget()
  1112. self.ui.setupUi(self)
  1113. self.b_enable = self.ui.b_enable
  1114. self.b_gui = self.ui.b_gui
  1115. self.b_edit = self.ui.b_edit
  1116. self.label_name = self.ui.label_name
  1117. self.led_control = self.ui.led_control
  1118. self.led_midi = self.ui.led_midi
  1119. self.led_audio_in = self.ui.led_audio_in
  1120. self.led_audio_out = self.ui.led_audio_out
  1121. self.peak_in = self.ui.peak_in
  1122. self.peak_out = self.ui.peak_out
  1123. self.ready()
  1124. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1125. #------------------------------------------------------------------
  1126. def getFixedHeight(self):
  1127. if self.fSkinStyle == "calf_blue":
  1128. return 36
  1129. return 30
  1130. # ------------------------------------------------------------------------------------------------------------
  1131. class PluginSlot_Default(AbstractPluginSlot):
  1132. def __init__(self, parent, host, pluginId, skinStyle):
  1133. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1134. self.ui = ui_carla_plugin_default.Ui_PluginWidget()
  1135. self.ui.setupUi(self)
  1136. # -------------------------------------------------------------
  1137. self.b_enable = self.ui.b_enable
  1138. self.b_gui = self.ui.b_gui
  1139. self.b_edit = self.ui.b_edit
  1140. self.label_name = self.ui.label_name
  1141. self.led_control = self.ui.led_control
  1142. self.led_midi = self.ui.led_midi
  1143. self.led_audio_in = self.ui.led_audio_in
  1144. self.led_audio_out = self.ui.led_audio_out
  1145. self.peak_in = self.ui.peak_in
  1146. self.peak_out = self.ui.peak_out
  1147. self.w_knobs_left = self.ui.w_knobs_left
  1148. self.w_knobs_right = self.ui.w_knobs_right
  1149. self.ready()
  1150. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1151. #------------------------------------------------------------------
  1152. def getFixedHeight(self):
  1153. if self.fSkinStyle == "mod":
  1154. return 86
  1155. return 80
  1156. #------------------------------------------------------------------
  1157. def paintEvent(self, event):
  1158. painter = QPainter(self)
  1159. painter.setBrush(Qt.transparent)
  1160. painter.setPen(QPen(QColor(42, 42, 42), 1))
  1161. painter.drawRect(0, 1, self.width()-1, self.getFixedHeight()-3)
  1162. painter.setPen(QPen(QColor(60, 60, 60), 1))
  1163. painter.drawLine(0, 0, self.width(), 0)
  1164. AbstractPluginSlot.paintEvent(self, event)
  1165. # ------------------------------------------------------------------------------------------------------------
  1166. class PluginSlot_Presets(AbstractPluginSlot):
  1167. def __init__(self, parent, host, pluginId, skinStyle):
  1168. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1169. self.ui = ui_carla_plugin_presets.Ui_PluginWidget()
  1170. self.ui.setupUi(self)
  1171. usingMidiPrograms = bool(skinStyle != "presets")
  1172. # -------------------------------------------------------------
  1173. # Set-up programs
  1174. if usingMidiPrograms:
  1175. programCount = self.host.get_midi_program_count(self.fPluginId)
  1176. else:
  1177. programCount = self.host.get_program_count(self.fPluginId)
  1178. if programCount > 0:
  1179. self.ui.cb_presets.setEnabled(True)
  1180. self.ui.label_presets.setEnabled(True)
  1181. for i in range(programCount):
  1182. if usingMidiPrograms:
  1183. progName = self.host.get_midi_program_data(self.fPluginId, i)['name']
  1184. else:
  1185. progName = self.host.get_program_name(self.fPluginId, i)
  1186. self.ui.cb_presets.addItem(progName)
  1187. if usingMidiPrograms:
  1188. curProg = self.host.get_current_midi_program_index(self.fPluginId)
  1189. else:
  1190. curProg = self.host.get_current_program_index(self.fPluginId)
  1191. self.ui.cb_presets.setCurrentIndex(curProg)
  1192. else:
  1193. self.ui.cb_presets.setEnabled(False)
  1194. self.ui.cb_presets.setVisible(False)
  1195. self.ui.label_presets.setEnabled(False)
  1196. self.ui.label_presets.setVisible(False)
  1197. # -------------------------------------------------------------
  1198. self.b_enable = self.ui.b_enable
  1199. self.b_gui = self.ui.b_gui
  1200. self.b_edit = self.ui.b_edit
  1201. self.cb_presets = self.ui.cb_presets
  1202. self.label_name = self.ui.label_name
  1203. self.label_presets = self.ui.label_presets
  1204. self.led_control = self.ui.led_control
  1205. self.led_midi = self.ui.led_midi
  1206. self.led_audio_in = self.ui.led_audio_in
  1207. self.led_audio_out = self.ui.led_audio_out
  1208. self.peak_in = self.ui.peak_in
  1209. self.peak_out = self.ui.peak_out
  1210. if skinStyle == "zynfx":
  1211. self.setupZynFxParams()
  1212. else:
  1213. self.w_knobs_left = self.ui.w_knobs_left
  1214. self.w_knobs_right = self.ui.w_knobs_right
  1215. self.ready()
  1216. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1217. if usingMidiPrograms:
  1218. self.ui.cb_presets.currentIndexChanged.connect(self.slot_midiProgramChanged)
  1219. else:
  1220. self.ui.cb_presets.currentIndexChanged.connect(self.slot_programChanged)
  1221. # -------------------------------------------------------------
  1222. def setupZynFxParams(self):
  1223. parameterCount = self.host.get_parameter_count(self.fPluginId)
  1224. index = 0
  1225. for i in range(parameterCount):
  1226. if index >= 8:
  1227. break
  1228. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  1229. paramData = self.host.get_parameter_data(self.fPluginId, i)
  1230. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  1231. if paramData['type'] != PARAMETER_INPUT:
  1232. continue
  1233. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  1234. continue
  1235. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1236. continue
  1237. paramName = paramInfo['name']
  1238. if paramName.startswith("unused"):
  1239. continue
  1240. # real zyn fx plugins
  1241. if self.fPluginInfo['label'] == "zynalienwah":
  1242. if i == 0: paramName = "Freq"
  1243. elif i == 1: paramName = "Rnd"
  1244. elif i == 2: paramName = "L type" # combobox
  1245. elif i == 3: paramName = "St.df"
  1246. elif i == 5: paramName = "Fb"
  1247. elif i == 7: paramName = "L/R"
  1248. elif self.fPluginInfo['label'] == "zynchorus":
  1249. if i == 0: paramName = "Freq"
  1250. elif i == 1: paramName = "Rnd"
  1251. elif i == 2: paramName = "L type" # combobox
  1252. elif i == 3: paramName = "St.df"
  1253. elif i == 6: paramName = "Fb"
  1254. elif i == 7: paramName = "L/R"
  1255. elif i == 8: paramName = "Flngr" # button
  1256. elif i == 9: paramName = "Subst" # button
  1257. elif self.fPluginInfo['label'] == "zyndistortion":
  1258. if i == 0: paramName = "LRc."
  1259. elif i == 4: paramName = "Neg." # button
  1260. elif i == 5: paramName = "LPF"
  1261. elif i == 6: paramName = "HPF"
  1262. elif i == 7: paramName = "St." # button
  1263. elif i == 8: paramName = "PF" # button
  1264. elif self.fPluginInfo['label'] == "zyndynamicfilter":
  1265. if i == 0: paramName = "Freq"
  1266. elif i == 1: paramName = "Rnd"
  1267. elif i == 2: paramName = "L type" # combobox
  1268. elif i == 3: paramName = "St.df"
  1269. elif i == 4: paramName = "LfoD"
  1270. elif i == 5: paramName = "A.S."
  1271. elif i == 6: paramName = "A.Inv." # button
  1272. elif i == 7: paramName = "A.M."
  1273. elif self.fPluginInfo['label'] == "zynecho":
  1274. if i == 1: paramName = "LRdl."
  1275. elif i == 2: paramName = "LRc."
  1276. elif i == 3: paramName = "Fb."
  1277. elif i == 4: paramName = "Damp"
  1278. elif self.fPluginInfo['label'] == "zynphaser":
  1279. if i == 0: paramName = "Freq"
  1280. elif i == 1: paramName = "Rnd"
  1281. elif i == 2: paramName = "L type" # combobox
  1282. elif i == 3: paramName = "St.df"
  1283. elif i == 5: paramName = "Fb"
  1284. elif i == 7: paramName = "L/R"
  1285. elif i == 8: paramName = "Subst" # button
  1286. elif i == 9: paramName = "Phase"
  1287. elif i == 11: paramName = "Dist"
  1288. elif self.fPluginInfo['label'] == "zynreverb":
  1289. if i == 2: paramName = "I.delfb"
  1290. elif i == 5: paramName = "LPF"
  1291. elif i == 6: paramName = "HPF"
  1292. elif i == 9: paramName = "R.S."
  1293. elif i == 10: paramName = "I.del"
  1294. else:
  1295. paramName = getParameterShortName(paramName)
  1296. widget = PixmapDial(self, i)
  1297. widget.setLabel(paramName)
  1298. widget.setMinimum(paramRanges['min'])
  1299. widget.setMaximum(paramRanges['max'])
  1300. widget.setPixmap(3)
  1301. widget.setCustomPaintColor(QColor(83, 173, 10))
  1302. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  1303. widget.forceWhiteLabelGradientText()
  1304. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1305. widget.setEnabled(False)
  1306. self.fParameterList.append([i, widget])
  1307. self.ui.w_knobs_left.layout().addWidget(widget)
  1308. if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET:
  1309. widget = PixmapDial(self, PARAMETER_DRYWET)
  1310. widget.setLabel("Wet")
  1311. widget.setMinimum(0.0)
  1312. widget.setMaximum(1.0)
  1313. widget.setPixmap(3)
  1314. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  1315. widget.forceWhiteLabelGradientText()
  1316. self.fParameterList.append([PARAMETER_DRYWET, widget])
  1317. self.ui.w_knobs_right.layout().addWidget(widget)
  1318. if self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME:
  1319. widget = PixmapDial(self, PARAMETER_VOLUME)
  1320. widget.setLabel("Volume")
  1321. widget.setMinimum(0.0)
  1322. widget.setMaximum(1.27)
  1323. widget.setPixmap(3)
  1324. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  1325. widget.forceWhiteLabelGradientText()
  1326. self.fParameterList.append([PARAMETER_VOLUME, widget])
  1327. self.ui.w_knobs_right.layout().addWidget(widget)
  1328. #------------------------------------------------------------------
  1329. def getFixedHeight(self):
  1330. return 80
  1331. #------------------------------------------------------------------
  1332. def paintEvent(self, event):
  1333. painter = QPainter(self)
  1334. painter.setBrush(Qt.transparent)
  1335. painter.setPen(QPen(QColor(50, 50, 50), 1))
  1336. painter.drawRect(0, 1, self.width()-1, self.height()-3)
  1337. painter.setPen(QPen(QColor(64, 64, 64), 1))
  1338. painter.drawLine(0, 0, self.width(), 0)
  1339. AbstractPluginSlot.paintEvent(self, event)
  1340. # ------------------------------------------------------------------------------------------------------------
  1341. def getSkinStyle(host, pluginId):
  1342. if False:
  1343. # kdevelop likes this :)
  1344. host = CarlaHostNull()
  1345. progCount = 0
  1346. pluginInfo = PyCarlaPluginInfo
  1347. pluginName = ""
  1348. pluginInfo = host.get_plugin_info(pluginId)
  1349. pluginName = host.get_real_plugin_name(pluginId)
  1350. pluginLabel = pluginInfo['label'].lower()
  1351. pluginMaker = pluginInfo['maker']
  1352. uniqueId = pluginInfo['uniqueId']
  1353. if pluginInfo['type'] in (PLUGIN_VST2, PLUGIN_VST3, PLUGIN_AU):
  1354. progCount = host.get_program_count(pluginId)
  1355. else:
  1356. progCount = host.get_midi_program_count(pluginId)
  1357. # Samplers
  1358. if pluginInfo['type'] == PLUGIN_GIG:
  1359. return "gig"
  1360. if pluginInfo['type'] == PLUGIN_SF2:
  1361. return "sf2"
  1362. if pluginInfo['type'] == PLUGIN_SFZ:
  1363. return "sfz"
  1364. # Calf
  1365. if pluginName.split(" ", 1)[0].lower() == "calf":
  1366. return "calf_black" if "mono" in pluginLabel else "calf_blue"
  1367. # MOD
  1368. #if pluginLabel.startswith("http://moddevices.com/") or pluginLabel.startswith("http://plugin.org.uk/swh-plugins/"):
  1369. #return "mod"
  1370. # OpenAV
  1371. if pluginMaker == "OpenAV Productions":
  1372. return "openav"
  1373. # ZynFX
  1374. if pluginInfo['type'] == PLUGIN_INTERNAL:
  1375. if pluginLabel.startswith("zyn") and pluginInfo['category'] != PLUGIN_CATEGORY_SYNTH:
  1376. return "zynfx"
  1377. if pluginInfo['type'] == PLUGIN_LADSPA:
  1378. if pluginLabel.startswith("zyn") and pluginMaker.startswith("Josep Andreu"):
  1379. return "zynfx"
  1380. if pluginInfo['type'] == PLUGIN_LV2:
  1381. if pluginLabel.startswith("http://kxstudio.sf.net/carla/plugins/zyn") and pluginName != "ZynAddSubFX":
  1382. return "zynfx"
  1383. # Presets
  1384. if progCount > 1 and (pluginInfo['hints'] & PLUGIN_USES_MULTI_PROGS) == 0:
  1385. if pluginInfo['type'] in (PLUGIN_VST2, PLUGIN_VST3, PLUGIN_AU):
  1386. return "presets"
  1387. return "mpresets"
  1388. # DISTRHO Plugins (needs to be last)
  1389. if pluginMaker.startswith("falkTX, ") or pluginMaker == "DISTRHO" or pluginLabel.startswith("http://distrho.sf.net/plugins/"):
  1390. return pluginLabel.replace("http://distrho.sf.net/plugins/","")
  1391. return "default"
  1392. def createPluginSlot(parent, host, pluginId, options):
  1393. if not options['useSkins']:
  1394. return PluginSlot_Classic(parent, host, pluginId)
  1395. skinStyle = getSkinStyle(host, pluginId)
  1396. if "compact" in skinStyle or options['compact']:
  1397. return PluginSlot_Compact(parent, host, pluginId, skinStyle)
  1398. if "calf" in skinStyle:
  1399. return PluginSlot_Calf(parent, host, pluginId, skinStyle)
  1400. if skinStyle in ("mpresets", "presets", "zynfx"):
  1401. return PluginSlot_Presets(parent, host, pluginId, skinStyle)
  1402. return PluginSlot_Default(parent, host, pluginId, skinStyle)
  1403. # ------------------------------------------------------------------------------------------------------------
  1404. # Main Testing
  1405. if __name__ == '__main__':
  1406. from carla_app import CarlaApplication
  1407. from carla_host import initHost, loadHostSettings
  1408. import resources_rc
  1409. app = CarlaApplication("Carla-Skins")
  1410. host = initHost("Skins", None, False, False, False)
  1411. loadHostSettings(host)
  1412. host.engine_init("JACK", "Carla-Widgets")
  1413. host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, "", "", "zynreverb", 0, None, 0x0)
  1414. #host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None, 0x0)
  1415. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://www.openavproductions.com/sorcer", 0, None, 0x0)
  1416. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://calf.sourceforge.net/plugins/Compressor", 0, None, 0x0)
  1417. host.set_active(0, True)
  1418. #gui = createPluginSlot(None, host, 0, True)
  1419. gui = PluginSlot_Compact(None, host, 0, "default")
  1420. gui.testTimer()
  1421. gui.show()
  1422. app.exec_()