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

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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847
  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.fEditDialog.setName(name)
  501. if self.label_name is not None:
  502. self.label_name.setText(name)
  503. def setSelected(self, yesNo):
  504. if self.fIsSelected == yesNo:
  505. return
  506. self.fIsSelected = yesNo
  507. self.update()
  508. #------------------------------------------------------------------
  509. def setActive(self, active, sendCallback=False, sendHost=True):
  510. self.fIsActive = active
  511. if sendCallback:
  512. self.fParameterIconTimer = ICON_STATE_ON
  513. self.activeChanged(active)
  514. if sendHost:
  515. self.host.set_active(self.fPluginId, active)
  516. if active:
  517. self.fEditDialog.clearNotes()
  518. self.midiActivityChanged(False)
  519. if self.label_name is not None:
  520. self.label_name.setEnabled(self.fIsActive)
  521. # called from rack, checks if param is possible first
  522. def setInternalParameter(self, parameterId, value):
  523. if parameterId <= PARAMETER_MAX or parameterId >= PARAMETER_NULL:
  524. return
  525. elif parameterId == PARAMETER_ACTIVE:
  526. return self.setActive(bool(value), True, True)
  527. elif parameterId == PARAMETER_DRYWET:
  528. if (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) == 0: return
  529. self.host.set_drywet(self.fPluginId, value)
  530. elif parameterId == PARAMETER_VOLUME:
  531. if (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) == 0: return
  532. self.host.set_volume(self.fPluginId, value)
  533. elif parameterId == PARAMETER_BALANCE_LEFT:
  534. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  535. self.host.set_balance_left(self.fPluginId, value)
  536. elif parameterId == PARAMETER_BALANCE_RIGHT:
  537. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  538. self.host.set_balance_right(self.fPluginId, value)
  539. elif parameterId == PARAMETER_PANNING:
  540. if (self.fPluginInfo['hints'] & PLUGIN_CAN_PANNING) == 0: return
  541. self.host.set_panning(self.fPluginId, value)
  542. elif parameterId == PARAMETER_CTRL_CHANNEL:
  543. self.host.set_ctrl_channel(self.fPluginId, value)
  544. self.fEditDialog.setParameterValue(parameterId, value)
  545. #------------------------------------------------------------------
  546. def setParameterValue(self, parameterId, value, sendCallback):
  547. if parameterId == PARAMETER_ACTIVE:
  548. return self.setActive(bool(value), True, False)
  549. self.fEditDialog.setParameterValue(parameterId, value)
  550. if sendCallback:
  551. self.fParameterIconTimer = ICON_STATE_ON
  552. self.editDialogParameterValueChanged(self.fPluginId, parameterId, value)
  553. def setParameterDefault(self, parameterId, value):
  554. self.fEditDialog.setParameterDefault(parameterId, value)
  555. def setParameterMidiControl(self, parameterId, control):
  556. self.fEditDialog.setParameterMidiControl(parameterId, control)
  557. def setParameterMidiChannel(self, parameterId, channel):
  558. self.fEditDialog.setParameterMidiChannel(parameterId, channel)
  559. #------------------------------------------------------------------
  560. def setProgram(self, index, sendCallback):
  561. self.fEditDialog.setProgram(index)
  562. if sendCallback:
  563. self.fParameterIconTimer = ICON_STATE_ON
  564. self.editDialogProgramChanged(self.fPluginId, index)
  565. self.updateParameterValues()
  566. def setMidiProgram(self, index, sendCallback):
  567. self.fEditDialog.setMidiProgram(index)
  568. if sendCallback:
  569. self.fParameterIconTimer = ICON_STATE_ON
  570. self.editDialogMidiProgramChanged(self.fPluginId, index)
  571. self.updateParameterValues()
  572. #------------------------------------------------------------------
  573. def setOption(self, option, yesNo):
  574. self.fEditDialog.setOption(option, yesNo)
  575. #------------------------------------------------------------------
  576. def activeChanged(self, onOff):
  577. self.fIsActive = onOff
  578. if self.b_enable is None:
  579. return
  580. self.b_enable.blockSignals(True)
  581. self.b_enable.setChecked(onOff)
  582. self.b_enable.blockSignals(False)
  583. def customUiStateChanged(self, state):
  584. if self.b_gui is None:
  585. return
  586. self.b_gui.blockSignals(True)
  587. if state == 0:
  588. self.b_gui.setChecked(False)
  589. self.b_gui.setEnabled(True)
  590. elif state == 1:
  591. self.b_gui.setChecked(True)
  592. self.b_gui.setEnabled(True)
  593. elif state == -1:
  594. self.b_gui.setChecked(False)
  595. self.b_gui.setEnabled(False)
  596. self.b_gui.blockSignals(False)
  597. def parameterActivityChanged(self, onOff):
  598. if self.led_control is None:
  599. return
  600. self.led_control.setChecked(onOff)
  601. def midiActivityChanged(self, onOff):
  602. if self.led_midi is None:
  603. return
  604. self.led_midi.setChecked(onOff)
  605. def optionChanged(self, option, yesNo):
  606. pass
  607. # -----------------------------------------------------------------
  608. # PluginEdit callbacks
  609. def editDialogVisibilityChanged(self, pluginId, visible):
  610. if self.b_edit is None:
  611. return
  612. self.b_edit.blockSignals(True)
  613. self.b_edit.setChecked(visible)
  614. self.b_edit.blockSignals(False)
  615. def editDialogPluginHintsChanged(self, pluginId, hints):
  616. self.fPluginInfo['hints'] = hints
  617. for paramIndex, paramWidget in self.fParameterList:
  618. if paramIndex == PARAMETER_DRYWET:
  619. paramWidget.setVisible(hints & PLUGIN_CAN_DRYWET)
  620. elif paramIndex == PARAMETER_VOLUME:
  621. paramWidget.setVisible(hints & PLUGIN_CAN_VOLUME)
  622. if self.b_gui is not None:
  623. self.b_gui.setEnabled(bool(hints & PLUGIN_HAS_CUSTOM_UI))
  624. def editDialogParameterValueChanged(self, pluginId, parameterId, value):
  625. for paramIndex, paramWidget in self.fParameterList:
  626. if paramIndex != parameterId:
  627. continue
  628. paramWidget.blockSignals(True)
  629. paramWidget.setValue(value)
  630. paramWidget.blockSignals(False)
  631. break
  632. def editDialogProgramChanged(self, pluginId, index):
  633. if self.cb_presets is None:
  634. return
  635. self.cb_presets.blockSignals(True)
  636. self.cb_presets.setCurrentIndex(index)
  637. self.cb_presets.blockSignals(False)
  638. # FIXME
  639. self.updateParameterValues()
  640. def editDialogMidiProgramChanged(self, pluginId, index):
  641. if self.cb_presets is None:
  642. return
  643. self.cb_presets.blockSignals(True)
  644. self.cb_presets.setCurrentIndex(index)
  645. self.cb_presets.blockSignals(False)
  646. # FIXME
  647. self.updateParameterValues()
  648. def editDialogNotePressed(self, pluginId, note):
  649. pass
  650. def editDialogNoteReleased(self, pluginId, note):
  651. pass
  652. def editDialogMidiActivityChanged(self, pluginId, onOff):
  653. self.midiActivityChanged(onOff)
  654. #------------------------------------------------------------------
  655. def idleFast(self):
  656. # Input peaks
  657. if self.fPeaksInputCount > 0:
  658. if self.fPeaksInputCount > 1:
  659. peak1 = self.host.get_input_peak_value(self.fPluginId, True)
  660. peak2 = self.host.get_input_peak_value(self.fPluginId, False)
  661. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  662. if self.peak_in is not None:
  663. self.peak_in.displayMeter(1, peak1)
  664. self.peak_in.displayMeter(2, peak2)
  665. else:
  666. peak = self.host.get_input_peak_value(self.fPluginId, True)
  667. ledState = bool(peak != 0.0)
  668. if self.peak_in is not None:
  669. self.peak_in.displayMeter(1, peak)
  670. if self.fLastGreenLedState != ledState and self.led_audio_in is not None:
  671. self.fLastGreenLedState = ledState
  672. self.led_audio_in.setChecked(ledState)
  673. # Output peaks
  674. if self.fPeaksOutputCount > 0:
  675. if self.fPeaksOutputCount > 1:
  676. peak1 = self.host.get_output_peak_value(self.fPluginId, True)
  677. peak2 = self.host.get_output_peak_value(self.fPluginId, False)
  678. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  679. if self.peak_out is not None:
  680. self.peak_out.displayMeter(1, peak1)
  681. self.peak_out.displayMeter(2, peak2)
  682. else:
  683. peak = self.host.get_output_peak_value(self.fPluginId, True)
  684. ledState = bool(peak != 0.0)
  685. if self.peak_out is not None:
  686. self.peak_out.displayMeter(1, peak)
  687. if self.fLastBlueLedState != ledState and self.led_audio_out is not None:
  688. self.fLastBlueLedState = ledState
  689. self.led_audio_out.setChecked(ledState)
  690. def idleSlow(self):
  691. if self.fParameterIconTimer == ICON_STATE_ON:
  692. self.parameterActivityChanged(True)
  693. self.fParameterIconTimer = ICON_STATE_WAIT
  694. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  695. self.fParameterIconTimer = ICON_STATE_OFF
  696. elif self.fParameterIconTimer == ICON_STATE_OFF:
  697. self.parameterActivityChanged(False)
  698. self.fParameterIconTimer = ICON_STATE_NULL
  699. self.fEditDialog.idleSlow()
  700. #------------------------------------------------------------------
  701. def drawOutline(self):
  702. painter = QPainter(self)
  703. if self.fIsSelected:
  704. painter.setPen(QPen(Qt.cyan, 4))
  705. painter.setBrush(Qt.transparent)
  706. painter.drawRect(0, 0, self.width(), self.height())
  707. else:
  708. painter.setPen(QPen(Qt.black, 1))
  709. painter.setBrush(Qt.black)
  710. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  711. def updateParameterValues(self):
  712. for paramIndex, paramWidget in self.fParameterList:
  713. if paramIndex < 0:
  714. continue
  715. paramWidget.blockSignals(True)
  716. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramIndex))
  717. paramWidget.blockSignals(False)
  718. #------------------------------------------------------------------
  719. @pyqtSlot(bool)
  720. def slot_enableClicked(self, yesNo):
  721. self.setActive(yesNo, False, True)
  722. @pyqtSlot()
  723. def slot_showDefaultCustomMenu(self):
  724. menu = QMenu(self)
  725. # -------------------------------------------------------------
  726. # Expand/Minimize
  727. actCompact = menu.addAction(self.tr("Expand") if isinstance(self, PluginSlot_Compact) else self.tr("Minimize"))
  728. menu.addSeparator()
  729. # -------------------------------------------------------------
  730. # Bypass and Enable/Disable
  731. actBypass = menu.addAction(self.tr("Bypass"))
  732. actEnable = menu.addAction(self.tr("Disable") if self.fIsActive else self.tr("Enable"))
  733. menu.addSeparator()
  734. if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET:
  735. actBypass.setCheckable(True)
  736. actBypass.setChecked(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_DRYWET) == 0.0)
  737. else:
  738. actBypass.setVisible(False)
  739. # -------------------------------------------------------------
  740. # Reset and Randomize parameters
  741. actReset = menu.addAction(self.tr("Reset parameters"))
  742. actRandom = menu.addAction(self.tr("Randomize parameters"))
  743. menu.addSeparator()
  744. # -------------------------------------------------------------
  745. # Edit and Show Custom UI
  746. actEdit = menu.addAction(self.tr("Edit"))
  747. actGui = menu.addAction(self.tr("Show Custom UI"))
  748. menu.addSeparator()
  749. if self.b_edit is not None:
  750. actEdit.setCheckable(True)
  751. actEdit.setChecked(self.b_edit.isChecked())
  752. else:
  753. actEdit.setVisible(False)
  754. if self.b_gui is not None:
  755. actGui.setCheckable(True)
  756. actGui.setChecked(self.b_gui.isChecked())
  757. actGui.setEnabled(self.b_gui.isEnabled())
  758. else:
  759. actGui.setVisible(False)
  760. # -------------------------------------------------------------
  761. # Other stuff
  762. actClone = menu.addAction(self.tr("Clone"))
  763. actReplace = menu.addAction(self.tr("Replace..."))
  764. actRename = menu.addAction(self.tr("Rename..."))
  765. actRemove = menu.addAction(self.tr("Remove"))
  766. if self.fIdleTimerId != 0:
  767. actRemove.setVisible(False)
  768. # -------------------------------------------------------------
  769. # exec
  770. actSel = menu.exec_(QCursor.pos())
  771. if not actSel:
  772. return
  773. # -------------------------------------------------------------
  774. # Expand/Minimize
  775. elif actSel == actCompact:
  776. # FIXME
  777. gCarla.gui.compactPlugin(self.fPluginId)
  778. # -------------------------------------------------------------
  779. # Bypass and Enable/Disable
  780. elif actSel == actBypass:
  781. value = 0.0 if actBypass.isChecked() else 1.0
  782. self.host.set_drywet(self.fPluginId, value)
  783. self.setParameterValue(PARAMETER_DRYWET, value, True)
  784. elif actSel == actEnable:
  785. self.setActive(not self.fIsActive, True, True)
  786. # -------------------------------------------------------------
  787. # Reset and Randomize parameters
  788. elif actSel == actReset:
  789. self.host.reset_parameters(self.fPluginId)
  790. elif actSel == actRandom:
  791. self.host.randomize_parameters(self.fPluginId)
  792. # -------------------------------------------------------------
  793. # Edit and Show Custom UI
  794. elif actSel == actEdit:
  795. self.b_edit.click()
  796. elif actSel == actGui:
  797. self.b_gui.click()
  798. # -------------------------------------------------------------
  799. # Clone
  800. elif actSel == actClone:
  801. if not self.host.clone_plugin(self.fPluginId):
  802. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  803. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  804. # -------------------------------------------------------------
  805. # Rename
  806. elif actSel == actRename:
  807. oldName = self.fPluginInfo['name']
  808. newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName)
  809. if not (newNameTry[1] and newNameTry[0] and oldName != newNameTry[0]):
  810. return
  811. newName = newNameTry[0]
  812. if self.host.rename_plugin(self.fPluginId, newName):
  813. self.setName(newName)
  814. else:
  815. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  816. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  817. # -------------------------------------------------------------
  818. # Replace
  819. elif actSel == actReplace:
  820. # FIXME
  821. gCarla.gui.slot_pluginAdd(self.fPluginId)
  822. # -------------------------------------------------------------
  823. # Remove
  824. elif actSel == actRemove:
  825. if not self.host.remove_plugin(self.fPluginId):
  826. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  827. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  828. # -------------------------------------------------------------
  829. @pyqtSlot()
  830. def slot_knobCustomMenu(self):
  831. sender = self.sender()
  832. index = sender.fIndex
  833. minimum = sender.fMinimum
  834. maximum = sender.fMaximum
  835. current = sender.fRealValue
  836. label = sender.fLabel
  837. if index in (PARAMETER_NULL, PARAMETER_CTRL_CHANNEL) or index <= PARAMETER_MAX:
  838. return
  839. elif index in (PARAMETER_DRYWET, PARAMETER_VOLUME):
  840. default = 1.0
  841. elif index == PARAMETER_BALANCE_LEFT:
  842. default = -1.0
  843. elif index == PARAMETER_BALANCE_RIGHT:
  844. default = 1.0
  845. elif index == PARAMETER_PANNING:
  846. default = 0.0
  847. else:
  848. default = self.host.get_default_parameter_value(self.fPluginId, index)
  849. if index < PARAMETER_NULL:
  850. # show in integer percentage
  851. textReset = self.tr("Reset (%i%%)" % round(default*100.0))
  852. textMinim = self.tr("Set to Minimum (%i%%)" % round(minimum*100.0))
  853. textMaxim = self.tr("Set to Maximum (%i%%)" % round(maximum*100.0))
  854. else:
  855. # show in full float value
  856. textReset = self.tr("Reset (%f)" % default)
  857. textMinim = self.tr("Set to Minimum (%f)" % minimum)
  858. textMaxim = self.tr("Set to Maximum (%f)" % maximum)
  859. menu = QMenu(self)
  860. actReset = menu.addAction(textReset)
  861. menu.addSeparator()
  862. actMinimum = menu.addAction(textMinim)
  863. actCenter = menu.addAction(self.tr("Set to Center"))
  864. actMaximum = menu.addAction(textMaxim)
  865. menu.addSeparator()
  866. actSet = menu.addAction(self.tr("Set value..."))
  867. if index > PARAMETER_NULL or index not in (PARAMETER_BALANCE_LEFT, PARAMETER_BALANCE_RIGHT, PARAMETER_PANNING):
  868. menu.removeAction(actCenter)
  869. actSelected = menu.exec_(QCursor.pos())
  870. if actSelected == actSet:
  871. if index < PARAMETER_NULL:
  872. value, ok = QInputDialog.getInt(self, self.tr("Set value"), label, round(current*100), round(minimum*100), round(maximum*100), 1)
  873. if not ok:
  874. return
  875. value = float(value)/100.0
  876. else:
  877. paramInfo = self.host.get_parameter_info(self.fPluginId, index)
  878. paramRanges = self.host.get_parameter_ranges(self.fPluginId, index)
  879. scalePoints = []
  880. for i in range(paramInfo['scalePointCount']):
  881. scalePoints.append(self.host.get_parameter_scalepoint_info(self.fPluginId, index, i))
  882. dialog = CustomInputDialog(self, label, current, minimum, maximum,
  883. paramRanges['step'], paramRanges['stepSmall'], scalePoints)
  884. if not dialog.exec_():
  885. return
  886. value = dialog.returnValue()
  887. elif actSelected == actMinimum:
  888. value = minimum
  889. elif actSelected == actMaximum:
  890. value = maximum
  891. elif actSelected == actReset:
  892. value = default
  893. elif actSelected == actCenter:
  894. value = 0.0
  895. else:
  896. return
  897. self.sender().setValue(value)
  898. #------------------------------------------------------------------
  899. @pyqtSlot(bool)
  900. def slot_showCustomUi(self, show):
  901. self.host.show_custom_ui(self.fPluginId, show)
  902. @pyqtSlot(bool)
  903. def slot_showEditDialog(self, show):
  904. self.fEditDialog.setVisible(show)
  905. @pyqtSlot()
  906. def slot_removePlugin(self):
  907. if not self.host.remove_plugin(self.fPluginId):
  908. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  909. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  910. #------------------------------------------------------------------
  911. @pyqtSlot(int)
  912. def slot_parameterValueChanged(self, value):
  913. index = self.sender().getIndex()
  914. if index < 0:
  915. self.setInternalParameter(index, value)
  916. else:
  917. self.host.set_parameter_value(self.fPluginId, index, value)
  918. self.setParameterValue(index, value, False)
  919. @pyqtSlot(int)
  920. def slot_programChanged(self, index):
  921. self.host.set_program(self.fPluginId, index)
  922. self.setProgram(index, False)
  923. @pyqtSlot(int)
  924. def slot_midiProgramChanged(self, index):
  925. self.host.set_midi_program(self.fPluginId, index)
  926. self.setMidiProgram(index, False)
  927. #------------------------------------------------------------------
  928. def testTimer(self):
  929. self.fIdleTimerId = self.startTimer(25)
  930. #------------------------------------------------------------------
  931. def mouseDoubleClickEvent(self, event):
  932. QFrame.mouseDoubleClickEvent(self, event)
  933. # FIXME
  934. gCarla.gui.compactPlugin(self.fPluginId)
  935. def closeEvent(self, event):
  936. if self.fIdleTimerId != 0:
  937. self.killTimer(self.fIdleTimerId)
  938. self.fIdleTimerId = 0
  939. self.host.engine_close()
  940. QFrame.closeEvent(self, event)
  941. def timerEvent(self, event):
  942. if event.timerId() == self.fIdleTimerId:
  943. self.host.engine_idle()
  944. self.idleFast()
  945. self.idleSlow()
  946. QFrame.timerEvent(self, event)
  947. def paintEvent(self, event):
  948. self.drawOutline()
  949. QFrame.paintEvent(self, event)
  950. # ------------------------------------------------------------------------------------------------------------
  951. class PluginSlot_Calf(AbstractPluginSlot):
  952. def __init__(self, parent, host, pluginId, skinStyle):
  953. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  954. self.ui = ui_carla_plugin_calf.Ui_PluginWidget()
  955. self.ui.setupUi(self)
  956. audioCount = self.host.get_audio_port_count_info(self.fPluginId)
  957. midiCount = self.host.get_midi_port_count_info(self.fPluginId)
  958. # -------------------------------------------------------------
  959. # Internal stuff
  960. self.fButtonFont = self.ui.b_gui.font()
  961. self.fButtonFont.setBold(False)
  962. self.fButtonFont.setPixelSize(10)
  963. self.fButtonColorOn = QColor( 18, 41, 87)
  964. self.fButtonColorOff = QColor(150, 150, 150)
  965. # -------------------------------------------------------------
  966. # Set-up GUI
  967. self.ui.label_active.setFont(self.fButtonFont)
  968. self.ui.b_remove.setPixmaps(":/bitmaps/button_calf1.png", ":/bitmaps/button_calf1_down.png", ":/bitmaps/button_calf1_hover.png")
  969. self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont)
  970. self.ui.b_remove.setTopText(self.tr("Remove"), self.fButtonColorOn, self.fButtonFont)
  971. if self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI:
  972. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  973. else:
  974. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  975. if audioCount['ins'] == 0:
  976. self.ui.label_audio_in.hide()
  977. if audioCount['outs'] == 0:
  978. self.ui.label_audio_out.hide()
  979. if midiCount['ins'] == 0:
  980. self.ui.label_midi.hide()
  981. self.ui.led_midi.hide()
  982. if self.fIdleTimerId != 0:
  983. self.ui.b_remove.setEnabled(False)
  984. self.ui.b_remove.setVisible(False)
  985. # -------------------------------------------------------------
  986. self.b_enable = self.ui.b_enable
  987. self.b_gui = self.ui.b_gui
  988. self.b_edit = self.ui.b_edit
  989. self.b_remove = self.ui.b_remove
  990. self.label_name = self.ui.label_name
  991. self.led_midi = self.ui.led_midi
  992. self.peak_in = self.ui.peak_in
  993. self.peak_out = self.ui.peak_out
  994. self.w_knobs_left = self.ui.w_knobs
  995. self.ready()
  996. self.ui.led_midi.setColor(self.ui.led_midi.CALF)
  997. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  998. #------------------------------------------------------------------
  999. def getFixedHeight(self):
  1000. return 94 if max(self.peak_in.channelCount(), self.peak_out.channelCount()) < 2 else 106
  1001. #------------------------------------------------------------------
  1002. def editDialogPluginHintsChanged(self, pluginId, hints):
  1003. if hints & PLUGIN_HAS_CUSTOM_UI:
  1004. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  1005. else:
  1006. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  1007. AbstractPluginSlot.editDialogPluginHintsChanged(self, pluginId, hints)
  1008. #------------------------------------------------------------------
  1009. def paintEvent(self, event):
  1010. isBlack = bool(self.fSkinStyle == "calf_black")
  1011. painter = QPainter(self)
  1012. painter.setBrush(Qt.transparent)
  1013. painter.setPen(QPen(QColor(20, 20, 20) if isBlack else QColor(75, 86, 99), 1))
  1014. painter.drawRect(0, 1, self.width()-1, self.height()-3)
  1015. painter.setPen(QPen(QColor(45, 45, 45) if isBlack else QColor(86, 99, 114), 1))
  1016. painter.drawLine(0, 0, self.width(), 0)
  1017. AbstractPluginSlot.paintEvent(self, event)
  1018. # ------------------------------------------------------------------------------------------------------------
  1019. class PluginSlot_Classic(AbstractPluginSlot):
  1020. def __init__(self, parent, host, pluginId):
  1021. AbstractPluginSlot.__init__(self, parent, host, pluginId, "classic")
  1022. self.ui = ui_carla_plugin_classic.Ui_PluginWidget()
  1023. self.ui.setupUi(self)
  1024. # -------------------------------------------------------------
  1025. # Internal stuff
  1026. self.fColorTop = QColor(60, 60, 60)
  1027. self.fColorBottom = QColor(47, 47, 47)
  1028. self.fColorSeprtr = QColor(70, 70, 70)
  1029. # -------------------------------------------------------------
  1030. self.b_enable = self.ui.b_enable
  1031. self.b_gui = self.ui.b_gui
  1032. self.b_edit = self.ui.b_edit
  1033. self.label_name = self.ui.label_name
  1034. self.led_control = self.ui.led_control
  1035. self.led_midi = self.ui.led_midi
  1036. self.led_audio_in = self.ui.led_audio_in
  1037. self.led_audio_out = self.ui.led_audio_out
  1038. self.peak_in = self.ui.peak_in
  1039. self.peak_out = self.ui.peak_out
  1040. self.ready()
  1041. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1042. #------------------------------------------------------------------
  1043. def getFixedHeight(self):
  1044. return 36
  1045. #------------------------------------------------------------------
  1046. def paintEvent(self, event):
  1047. painter = QPainter(self)
  1048. painter.save()
  1049. areaX = self.ui.area_right.x()+7
  1050. width = self.width()
  1051. height = self.height()
  1052. painter.setPen(QPen(QColor(17, 17, 17), 1))
  1053. painter.setBrush(QColor(17, 17, 17))
  1054. painter.drawRect(0, 0, width, height)
  1055. painter.setPen(self.fColorSeprtr.lighter(110))
  1056. painter.setBrush(self.fColorBottom)
  1057. painter.setRenderHint(QPainter.Antialiasing, True)
  1058. # name -> leds arc
  1059. path = QPainterPath()
  1060. path.moveTo(areaX-20, height-4)
  1061. path.cubicTo(areaX, height-5, areaX-20, 4.75, areaX, 4.75)
  1062. path.lineTo(areaX, height-5)
  1063. painter.drawPath(path)
  1064. painter.setPen(self.fColorSeprtr)
  1065. painter.setRenderHint(QPainter.Antialiasing, False)
  1066. # separator lines
  1067. painter.drawLine(0, height-5, areaX-20, height-5)
  1068. painter.drawLine(areaX, 4, width, 4)
  1069. painter.setPen(self.fColorBottom)
  1070. painter.setBrush(self.fColorBottom)
  1071. # top, bottom and left lines
  1072. painter.drawLine(0, 0, width, 0)
  1073. painter.drawRect(0, height-4, areaX, 4)
  1074. painter.drawRoundedRect(areaX-20, height-5, areaX, 5, 22, 22)
  1075. painter.drawLine(0, 0, 0, height)
  1076. # fill the rest
  1077. painter.drawRect(areaX-1, 5, width, height)
  1078. # bottom 1px line
  1079. painter.setPen(self.fColorSeprtr)
  1080. painter.drawLine(0, height-1, width, height-1)
  1081. painter.restore()
  1082. AbstractPluginSlot.paintEvent(self, event)
  1083. # ------------------------------------------------------------------------------------------------------------
  1084. class PluginSlot_Compact(AbstractPluginSlot):
  1085. def __init__(self, parent, host, pluginId, skinStyle):
  1086. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1087. self.ui = ui_carla_plugin_compact.Ui_PluginWidget()
  1088. self.ui.setupUi(self)
  1089. self.b_enable = self.ui.b_enable
  1090. self.b_gui = self.ui.b_gui
  1091. self.b_edit = self.ui.b_edit
  1092. self.label_name = self.ui.label_name
  1093. self.led_control = self.ui.led_control
  1094. self.led_midi = self.ui.led_midi
  1095. self.led_audio_in = self.ui.led_audio_in
  1096. self.led_audio_out = self.ui.led_audio_out
  1097. self.peak_in = self.ui.peak_in
  1098. self.peak_out = self.ui.peak_out
  1099. self.ready()
  1100. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1101. #------------------------------------------------------------------
  1102. def getFixedHeight(self):
  1103. if self.fSkinStyle == "calf_blue":
  1104. return 36
  1105. return 30
  1106. # ------------------------------------------------------------------------------------------------------------
  1107. class PluginSlot_Default(AbstractPluginSlot):
  1108. def __init__(self, parent, host, pluginId, skinStyle):
  1109. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1110. self.ui = ui_carla_plugin_default.Ui_PluginWidget()
  1111. self.ui.setupUi(self)
  1112. # -------------------------------------------------------------
  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.w_knobs_left = self.ui.w_knobs_left
  1124. self.w_knobs_right = self.ui.w_knobs_right
  1125. self.ready()
  1126. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1127. #------------------------------------------------------------------
  1128. def getFixedHeight(self):
  1129. if self.fSkinStyle == "mod":
  1130. return 86
  1131. return 80
  1132. #------------------------------------------------------------------
  1133. def paintEvent(self, event):
  1134. painter = QPainter(self)
  1135. painter.setBrush(Qt.transparent)
  1136. painter.setPen(QPen(QColor(42, 42, 42), 1))
  1137. painter.drawRect(0, 1, self.width()-1, self.getFixedHeight()-3)
  1138. painter.setPen(QPen(QColor(60, 60, 60), 1))
  1139. painter.drawLine(0, 0, self.width(), 0)
  1140. AbstractPluginSlot.paintEvent(self, event)
  1141. # ------------------------------------------------------------------------------------------------------------
  1142. class PluginSlot_Presets(AbstractPluginSlot):
  1143. def __init__(self, parent, host, pluginId, skinStyle):
  1144. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle)
  1145. self.ui = ui_carla_plugin_presets.Ui_PluginWidget()
  1146. self.ui.setupUi(self)
  1147. usingMidiPrograms = bool(skinStyle != "presets")
  1148. # -------------------------------------------------------------
  1149. # Set-up programs
  1150. if usingMidiPrograms:
  1151. programCount = self.host.get_midi_program_count(self.fPluginId)
  1152. else:
  1153. programCount = self.host.get_program_count(self.fPluginId)
  1154. if programCount > 0:
  1155. self.ui.cb_presets.setEnabled(True)
  1156. self.ui.label_presets.setEnabled(True)
  1157. for i in range(programCount):
  1158. if usingMidiPrograms:
  1159. progName = self.host.get_midi_program_data(self.fPluginId, i)['name']
  1160. else:
  1161. progName = self.host.get_program_name(self.fPluginId, i)
  1162. self.ui.cb_presets.addItem(progName)
  1163. if usingMidiPrograms:
  1164. curProg = self.host.get_current_midi_program_index(self.fPluginId)
  1165. else:
  1166. curProg = self.host.get_current_program_index(self.fPluginId)
  1167. self.ui.cb_presets.setCurrentIndex(curProg)
  1168. else:
  1169. self.ui.cb_presets.setEnabled(False)
  1170. self.ui.cb_presets.setVisible(False)
  1171. self.ui.label_presets.setEnabled(False)
  1172. self.ui.label_presets.setVisible(False)
  1173. # -------------------------------------------------------------
  1174. self.b_enable = self.ui.b_enable
  1175. self.b_gui = self.ui.b_gui
  1176. self.b_edit = self.ui.b_edit
  1177. self.cb_presets = self.ui.cb_presets
  1178. self.label_name = self.ui.label_name
  1179. self.label_presets = self.ui.label_presets
  1180. self.led_control = self.ui.led_control
  1181. self.led_midi = self.ui.led_midi
  1182. self.led_audio_in = self.ui.led_audio_in
  1183. self.led_audio_out = self.ui.led_audio_out
  1184. self.peak_in = self.ui.peak_in
  1185. self.peak_out = self.ui.peak_out
  1186. if skinStyle == "zynfx":
  1187. self.setupZynFxParams()
  1188. else:
  1189. self.w_knobs_left = self.ui.w_knobs_left
  1190. self.w_knobs_right = self.ui.w_knobs_right
  1191. self.ready()
  1192. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1193. if usingMidiPrograms:
  1194. self.ui.cb_presets.currentIndexChanged.connect(self.slot_midiProgramChanged)
  1195. else:
  1196. self.ui.cb_presets.currentIndexChanged.connect(self.slot_programChanged)
  1197. # -------------------------------------------------------------
  1198. def setupZynFxParams(self):
  1199. parameterCount = self.host.get_parameter_count(self.fPluginId)
  1200. index = 0
  1201. for i in range(parameterCount):
  1202. if index >= 8:
  1203. break
  1204. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  1205. paramData = self.host.get_parameter_data(self.fPluginId, i)
  1206. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  1207. if paramData['type'] != PARAMETER_INPUT:
  1208. continue
  1209. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  1210. continue
  1211. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1212. continue
  1213. paramName = paramInfo['name']
  1214. if paramName.startswith("unused"):
  1215. continue
  1216. # real zyn fx plugins
  1217. if self.fPluginInfo['label'] == "zynalienwah":
  1218. if i == 0: paramName = "Freq"
  1219. elif i == 1: paramName = "Rnd"
  1220. elif i == 2: paramName = "L type" # combobox
  1221. elif i == 3: paramName = "St.df"
  1222. elif i == 5: paramName = "Fb"
  1223. elif i == 7: paramName = "L/R"
  1224. elif self.fPluginInfo['label'] == "zynchorus":
  1225. if i == 0: paramName = "Freq"
  1226. elif i == 1: paramName = "Rnd"
  1227. elif i == 2: paramName = "L type" # combobox
  1228. elif i == 3: paramName = "St.df"
  1229. elif i == 6: paramName = "Fb"
  1230. elif i == 7: paramName = "L/R"
  1231. elif i == 8: paramName = "Flngr" # button
  1232. elif i == 9: paramName = "Subst" # button
  1233. elif self.fPluginInfo['label'] == "zyndistortion":
  1234. if i == 0: paramName = "LRc."
  1235. elif i == 4: paramName = "Neg." # button
  1236. elif i == 5: paramName = "LPF"
  1237. elif i == 6: paramName = "HPF"
  1238. elif i == 7: paramName = "St." # button
  1239. elif i == 8: paramName = "PF" # button
  1240. elif self.fPluginInfo['label'] == "zyndynamicfilter":
  1241. if i == 0: paramName = "Freq"
  1242. elif i == 1: paramName = "Rnd"
  1243. elif i == 2: paramName = "L type" # combobox
  1244. elif i == 3: paramName = "St.df"
  1245. elif i == 4: paramName = "LfoD"
  1246. elif i == 5: paramName = "A.S."
  1247. elif i == 6: paramName = "A.Inv." # button
  1248. elif i == 7: paramName = "A.M."
  1249. elif self.fPluginInfo['label'] == "zynecho":
  1250. if i == 1: paramName = "LRdl."
  1251. elif i == 2: paramName = "LRc."
  1252. elif i == 3: paramName = "Fb."
  1253. elif i == 4: paramName = "Damp"
  1254. elif self.fPluginInfo['label'] == "zynphaser":
  1255. if i == 0: paramName = "Freq"
  1256. elif i == 1: paramName = "Rnd"
  1257. elif i == 2: paramName = "L type" # combobox
  1258. elif i == 3: paramName = "St.df"
  1259. elif i == 5: paramName = "Fb"
  1260. elif i == 7: paramName = "L/R"
  1261. elif i == 8: paramName = "Subst" # button
  1262. elif i == 9: paramName = "Phase"
  1263. elif i == 11: paramName = "Dist"
  1264. elif self.fPluginInfo['label'] == "zynreverb":
  1265. if i == 2: paramName = "I.delfb"
  1266. elif i == 5: paramName = "LPF"
  1267. elif i == 6: paramName = "HPF"
  1268. elif i == 9: paramName = "R.S."
  1269. elif i == 10: paramName = "I.del"
  1270. else:
  1271. paramName = getParameterShortName(paramName)
  1272. widget = PixmapDial(self, i)
  1273. widget.setLabel(paramName)
  1274. widget.setMinimum(paramRanges['min'])
  1275. widget.setMaximum(paramRanges['max'])
  1276. widget.setPixmap(3)
  1277. widget.setCustomPaintColor(QColor(83, 173, 10))
  1278. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  1279. widget.forceWhiteLabelGradientText()
  1280. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1281. widget.setEnabled(False)
  1282. self.fParameterList.append([i, widget])
  1283. self.ui.w_knobs_left.layout().addWidget(widget)
  1284. if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET:
  1285. widget = PixmapDial(self, PARAMETER_DRYWET)
  1286. widget.setLabel("Wet")
  1287. widget.setMinimum(0.0)
  1288. widget.setMaximum(1.0)
  1289. widget.setPixmap(3)
  1290. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  1291. widget.forceWhiteLabelGradientText()
  1292. self.fParameterList.append([PARAMETER_DRYWET, widget])
  1293. self.ui.w_knobs_right.layout().addWidget(widget)
  1294. if self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME:
  1295. widget = PixmapDial(self, PARAMETER_VOLUME)
  1296. widget.setLabel("Volume")
  1297. widget.setMinimum(0.0)
  1298. widget.setMaximum(1.27)
  1299. widget.setPixmap(3)
  1300. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  1301. widget.forceWhiteLabelGradientText()
  1302. self.fParameterList.append([PARAMETER_VOLUME, widget])
  1303. self.ui.w_knobs_right.layout().addWidget(widget)
  1304. #------------------------------------------------------------------
  1305. def getFixedHeight(self):
  1306. return 80
  1307. #------------------------------------------------------------------
  1308. def paintEvent(self, event):
  1309. painter = QPainter(self)
  1310. painter.setBrush(Qt.transparent)
  1311. painter.setPen(QPen(QColor(50, 50, 50), 1))
  1312. painter.drawRect(0, 1, self.width()-1, self.height()-3)
  1313. painter.setPen(QPen(QColor(64, 64, 64), 1))
  1314. painter.drawLine(0, 0, self.width(), 0)
  1315. AbstractPluginSlot.paintEvent(self, event)
  1316. # ------------------------------------------------------------------------------------------------------------
  1317. def getSkinStyle(host, pluginId):
  1318. if False:
  1319. # kdevelop likes this :)
  1320. host = CarlaHostNull()
  1321. progCount = 0
  1322. pluginInfo = PyCarlaPluginInfo
  1323. pluginName = ""
  1324. pluginInfo = host.get_plugin_info(pluginId)
  1325. pluginName = host.get_real_plugin_name(pluginId)
  1326. pluginLabel = pluginInfo['label'].lower()
  1327. pluginMaker = pluginInfo['maker']
  1328. uniqueId = pluginInfo['uniqueId']
  1329. if pluginInfo['type'] in (PLUGIN_VST2, PLUGIN_VST3, PLUGIN_AU):
  1330. progCount = host.get_program_count(pluginId)
  1331. else:
  1332. progCount = host.get_midi_program_count(pluginId)
  1333. # Samplers
  1334. if pluginInfo['type'] == PLUGIN_GIG:
  1335. return "gig"
  1336. if pluginInfo['type'] == PLUGIN_SF2:
  1337. return "sf2"
  1338. if pluginInfo['type'] == PLUGIN_SFZ:
  1339. return "sfz"
  1340. # Calf
  1341. if pluginName.split(" ", 1)[0].lower() == "calf":
  1342. return "calf_black" if "mono" in pluginLabel else "calf_blue"
  1343. # MOD
  1344. #if pluginLabel.startswith("http://moddevices.com/") or pluginLabel.startswith("http://plugin.org.uk/swh-plugins/"):
  1345. #return "mod"
  1346. # OpenAV
  1347. if pluginMaker == "OpenAV Productions":
  1348. return "openav"
  1349. # ZynFX
  1350. if pluginInfo['type'] == PLUGIN_INTERNAL:
  1351. if pluginLabel.startswith("zyn") and pluginInfo['category'] != PLUGIN_CATEGORY_SYNTH:
  1352. return "zynfx"
  1353. if pluginInfo['type'] == PLUGIN_LADSPA:
  1354. if pluginLabel.startswith("zyn") and pluginMaker.startswith("Josep Andreu"):
  1355. return "zynfx"
  1356. if pluginInfo['type'] == PLUGIN_LV2:
  1357. if pluginLabel.startswith("http://kxstudio.sf.net/carla/plugins/zyn") and pluginName != "ZynAddSubFX":
  1358. return "zynfx"
  1359. # Presets
  1360. if progCount > 1 and (pluginInfo['hints'] & PLUGIN_USES_MULTI_PROGS) == 0:
  1361. if pluginInfo['type'] in (PLUGIN_VST2, PLUGIN_VST3, PLUGIN_AU):
  1362. return "presets"
  1363. return "mpresets"
  1364. # DISTRHO Plugins (needs to be last)
  1365. if pluginMaker.startswith("falkTX, ") or pluginMaker == "DISTRHO" or pluginLabel.startswith("http://distrho.sf.net/plugins/"):
  1366. return pluginLabel.replace("http://distrho.sf.net/plugins/","")
  1367. return "default"
  1368. def createPluginSlot(parent, host, pluginId, options):
  1369. if not options['useSkins']:
  1370. return PluginSlot_Classic(parent, host, pluginId)
  1371. skinStyle = getSkinStyle(host, pluginId)
  1372. if "compact" in skinStyle or options['compact']:
  1373. return PluginSlot_Compact(parent, host, pluginId, skinStyle)
  1374. if "calf" in skinStyle:
  1375. return PluginSlot_Calf(parent, host, pluginId, skinStyle)
  1376. if skinStyle in ("mpresets", "presets", "zynfx"):
  1377. return PluginSlot_Presets(parent, host, pluginId, skinStyle)
  1378. return PluginSlot_Default(parent, host, pluginId, skinStyle)
  1379. # ------------------------------------------------------------------------------------------------------------
  1380. # Main Testing
  1381. if __name__ == '__main__':
  1382. from carla_app import CarlaApplication
  1383. from carla_host import initHost, loadHostSettings
  1384. import resources_rc
  1385. app = CarlaApplication("Carla-Skins")
  1386. host = initHost("Skins", None, False, False, False)
  1387. loadHostSettings(host)
  1388. host.engine_init("JACK", "Carla-Widgets")
  1389. host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, "", "", "zynreverb", 0, None, 0x0)
  1390. #host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None, 0x0)
  1391. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://www.openavproductions.com/sorcer", 0, None, 0x0)
  1392. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://calf.sourceforge.net/plugins/Compressor", 0, None, 0x0)
  1393. host.set_active(0, True)
  1394. #gui = createPluginSlot(None, host, 0, True)
  1395. gui = PluginSlot_Compact(None, host, 0, "default")
  1396. gui.testTimer()
  1397. gui.show()
  1398. app.exec_()