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.

1972 lines
72KB

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