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.

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