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.

1922 lines
70KB

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