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.

1916 lines
70KB

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