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.

1614 lines
59KB

  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, QPen, QPixmap
  25. from PyQt5.QtWidgets import QFrame, QPushButton
  26. else:
  27. from PyQt4.QtCore import Qt, QRectF
  28. from PyQt4.QtGui import QFont, QFrame, QPen, QPixmap, QPushButton
  29. # ------------------------------------------------------------------------------------------------------------
  30. # Imports (Custom)
  31. import ui_carla_plugin_default
  32. import ui_carla_plugin_basic_fx
  33. import ui_carla_plugin_calf
  34. import ui_carla_plugin_zita
  35. import ui_carla_plugin_zynfx
  36. from carla_widgets import *
  37. from pixmapdial import PixmapDial
  38. # ------------------------------------------------------------------------------------------------------------
  39. # Try to "shortify" a parameter name
  40. def getParameterShortName(paramName):
  41. paramName = paramName.split("/",1)[0].split(" (",1)[0].split(" [",1)[0].strip()
  42. paramLow = paramName.lower()
  43. # Cut generic names
  44. if "bandwidth" in paramLow:
  45. paramName = paramName.replace("andwidth", "w")
  46. elif "distortion" in paramLow:
  47. paramName = paramName.replace("istortion", "ist")
  48. elif "feedback" in paramLow:
  49. paramName = paramName.replace("eedback", "b")
  50. elif "frequency" in paramLow:
  51. paramName = paramName.replace("requency", "req")
  52. elif "output" in paramLow:
  53. paramName = paramName.replace("utput", "ut")
  54. elif "random" in paramLow:
  55. paramName = paramName.replace("andom", "nd")
  56. elif "threshold" in paramLow:
  57. paramName = paramName.replace("hreshold", "hres")
  58. # Cut useless prefix
  59. elif paramLow.startswith("room "):
  60. paramName = paramName.split(" ",1)[1]
  61. # Cut useless suffix
  62. elif paramLow.endswith(" level"):
  63. paramName = paramName.rsplit(" ",1)[0]
  64. elif paramLow.endswith(" time"):
  65. paramName = paramName.rsplit(" ",1)[0]
  66. if len(paramName) > 7:
  67. paramName = paramName[:7]
  68. return paramName.strip()
  69. # ------------------------------------------------------------------------------------------------------------
  70. # Abstract plugin slot
  71. class AbstractPluginSlot(QFrame, PluginEditParentMeta):
  72. #class AbstractPluginSlot(QFrame, PluginEditParentMeta, metaclass=PyQtMetaClass):
  73. def __init__(self, parent, pluginId):
  74. QFrame.__init__(self, parent)
  75. # -------------------------------------------------------------
  76. # Get plugin info
  77. self.fPluginId = pluginId
  78. self.fPluginInfo = gCarla.host.get_plugin_info(self.fPluginId) if gCarla.host is not None else gFakePluginInfo
  79. if not gCarla.isLocal:
  80. self.fPluginInfo['hints'] &= ~PLUGIN_HAS_CUSTOM_UI
  81. # -------------------------------------------------------------
  82. # Internal stuff
  83. self.fIsActive = bool(gCarla.host.get_internal_parameter_value(self.fPluginId, PARAMETER_ACTIVE) >= 0.5) if gCarla.host is not None else True
  84. self.fIsSelected = False
  85. self.fLastGreenLedState = False
  86. self.fLastBlueLedState = False
  87. self.fParameterIconTimer = ICON_STATE_OFF
  88. self.fParameterList = [] # index, widget
  89. if gCarla.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK or gCarla.host is None:
  90. self.fPeaksInputCount = 2
  91. self.fPeaksOutputCount = 2
  92. else:
  93. audioCountInfo = gCarla.host.get_audio_port_count_info(self.fPluginId)
  94. self.fPeaksInputCount = int(audioCountInfo['ins'])
  95. self.fPeaksOutputCount = int(audioCountInfo['outs'])
  96. if self.fPeaksInputCount > 2:
  97. self.fPeaksInputCount = 2
  98. if self.fPeaksOutputCount > 2:
  99. self.fPeaksOutputCount = 2
  100. # -------------------------------------------------------------
  101. # Set-up GUI
  102. self.fEditDialog = PluginEdit(self, gCarla.host, self.fPluginId)
  103. # -------------------------------------------------------------
  104. # Set-up common widgets (as none)
  105. self.b_enable = None
  106. self.b_gui = None
  107. self.b_edit = None
  108. self.b_remove = None
  109. self.cb_presets = None
  110. self.label_name = None
  111. self.label_type = None
  112. self.led_control = None
  113. self.led_midi = None
  114. self.led_audio_in = None
  115. self.led_audio_out = None
  116. self.peak_in = None
  117. self.peak_out = None
  118. #------------------------------------------------------------------
  119. def ready(self):
  120. if self.b_enable is not None:
  121. self.b_enable.setChecked(self.fIsActive)
  122. self.b_enable.clicked.connect(self.slot_enableClicked)
  123. if self.b_gui is not None:
  124. self.b_gui.clicked.connect(self.slot_showCustomUi)
  125. self.b_gui.setEnabled(bool(self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI))
  126. if self.b_edit is None:
  127. # Edit dialog *must* be available
  128. self.b_edit = QPushButton(self)
  129. self.b_edit.setCheckable(True)
  130. self.b_edit.hide()
  131. self.b_edit.clicked.connect(self.slot_showEditDialog)
  132. if self.b_remove is not None:
  133. self.b_remove.clicked.connect(self.slot_removePlugin)
  134. if self.label_name is not None:
  135. self.label_name.setText(self.fPluginInfo['name'])
  136. if self.label_type is not None:
  137. self.label_type.setText(getPluginTypeAsString(self.fPluginInfo['type']))
  138. if self.led_control is not None:
  139. self.led_control.setColor(self.led_control.YELLOW)
  140. self.led_control.setEnabled(False)
  141. if self.led_midi is not None:
  142. self.led_midi.setColor(self.led_midi.RED)
  143. self.led_midi.setEnabled(False)
  144. if self.led_audio_in is not None:
  145. self.led_audio_in.setColor(self.led_audio_in.GREEN)
  146. self.led_audio_in.setEnabled(False)
  147. if self.led_audio_out is not None:
  148. self.led_audio_out.setColor(self.led_audio_out.BLUE)
  149. self.led_audio_out.setEnabled(False)
  150. if self.peak_in is not None:
  151. self.peak_in.setColor(self.peak_in.GREEN)
  152. self.peak_in.setChannels(self.fPeaksInputCount)
  153. self.peak_in.setOrientation(self.peak_in.HORIZONTAL)
  154. if self.peak_out is not None:
  155. self.peak_out.setColor(self.peak_in.BLUE)
  156. self.peak_out.setChannels(self.fPeaksOutputCount)
  157. self.peak_out.setOrientation(self.peak_out.HORIZONTAL)
  158. if gCarla.host is None:
  159. return
  160. for paramIndex, paramWidget in self.fParameterList:
  161. paramWidget.setContextMenuPolicy(Qt.CustomContextMenu)
  162. paramWidget.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  163. paramWidget.realValueChanged.connect(self.slot_parameterValueChanged)
  164. paramWidget.setValue(gCarla.host.get_internal_parameter_value(self.fPluginId, paramIndex))
  165. #------------------------------------------------------------------
  166. def getFixedHeight(self):
  167. return 32
  168. def getHints(self):
  169. return self.fPluginInfo['hints']
  170. def getPluginId(self):
  171. return self.fPluginId
  172. #------------------------------------------------------------------
  173. def setId(self, idx):
  174. self.fPluginId = idx
  175. self.fEditDialog.setId(idx)
  176. def setName(self, name):
  177. self.fEditDialog.setName(name)
  178. if self.label_name is not None:
  179. self.label_name.setText(name)
  180. def setSelected(self, yesNo):
  181. if self.fIsSelected == yesNo:
  182. return
  183. self.fIsSelected = yesNo
  184. self.update()
  185. #------------------------------------------------------------------
  186. def setActive(self, active, sendCallback=False, sendHost=True):
  187. self.fIsActive = active
  188. if sendCallback:
  189. self.fParameterIconTimer = ICON_STATE_ON
  190. self.activeChanged(active)
  191. if sendHost:
  192. gCarla.host.set_active(self.fPluginId, active)
  193. if active:
  194. self.fEditDialog.clearNotes()
  195. self.midiActivityChanged(False)
  196. # called from rack, checks if param is possible first
  197. def setInternalParameter(self, parameterId, value):
  198. if parameterId <= PARAMETER_MAX or parameterId >= PARAMETER_NULL:
  199. return
  200. elif parameterId == PARAMETER_ACTIVE:
  201. return self.setActive(bool(value), True, True)
  202. elif parameterId == PARAMETER_DRYWET:
  203. if (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) == 0: return
  204. gCarla.host.set_drywet(self.fPluginId, value)
  205. elif parameterId == PARAMETER_VOLUME:
  206. if (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) == 0: return
  207. gCarla.host.set_volume(self.fPluginId, value)
  208. elif parameterId == PARAMETER_BALANCE_LEFT:
  209. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  210. gCarla.host.set_balance_left(self.fPluginId, value)
  211. elif parameterId == PARAMETER_BALANCE_RIGHT:
  212. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  213. gCarla.host.set_balance_right(self.fPluginId, value)
  214. elif parameterId == PARAMETER_PANNING:
  215. if (self.fPluginInfo['hints'] & PLUGIN_CAN_PANNING) == 0: return
  216. gCarla.host.set_panning(self.fPluginId, value)
  217. elif parameterId == PARAMETER_CTRL_CHANNEL:
  218. gCarla.host.set_ctrl_channel(self.fPluginId, value)
  219. self.fEditDialog.setParameterValue(parameterId, value)
  220. #------------------------------------------------------------------
  221. def setParameterValue(self, parameterId, value, sendCallback):
  222. if parameterId == PARAMETER_ACTIVE:
  223. return self.setActive(bool(value), True, False)
  224. self.fEditDialog.setParameterValue(parameterId, value)
  225. if sendCallback:
  226. self.fParameterIconTimer = ICON_STATE_ON
  227. self.parameterValueChanged(parameterId, value)
  228. def setParameterDefault(self, parameterId, value):
  229. self.fEditDialog.setParameterDefault(parameterId, value)
  230. def setParameterMidiControl(self, parameterId, control):
  231. self.fEditDialog.setParameterMidiControl(parameterId, control)
  232. def setParameterMidiChannel(self, parameterId, channel):
  233. self.fEditDialog.setParameterMidiChannel(parameterId, channel)
  234. #------------------------------------------------------------------
  235. def setProgram(self, index, sendCallback):
  236. self.fEditDialog.setProgram(index)
  237. if sendCallback:
  238. self.fParameterIconTimer = ICON_STATE_ON
  239. self.programChanged(index)
  240. def setMidiProgram(self, index, sendCallback):
  241. self.fEditDialog.setMidiProgram(index)
  242. if sendCallback:
  243. self.fParameterIconTimer = ICON_STATE_ON
  244. self.midiProgramChanged(index)
  245. #------------------------------------------------------------------
  246. def setOption(self, option, yesNo):
  247. self.fEditDialog.setOption(option, yesNo)
  248. #------------------------------------------------------------------
  249. def sendNoteOn(self, channel, note):
  250. if self.fEditDialog.sendNoteOn(channel, note):
  251. self.midiActivityChanged(True)
  252. def sendNoteOff(self, channel, note):
  253. if self.fEditDialog.sendNoteOff(channel, note):
  254. self.midiActivityChanged(False)
  255. #------------------------------------------------------------------
  256. def activeChanged(self, onOff):
  257. self.fIsActive = onOff
  258. if self.b_enable is None:
  259. return
  260. self.b_enable.blockSignals(True)
  261. self.b_enable.setChecked(onOff)
  262. self.b_enable.blockSignals(False)
  263. def customUiStateChanged(self, state):
  264. if self.b_gui is None:
  265. return
  266. self.b_gui.blockSignals(True)
  267. if state == 0:
  268. self.b_gui.setChecked(False)
  269. self.b_gui.setEnabled(True)
  270. elif state == 1:
  271. self.b_gui.setChecked(True)
  272. self.b_gui.setEnabled(True)
  273. elif state == -1:
  274. self.b_gui.setChecked(False)
  275. self.b_gui.setEnabled(False)
  276. self.b_gui.blockSignals(False)
  277. def parameterActivityChanged(self, onOff):
  278. if self.led_control is None:
  279. return
  280. self.led_control.setChecked(onOff)
  281. def midiActivityChanged(self, onOff):
  282. if self.led_midi is None:
  283. return
  284. self.led_midi.setChecked(onOff)
  285. def optionChanged(self, option, yesNo):
  286. pass
  287. # -----------------------------------------------------------------
  288. # PluginEdit callbacks
  289. def editDialogChanged(self, visible):
  290. if self.b_edit is None:
  291. return
  292. self.b_edit.blockSignals(True)
  293. self.b_edit.setChecked(visible)
  294. self.b_edit.blockSignals(False)
  295. def pluginHintsChanged(self, hints):
  296. self.fPluginInfo['hints'] = hints
  297. self.ui.dial_drywet.setVisible(hints & PLUGIN_CAN_DRYWET)
  298. self.ui.dial_vol.setVisible(hints & PLUGIN_CAN_VOLUME)
  299. if self.b_gui is not None:
  300. self.b_gui.setEnabled(bool(hints & PLUGIN_HAS_CUSTOM_UI))
  301. def parameterValueChanged(self, parameterId, value):
  302. for paramIndex, paramWidget in self.fParameterList:
  303. if paramIndex != parameterId:
  304. continue
  305. paramWidget.blockSignals(True)
  306. paramWidget.setValue(value)
  307. paramWidget.blockSignals(False)
  308. break
  309. def programChanged(self, index):
  310. if self.cb_presets is None:
  311. return
  312. self.cb_presets.blockSignals(True)
  313. self.cb_presets.setCurrentIndex(index)
  314. self.cb_presets.blockSignals(False)
  315. def midiProgramChanged(self, index):
  316. if self.cb_presets is None:
  317. return
  318. self.cb_presets.blockSignals(True)
  319. self.cb_presets.setCurrentIndex(index)
  320. self.cb_presets.blockSignals(False)
  321. def notePressed(self, note):
  322. pass
  323. def noteReleased(self, note):
  324. pass
  325. #------------------------------------------------------------------
  326. def idleFast(self):
  327. # Input peaks
  328. if self.fPeaksInputCount > 0:
  329. if self.fPeaksInputCount > 1:
  330. peak1 = gCarla.host.get_input_peak_value(self.fPluginId, True)
  331. peak2 = gCarla.host.get_input_peak_value(self.fPluginId, False)
  332. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  333. if self.peak_in is not None:
  334. self.peak_in.displayMeter(1, peak1)
  335. self.peak_in.displayMeter(2, peak2)
  336. else:
  337. peak = gCarla.host.get_input_peak_value(self.fPluginId, True)
  338. ledState = bool(peak != 0.0)
  339. if self.peak_in is not None:
  340. self.peak_in.displayMeter(1, peak)
  341. if self.fLastGreenLedState != ledState and self.led_audio_in is not None:
  342. self.fLastGreenLedState = ledState
  343. self.led_audio_in.setChecked(ledState)
  344. # Output peaks
  345. if self.fPeaksOutputCount > 0:
  346. if self.fPeaksOutputCount > 1:
  347. peak1 = gCarla.host.get_output_peak_value(self.fPluginId, True)
  348. peak2 = gCarla.host.get_output_peak_value(self.fPluginId, False)
  349. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  350. if self.peak_out is not None:
  351. self.peak_out.displayMeter(1, peak1)
  352. self.peak_out.displayMeter(2, peak2)
  353. else:
  354. peak = gCarla.host.get_output_peak_value(self.fPluginId, True)
  355. ledState = bool(peak != 0.0)
  356. if self.peak_out is not None:
  357. self.peak_out.displayMeter(1, peak)
  358. if self.fLastBlueLedState != ledState and self.led_audio_out is not None:
  359. self.fLastBlueLedState = ledState
  360. self.led_audio_out.setChecked(ledState)
  361. def idleSlow(self):
  362. if self.fParameterIconTimer == ICON_STATE_ON:
  363. self.fParameterIconTimer = ICON_STATE_WAIT1
  364. self.parameterActivityChanged(True)
  365. elif self.fParameterIconTimer == ICON_STATE_WAIT1:
  366. self.fParameterIconTimer = ICON_STATE_WAIT2
  367. elif self.fParameterIconTimer == ICON_STATE_WAIT2:
  368. self.fParameterIconTimer = ICON_STATE_OFF
  369. self.parameterActivityChanged(False)
  370. self.fEditDialog.idleSlow()
  371. #------------------------------------------------------------------
  372. def drawOutline(self):
  373. painter = QPainter(self)
  374. if self.fIsSelected:
  375. painter.setPen(QPen(Qt.cyan, 4))
  376. painter.setBrush(Qt.transparent)
  377. painter.drawRect(0, 0, self.width(), self.height())
  378. else:
  379. painter.setPen(QPen(Qt.black, 1))
  380. painter.setBrush(Qt.black)
  381. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  382. def showDefaultCustomMenu(self, isEnabled, bEdit = None, bGui = None):
  383. menu = QMenu(self)
  384. actActive = menu.addAction(self.tr("Disable") if isEnabled else self.tr("Enable"))
  385. menu.addSeparator()
  386. actReset = menu.addAction(self.tr("Reset parameters"))
  387. actRandom = menu.addAction(self.tr("Randomize parameters"))
  388. menu.addSeparator()
  389. if bEdit is not None:
  390. actEdit = menu.addAction(self.tr("Edit"))
  391. actEdit.setCheckable(True)
  392. actEdit.setChecked(bEdit.isChecked())
  393. else:
  394. actEdit = None
  395. if bGui is not None:
  396. actGui = menu.addAction(self.tr("Show Custom UI"))
  397. actGui.setCheckable(True)
  398. actGui.setChecked(bGui.isChecked())
  399. actGui.setEnabled(bGui.isEnabled())
  400. else:
  401. actGui = None
  402. menu.addSeparator()
  403. actClone = menu.addAction(self.tr("Clone"))
  404. actReplace = menu.addAction(self.tr("Replace..."))
  405. actRename = menu.addAction(self.tr("Rename..."))
  406. actRemove = menu.addAction(self.tr("Remove"))
  407. actSel = menu.exec_(QCursor.pos())
  408. if not actSel:
  409. return
  410. if actSel == actActive:
  411. self.setActive(not isEnabled, True, True)
  412. elif actSel == actReset:
  413. if gCarla.host is None: return
  414. gCarla.host.reset_parameters(self.fPluginId)
  415. elif actSel == actRandom:
  416. if gCarla.host is None: return
  417. gCarla.host.randomize_parameters(self.fPluginId)
  418. elif actSel == actGui:
  419. bGui.click()
  420. elif actSel == actEdit:
  421. bEdit.click()
  422. elif actSel == actClone:
  423. if gCarla.host is not None and not gCarla.host.clone_plugin(self.fPluginId):
  424. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  425. gCarla.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  426. elif actSel == actRename:
  427. oldName = self.fPluginInfo['name']
  428. newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName)
  429. if not (newNameTry[1] and newNameTry[0] and oldName != newNameTry[0]):
  430. return
  431. newName = newNameTry[0]
  432. if gCarla.host is None or gCarla.host.rename_plugin(self.fPluginId, newName):
  433. self.setName(newName)
  434. else:
  435. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  436. gCarla.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  437. elif actSel == actReplace:
  438. gCarla.gui.slot_pluginAdd(self.fPluginId)
  439. elif actSel == actRemove:
  440. if gCarla.host is not None and not gCarla.host.remove_plugin(self.fPluginId):
  441. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  442. gCarla.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  443. #------------------------------------------------------------------
  444. @pyqtSlot(bool)
  445. def slot_enableClicked(self, yesNo):
  446. self.setActive(yesNo, False, True)
  447. @pyqtSlot()
  448. def slot_showDefaultCustomMenu(self):
  449. self.showDefaultCustomMenu(self.fIsActive, self.b_edit, self.b_gui)
  450. @pyqtSlot()
  451. def slot_knobCustomMenu(self):
  452. sender = self.sender()
  453. index = sender.fIndex
  454. minimum = sender.fMinimum
  455. maximum = sender.fMaximum
  456. current = sender.fRealValue
  457. label = sender.fLabel
  458. if index in (PARAMETER_DRYWET, PARAMETER_VOLUME):
  459. default = 1.0
  460. resetText = self.tr("Reset (%i%%)" % int(default*100.0))
  461. minimText = self.tr("Set to Minimum (%i%%)" % int(minimum*100.0))
  462. maximText = self.tr("Set to Maximum (%i%%)" % int(maximum*100.0))
  463. else:
  464. default = gCarla.host.get_default_parameter_value(self.fPluginId, index)
  465. resetText = self.tr("Reset (%f)" % default)
  466. minimText = self.tr("Set to Minimum (%f)" % minimum)
  467. maximText = self.tr("Set to Maximum (%f)" % maximum)
  468. menu = QMenu(self)
  469. actReset = menu.addAction(resetText)
  470. menu.addSeparator()
  471. actMinimum = menu.addAction(minimText)
  472. actMaximum = menu.addAction(maximText)
  473. menu.addSeparator()
  474. actSet = menu.addAction(self.tr("Set value..."))
  475. actSelected = menu.exec_(QCursor.pos())
  476. if actSelected == actSet:
  477. valueTry = QInputDialog.getDouble(self, self.tr("Set value"), label, current, minimum, maximum, 3) # FIXME - 3 decimals
  478. if valueTry[1]:
  479. value = valueTry[0] * 10
  480. else:
  481. return
  482. elif actSelected == actMinimum:
  483. value = minimum
  484. elif actSelected == actMaximum:
  485. value = maximum
  486. elif actSelected == actReset:
  487. value = default
  488. else:
  489. return
  490. self.sender().setValue(value)
  491. #------------------------------------------------------------------
  492. @pyqtSlot(bool)
  493. def slot_showCustomUi(self, show):
  494. gCarla.host.show_custom_ui(self.fPluginId, show)
  495. @pyqtSlot(bool)
  496. def slot_showEditDialog(self, show):
  497. self.fEditDialog.setVisible(show)
  498. @pyqtSlot()
  499. def slot_removePlugin(self):
  500. gCarla.host.remove_plugin(self.fPluginId)
  501. #------------------------------------------------------------------
  502. @pyqtSlot(int)
  503. def slot_parameterValueChanged(self, value):
  504. index = self.sender().getIndex()
  505. if index < 0:
  506. self.setInternalParameter(index, value)
  507. else:
  508. gCarla.host.set_parameter_value(self.fPluginId, index, value)
  509. self.setParameterValue(index, value, False)
  510. @pyqtSlot(int)
  511. def slot_programChanged(self, index):
  512. gCarla.host.set_program(self.fPluginId, index)
  513. self.setProgram(index, False)
  514. @pyqtSlot(int)
  515. def slot_midiProgramChanged(self, index):
  516. gCarla.host.set_midi_program(self.fPluginId, index)
  517. self.setMidiProgram(index, False)
  518. #------------------------------------------------------------------
  519. def paintEvent(self, event):
  520. self.drawOutline()
  521. QFrame.paintEvent(self, event)
  522. # ------------------------------------------------------------------------------------------------------------
  523. class PluginSlot_Default(AbstractPluginSlot):
  524. def __init__(self, parent, pluginId):
  525. AbstractPluginSlot.__init__(self, parent, pluginId)
  526. self.ui = ui_carla_plugin_default.Ui_PluginWidget()
  527. self.ui.setupUi(self)
  528. # -------------------------------------------------------------
  529. # Internal stuff
  530. self.fColorTop = QColor(60, 60, 60)
  531. self.fColorBottom = QColor(47, 47, 47)
  532. self.fColorSeprtr = QColor(70, 70, 70)
  533. # -------------------------------------------------------------
  534. # Set-up GUI
  535. self.setStyleSheet("""
  536. QLabel#label_name {
  537. color: #BBB;
  538. }
  539. """)
  540. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  541. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  542. if self.fPluginInfo['iconName'] == "distrho":
  543. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  544. elif self.fPluginInfo['iconName'] == "file":
  545. self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  546. else:
  547. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  548. # -------------------------------------------------------------
  549. self.b_enable = self.ui.b_enable
  550. self.b_gui = self.ui.b_gui
  551. self.b_edit = self.ui.b_edit
  552. self.label_name = self.ui.label_name
  553. self.led_control = self.ui.led_control
  554. self.led_midi = self.ui.led_midi
  555. self.led_audio_in = self.ui.led_audio_in
  556. self.led_audio_out = self.ui.led_audio_out
  557. self.peak_in = self.ui.peak_in
  558. self.peak_out = self.ui.peak_out
  559. self.ready()
  560. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  561. #------------------------------------------------------------------
  562. def getFixedHeight(self):
  563. return 36
  564. #------------------------------------------------------------------
  565. def paintEvent(self, event):
  566. painter = QPainter(self)
  567. painter.save()
  568. areaX = self.ui.area_right.x()+7
  569. width = self.width()
  570. height = self.height()
  571. painter.setPen(QPen(QColor(17, 17, 17), 1))
  572. painter.setBrush(QColor(17, 17, 17))
  573. painter.drawRect(0, 0, width, height)
  574. painter.setPen(self.fColorSeprtr.lighter(110))
  575. painter.setBrush(self.fColorBottom)
  576. painter.setRenderHint(QPainter.Antialiasing, True)
  577. # name -> leds arc
  578. path = QPainterPath()
  579. path.moveTo(areaX-20, height-4)
  580. path.cubicTo(areaX, height-5, areaX-20, 4.75, areaX, 4.75)
  581. path.lineTo(areaX, height-5)
  582. painter.drawPath(path)
  583. painter.setPen(self.fColorSeprtr)
  584. painter.setRenderHint(QPainter.Antialiasing, False)
  585. # separator lines
  586. painter.drawLine(0, height-5, areaX-20, height-5)
  587. painter.drawLine(areaX, 4, width, 4)
  588. painter.setPen(self.fColorBottom)
  589. painter.setBrush(self.fColorBottom)
  590. # top, bottom and left lines
  591. painter.drawLine(0, 0, width, 0)
  592. painter.drawRect(0, height-4, areaX, 4)
  593. painter.drawRoundedRect(areaX-20, height-5, areaX, 5, 22, 22)
  594. painter.drawLine(0, 0, 0, height)
  595. # fill the rest
  596. painter.drawRect(areaX-1, 5, width, height)
  597. # bottom 1px line
  598. painter.setPen(self.fColorSeprtr)
  599. painter.drawLine(0, height-1, width, height-1)
  600. painter.restore()
  601. AbstractPluginSlot.paintEvent(self, event)
  602. # ------------------------------------------------------------------------------------------------------------
  603. class PluginSlot_BasicFX(AbstractPluginSlot):
  604. def __init__(self, parent, pluginId):
  605. AbstractPluginSlot.__init__(self, parent, pluginId)
  606. self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget()
  607. self.ui.setupUi(self)
  608. # -------------------------------------------------------------
  609. # Set-up GUI
  610. labelFont = self.ui.label_name.font()
  611. labelFont.setBold(True)
  612. labelFont.setPointSize(9)
  613. self.ui.label_name.setFont(labelFont)
  614. r = 40
  615. g = 40
  616. b = 40
  617. if self.fPluginInfo['category'] == PLUGIN_CATEGORY_MODULATOR:
  618. r += 10
  619. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_EQ:
  620. g += 10
  621. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  622. b += 10
  623. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  624. r += 15
  625. b -= 15
  626. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DISTORTION:
  627. g += 10
  628. b += 10
  629. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DYNAMICS:
  630. r += 10
  631. b += 10
  632. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_UTILITY:
  633. r += 10
  634. g += 10
  635. bg = "noise1"
  636. if self.fPluginInfo['maker'] in ("falkTX, Michael Gruhn", "DISTRHO") and "3bandeq" in self.fPluginInfo['label'].lower():
  637. bg = "3bandeq"
  638. self.setStyleSheet("""
  639. PluginSlot_BasicFX#PluginWidget {
  640. background-color: rgb(%i, %i, %i);
  641. background-image: url(:/bitmaps/background_%s.png);
  642. background-repeat: repeat-xy;
  643. }
  644. QLabel#label_name {
  645. color: #BBB;
  646. }
  647. """ % (r, g, b, bg))
  648. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  649. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  650. if self.fPluginInfo['iconName'] == "distrho":
  651. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  652. elif self.fPluginInfo['iconName'] == "file":
  653. self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  654. else:
  655. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  656. # -------------------------------------------------------------
  657. # Set-up parameters
  658. parameterCount = gCarla.host.get_parameter_count(self.fPluginId) if gCarla.host is not None else 0
  659. index = 0
  660. for i in range(parameterCount):
  661. if index >= 8:
  662. break
  663. paramInfo = gCarla.host.get_parameter_info(self.fPluginId, i)
  664. paramData = gCarla.host.get_parameter_data(self.fPluginId, i)
  665. paramRanges = gCarla.host.get_parameter_ranges(self.fPluginId, i)
  666. if paramData['type'] != PARAMETER_INPUT:
  667. continue
  668. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  669. continue
  670. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  671. continue
  672. paramName = getParameterShortName(paramInfo['name'])
  673. #if self.fPluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  674. #_r = 55 + float(i)/8*200
  675. #_g = 255 - float(i)/8*200
  676. #_b = 127 - r*2
  677. #elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  678. #_r = 127
  679. #_g = 55 + float(i)/8*200
  680. #_b = 255 - float(i)/8*200
  681. #elif r < b < g:
  682. #_r = 55 + float(i)/8*200
  683. #_g = 127
  684. #_b = 255 - float(i)/8*200
  685. #else:
  686. _r = 255 - float(index)/8*200
  687. _g = 55 + float(index)/8*200
  688. _b = (r-40)*4
  689. #if _r < 140: _r = 140
  690. #if _g < 140: _g = 140
  691. #if _b < 140: _b = 140
  692. widget = PixmapDial(self, i)
  693. widget.setPixmap(3)
  694. widget.setLabel(paramName)
  695. widget.setCustomPaintColor(QColor(_r, _g, _b))
  696. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  697. widget.forceWhiteLabelGradientText()
  698. widget.setMinimum(paramRanges['min'])
  699. widget.setMaximum(paramRanges['max'])
  700. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  701. widget.setEnabled(False)
  702. self.ui.w_knobs.layout().insertWidget(index, widget)
  703. index += 1
  704. self.fParameterList.append([i, widget])
  705. self.ui.dial_drywet.setIndex(PARAMETER_DRYWET)
  706. self.ui.dial_drywet.setPixmap(3)
  707. self.ui.dial_drywet.setLabel("Dry/Wet")
  708. self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  709. self.ui.dial_drywet.setMinimum(0.0)
  710. self.ui.dial_drywet.setMaximum(1.0)
  711. self.ui.dial_drywet.forceWhiteLabelGradientText()
  712. self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET)
  713. self.ui.dial_vol.setIndex(PARAMETER_VOLUME)
  714. self.ui.dial_vol.setPixmap(3)
  715. self.ui.dial_vol.setLabel("Volume")
  716. self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  717. self.ui.dial_vol.setMinimum(0.0)
  718. self.ui.dial_vol.setMaximum(1.27)
  719. self.ui.dial_vol.forceWhiteLabelGradientText()
  720. self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME)
  721. self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet])
  722. self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol])
  723. # -------------------------------------------------------------
  724. self.b_enable = self.ui.b_enable
  725. self.b_gui = self.ui.b_gui
  726. self.b_edit = self.ui.b_edit
  727. self.label_name = self.ui.label_name
  728. self.led_control = self.ui.led_control
  729. self.led_midi = self.ui.led_midi
  730. self.led_audio_in = self.ui.led_audio_in
  731. self.led_audio_out = self.ui.led_audio_out
  732. self.peak_in = self.ui.peak_in
  733. self.peak_out = self.ui.peak_out
  734. self.ready()
  735. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  736. #------------------------------------------------------------------
  737. def getFixedHeight(self):
  738. return 79
  739. #------------------------------------------------------------------
  740. def paintEvent(self, event):
  741. painter = QPainter(self)
  742. painter.setBrush(Qt.transparent)
  743. painter.setPen(QPen(QColor(42, 42, 42), 1))
  744. painter.drawRect(0, 1, self.width()-1, 79-3)
  745. painter.setPen(QPen(QColor(60, 60, 60), 1))
  746. painter.drawLine(0, 0, self.width(), 0)
  747. AbstractPluginSlot.paintEvent(self, event)
  748. # ------------------------------------------------------------------------------------------------------------
  749. class PluginSlot_Calf(AbstractPluginSlot):
  750. def __init__(self, parent, pluginId):
  751. AbstractPluginSlot.__init__(self, parent, pluginId)
  752. self.ui = ui_carla_plugin_calf.Ui_PluginWidget()
  753. self.ui.setupUi(self)
  754. audioCount = gCarla.host.get_audio_port_count_info(self.fPluginId) if gCarla.host is not None else {'ins': 2, 'outs': 2 }
  755. midiCount = gCarla.host.get_midi_port_count_info(self.fPluginId) if gCarla.host is not None else {'ins': 1, 'outs': 0 }
  756. # -------------------------------------------------------------
  757. # Internal stuff
  758. self.fButtonFont = self.ui.b_gui.font()
  759. self.fButtonFont.setBold(False)
  760. self.fButtonFont.setPointSize(8)
  761. # Use black for mono plugins
  762. self.fBackgroundBlack = audioCount['ins'] == 1
  763. self.fButtonColorOn = QColor( 18, 41, 87)
  764. self.fButtonColorOff = QColor(150, 150, 150)
  765. # -------------------------------------------------------------
  766. # Set-up GUI
  767. self.setStyleSheet("""
  768. QLabel#label_name, QLabel#label_audio_in, QLabel#label_audio_out, QLabel#label_midi {
  769. color: #BBB;
  770. }
  771. PluginSlot_Calf#PluginWidget {
  772. background-image: url(:/bitmaps/background_calf_%s.png);
  773. background-repeat: repeat-xy;
  774. border: 2px;
  775. }
  776. """ % ("black" if self.fBackgroundBlack else "blue"))
  777. self.ui.b_gui.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  778. self.ui.b_edit.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  779. self.ui.b_remove.setPixmaps(":/bitmaps/button_calf1.png", ":/bitmaps/button_calf1_down.png", ":/bitmaps/button_calf1_hover.png")
  780. self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont)
  781. self.ui.b_remove.setTopText(self.tr("Remove"), self.fButtonColorOn, self.fButtonFont)
  782. if self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI:
  783. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  784. else:
  785. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  786. labelFont = self.ui.label_name.font()
  787. labelFont.setBold(True)
  788. labelFont.setPointSize(10)
  789. self.ui.label_name.setFont(labelFont)
  790. if audioCount['ins'] == 0:
  791. self.ui.label_audio_in.hide()
  792. self.ui.peak_in.hide()
  793. if audioCount['outs'] > 0:
  794. self.ui.peak_out.setMinimumWidth(200)
  795. if audioCount['outs'] == 0:
  796. self.ui.label_audio_out.hide()
  797. self.ui.peak_out.hide()
  798. if midiCount['ins'] == 0:
  799. self.ui.label_midi.hide()
  800. self.ui.led_midi.hide()
  801. # -------------------------------------------------------------
  802. # Set-up parameters
  803. parameterCount = gCarla.host.get_parameter_count(self.fPluginId) if gCarla.host is not None else 0
  804. index = 0
  805. limit = 7 if midiCount['ins'] == 0 else 6
  806. for i in range(parameterCount):
  807. if index >= limit:
  808. break
  809. paramInfo = gCarla.host.get_parameter_info(self.fPluginId, i)
  810. paramData = gCarla.host.get_parameter_data(self.fPluginId, i)
  811. paramRanges = gCarla.host.get_parameter_ranges(self.fPluginId, i)
  812. if paramData['type'] != PARAMETER_INPUT:
  813. continue
  814. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  815. continue
  816. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  817. continue
  818. paramName = getParameterShortName(paramInfo['name'])
  819. widget = PixmapDial(self, i)
  820. widget.setPixmap(7)
  821. widget.setLabel(paramName)
  822. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  823. widget.setMinimum(paramRanges['min'])
  824. widget.setMaximum(paramRanges['max'])
  825. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  826. widget.setEnabled(False)
  827. self.ui.w_knobs.layout().insertWidget(index, widget)
  828. index += 1
  829. self.fParameterList.append([i, widget])
  830. # -------------------------------------------------------------
  831. self.b_gui = self.ui.b_gui
  832. self.b_edit = self.ui.b_edit
  833. self.b_remove = self.ui.b_remove
  834. self.label_name = self.ui.label_name
  835. self.led_midi = self.ui.led_midi
  836. self.peak_in = self.ui.peak_in
  837. self.peak_out = self.ui.peak_out
  838. self.ready()
  839. self.ui.led_midi.setColor(self.ui.led_midi.CALF)
  840. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  841. #------------------------------------------------------------------
  842. def getFixedHeight(self):
  843. return 88
  844. #------------------------------------------------------------------
  845. def pluginHintsChanged(self, hints):
  846. if hints & PLUGIN_HAS_CUSTOM_UI:
  847. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  848. else:
  849. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  850. AbstractPluginSlot.pluginHintsChanged(self, hints)
  851. #------------------------------------------------------------------
  852. def paintEvent(self, event):
  853. painter = QPainter(self)
  854. painter.setBrush(Qt.transparent)
  855. painter.setPen(QPen(QColor(20, 20, 20) if self.fBackgroundBlack else QColor(75, 86, 99), 1))
  856. painter.drawRect(0, 1, self.width()-1, 88-3)
  857. painter.setPen(QPen(QColor(45, 45, 45) if self.fBackgroundBlack else QColor(86, 99, 114), 1))
  858. painter.drawLine(0, 0, self.width(), 0)
  859. AbstractPluginSlot.paintEvent(self, event)
  860. # ------------------------------------------------------------------------------------------------------------
  861. class PluginSlot_Nekobi(AbstractPluginSlot):
  862. def __init__(self, parent, pluginId):
  863. AbstractPluginSlot.__init__(self, parent, pluginId)
  864. #self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget()
  865. #self.ui.setupUi(self)
  866. # -------------------------------------------------------------
  867. # Set-up GUI
  868. self.fPixmapCenter = QPixmap(":/bitmaps/background_nekobi.png")
  869. self.fPixmapLeft = QPixmap(":/bitmaps/background_nekobi_left.png")
  870. self.fPixmapLeftRect = QRectF(0, 0, self.fPixmapLeft.width(), self.fPixmapLeft.height())
  871. self.fPixmapRight = QPixmap(":/bitmaps/background_nekobi_right.png")
  872. self.fPixmapRightRect = QRectF(0, 0, self.fPixmapRight.width(), self.fPixmapRight.height())
  873. #self.setStyleSheet("""
  874. #PluginSlot_Nekobi#PluginWidget {
  875. #background-image: url(:/bitmaps/background_nekobi.png);
  876. #background-repeat: repeat-xy;
  877. #}
  878. #QLabel#label_name {
  879. #color: #BBB;
  880. #}
  881. #""")
  882. #------------------------------------------------------------------
  883. def getFixedHeight(self):
  884. return 108
  885. #------------------------------------------------------------------
  886. def paintEvent(self, event):
  887. painter = QPainter(self)
  888. # main bg (center)
  889. painter.drawTiledPixmap(0, 0, self.width(), self.height(), self.fPixmapCenter)
  890. # left side
  891. painter.drawPixmap(self.fPixmapLeftRect, self.fPixmapLeft, self.fPixmapLeftRect)
  892. # right side
  893. rightTarget = QRectF(self.fPixmapRightRect)
  894. rightTarget.moveLeft(self.width()-rightTarget.width())
  895. painter.drawPixmap(rightTarget, self.fPixmapRight, self.fPixmapRightRect)
  896. AbstractPluginSlot.paintEvent(self, event)
  897. # ------------------------------------------------------------------------------------------------------------
  898. class PluginSlot_ZitaRev(AbstractPluginSlot):
  899. def __init__(self, parent, pluginId):
  900. AbstractPluginSlot.__init__(self, parent, pluginId)
  901. self.ui = ui_carla_plugin_zita.Ui_PluginWidget()
  902. self.ui.setupUi(self)
  903. # -------------------------------------------------------------
  904. # Internal stuff
  905. audioCount = gCarla.host.get_audio_port_count_info(self.fPluginId) if gCarla.host is not None else {'ins': 2, 'outs': 2 }
  906. # -------------------------------------------------------------
  907. # Set-up GUI
  908. self.setMinimumWidth(640)
  909. self.setStyleSheet("""
  910. PluginSlot_ZitaRev#PluginWidget {
  911. background-color: #404040;
  912. border: 2px solid transparent;
  913. }
  914. QWidget#w_revsect {
  915. background-image: url(:/bitmaps/zita-rev/revsect.png);
  916. }
  917. QWidget#w_eq1sect {
  918. background-image: url(:/bitmaps/zita-rev/eq1sect.png);
  919. }
  920. QWidget#w_eq2sect {
  921. background-image: url(:/bitmaps/zita-rev/eq2sect.png);
  922. }
  923. QWidget#w_ambmixsect {
  924. background-image: url(:/bitmaps/zita-rev/%s.png);
  925. }
  926. QWidget#w_redzita {
  927. background-image: url(:/bitmaps/zita-rev/redzita.png);
  928. }
  929. """ % ("mixsect" if audioCount['outs'] == 2 else "ambsect"))
  930. # -------------------------------------------------------------
  931. # Set-up Knobs
  932. self.fKnobDelay = PixmapDial(self, 0)
  933. self.fKnobDelay.setPixmap(6)
  934. self.fKnobDelay.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  935. self.fKnobDelay.setMinimum(0.02)
  936. self.fKnobDelay.setMaximum(0.10)
  937. self.fKnobXover = PixmapDial(self, 1)
  938. self.fKnobXover.setPixmap(6)
  939. self.fKnobXover.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  940. self.fKnobXover.setMinimum(50.0)
  941. self.fKnobXover.setMaximum(1000.0)
  942. self.fKnobRtLow = PixmapDial(self, 2)
  943. self.fKnobRtLow.setPixmap(6)
  944. self.fKnobRtLow.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  945. self.fKnobRtLow.setMinimum(1.0)
  946. self.fKnobRtLow.setMaximum(8.0)
  947. self.fKnobRtMid = PixmapDial(self, 3)
  948. self.fKnobRtMid.setPixmap(6)
  949. self.fKnobRtMid.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  950. self.fKnobRtMid.setMinimum(1.0)
  951. self.fKnobRtMid.setMaximum(8.0)
  952. self.fKnobDamping = PixmapDial(self, 4)
  953. self.fKnobDamping.setPixmap(6)
  954. self.fKnobDamping.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  955. self.fKnobDamping.setMinimum(1500.0)
  956. self.fKnobDamping.setMaximum(24000.0)
  957. self.fKnobEq1Freq = PixmapDial(self, 5)
  958. self.fKnobEq1Freq.setPixmap(6)
  959. self.fKnobEq1Freq.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  960. self.fKnobEq1Freq.setMinimum(40.0)
  961. self.fKnobEq1Freq.setMaximum(10000.0)
  962. self.fKnobEq1Gain = PixmapDial(self, 6)
  963. self.fKnobEq1Gain.setPixmap(6)
  964. self.fKnobEq1Gain.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  965. self.fKnobEq1Gain.setMinimum(-20.0)
  966. self.fKnobEq1Gain.setMaximum(20.0)
  967. self.fKnobEq2Freq = PixmapDial(self, 7)
  968. self.fKnobEq2Freq.setPixmap(6)
  969. self.fKnobEq2Freq.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  970. self.fKnobEq2Freq.setMinimum(40.0)
  971. self.fKnobEq2Freq.setMaximum(10000.0)
  972. self.fKnobEq2Gain = PixmapDial(self, 8)
  973. self.fKnobEq2Gain.setPixmap(6)
  974. self.fKnobEq2Gain.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  975. self.fKnobEq2Gain.setMinimum(-20.0)
  976. self.fKnobEq2Gain.setMaximum(20.0)
  977. self.fKnobMix = PixmapDial(self, 9)
  978. self.fKnobMix.setPixmap(6)
  979. self.fKnobMix.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  980. self.fKnobMix.setMinimum(0.0)
  981. self.fKnobMix.setMaximum(1.0)
  982. self.fParameterList.append([0, self.fKnobDelay])
  983. self.fParameterList.append([1, self.fKnobXover])
  984. self.fParameterList.append([2, self.fKnobRtLow])
  985. self.fParameterList.append([3, self.fKnobRtMid])
  986. self.fParameterList.append([4, self.fKnobDamping])
  987. self.fParameterList.append([5, self.fKnobEq1Freq])
  988. self.fParameterList.append([6, self.fKnobEq1Gain])
  989. self.fParameterList.append([7, self.fKnobEq2Freq])
  990. self.fParameterList.append([8, self.fKnobEq2Gain])
  991. self.fParameterList.append([9, self.fKnobMix])
  992. # -------------------------------------------------------------
  993. self.ready()
  994. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  995. #------------------------------------------------------------------
  996. def getFixedHeight(self):
  997. return 79
  998. #------------------------------------------------------------------
  999. def paintEvent(self, event):
  1000. AbstractPluginSlot.paintEvent(self, event)
  1001. self.drawOutline()
  1002. def resizeEvent(self, event):
  1003. self.fKnobDelay.move(self.ui.w_revsect.x()+31, self.ui.w_revsect.y()+33)
  1004. self.fKnobXover.move(self.ui.w_revsect.x()+93, self.ui.w_revsect.y()+18)
  1005. self.fKnobRtLow.move(self.ui.w_revsect.x()+148, self.ui.w_revsect.y()+18)
  1006. self.fKnobRtMid.move(self.ui.w_revsect.x()+208, self.ui.w_revsect.y()+18)
  1007. self.fKnobDamping.move(self.ui.w_revsect.x()+268, self.ui.w_revsect.y()+18)
  1008. self.fKnobEq1Freq.move(self.ui.w_eq1sect.x()+20, self.ui.w_eq1sect.y()+33)
  1009. self.fKnobEq1Gain.move(self.ui.w_eq1sect.x()+69, self.ui.w_eq1sect.y()+18)
  1010. self.fKnobEq2Freq.move(self.ui.w_eq2sect.x()+20, self.ui.w_eq2sect.y()+33)
  1011. self.fKnobEq2Gain.move(self.ui.w_eq2sect.x()+69, self.ui.w_eq2sect.y()+18)
  1012. self.fKnobMix.move(self.ui.w_ambmixsect.x()+24, self.ui.w_ambmixsect.y()+33)
  1013. AbstractPluginSlot.resizeEvent(self, event)
  1014. # ------------------------------------------------------------------------------------------------------------
  1015. class PluginSlot_ZynFX(AbstractPluginSlot):
  1016. def __init__(self, parent, pluginId):
  1017. AbstractPluginSlot.__init__(self, parent, pluginId)
  1018. self.ui = ui_carla_plugin_zynfx.Ui_PluginWidget()
  1019. self.ui.setupUi(self)
  1020. # -------------------------------------------------------------
  1021. # Set-up GUI
  1022. self.setStyleSheet("""
  1023. PluginSlot_ZynFX#PluginWidget {
  1024. background-image: url(:/bitmaps/background_zynfx.png);
  1025. background-repeat: repeat-xy;
  1026. border: 2px;
  1027. }
  1028. QLabel#label_name, QLabel#label_presets {
  1029. color: #BBB;
  1030. }
  1031. """)
  1032. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  1033. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  1034. labelFont = self.ui.label_name.font()
  1035. labelFont.setBold(True)
  1036. labelFont.setPointSize(9)
  1037. self.ui.label_name.setFont(labelFont)
  1038. presetFont = self.ui.label_presets.font()
  1039. presetFont.setBold(True)
  1040. presetFont.setPointSize(8)
  1041. self.ui.label_presets.setFont(presetFont)
  1042. # -------------------------------------------------------------
  1043. # Set-up parameters
  1044. parameterCount = gCarla.host.get_parameter_count(self.fPluginId) if gCarla.host is not None else 0
  1045. index = 0
  1046. for i in range(parameterCount):
  1047. paramInfo = gCarla.host.get_parameter_info(self.fPluginId, i)
  1048. paramData = gCarla.host.get_parameter_data(self.fPluginId, i)
  1049. paramRanges = gCarla.host.get_parameter_ranges(self.fPluginId, i)
  1050. if paramData['type'] != PARAMETER_INPUT:
  1051. continue
  1052. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  1053. continue
  1054. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1055. continue
  1056. paramName = paramInfo['name']
  1057. # real zyn fx plugins
  1058. if self.fPluginInfo['label'] == "zynalienwah":
  1059. if i == 0: paramName = "Freq"
  1060. elif i == 1: paramName = "Rnd"
  1061. elif i == 2: paramName = "L type" # combobox
  1062. elif i == 3: paramName = "St.df"
  1063. elif i == 5: paramName = "Fb"
  1064. elif i == 7: paramName = "L/R"
  1065. elif self.fPluginInfo['label'] == "zynchorus":
  1066. if i == 0: paramName = "Freq"
  1067. elif i == 1: paramName = "Rnd"
  1068. elif i == 2: paramName = "L type" # combobox
  1069. elif i == 3: paramName = "St.df"
  1070. elif i == 6: paramName = "Fb"
  1071. elif i == 7: paramName = "L/R"
  1072. elif i == 8: paramName = "Flngr" # button
  1073. elif i == 9: paramName = "Subst" # button
  1074. elif self.fPluginInfo['label'] == "zyndistortion":
  1075. if i == 0: paramName = "LRc."
  1076. elif i == 4: paramName = "Neg." # button
  1077. elif i == 5: paramName = "LPF"
  1078. elif i == 6: paramName = "HPF"
  1079. elif i == 7: paramName = "St." # button
  1080. elif i == 8: paramName = "PF" # button
  1081. elif self.fPluginInfo['label'] == "zyndynamicfilter":
  1082. if i == 0: paramName = "Freq"
  1083. elif i == 1: paramName = "Rnd"
  1084. elif i == 2: paramName = "L type" # combobox
  1085. elif i == 3: paramName = "St.df"
  1086. elif i == 4: paramName = "LfoD"
  1087. elif i == 5: paramName = "A.S."
  1088. elif i == 6: paramName = "A.Inv." # button
  1089. elif i == 7: paramName = "A.M."
  1090. elif self.fPluginInfo['label'] == "zynecho":
  1091. if i == 1: paramName = "LRdl."
  1092. elif i == 2: paramName = "LRc."
  1093. elif i == 3: paramName = "Fb."
  1094. elif i == 4: paramName = "Damp"
  1095. elif self.fPluginInfo['label'] == "zynphaser":
  1096. if i == 0: paramName = "Freq"
  1097. elif i == 1: paramName = "Rnd"
  1098. elif i == 2: paramName = "L type" # combobox
  1099. elif i == 3: paramName = "St.df"
  1100. elif i == 5: paramName = "Fb"
  1101. elif i == 7: paramName = "L/R"
  1102. elif i == 8: paramName = "Subst" # button
  1103. elif i == 9: paramName = "Phase"
  1104. elif i == 11: paramName = "Dist"
  1105. elif self.fPluginInfo['label'] == "zynreverb":
  1106. if i == 2: paramName = "I.delfb"
  1107. elif i == 5: paramName = "LPF"
  1108. elif i == 6: paramName = "HPF"
  1109. elif i == 9: paramName = "R.S."
  1110. elif i == 10: paramName = "I.del"
  1111. else:
  1112. paramName = getParameterShortName(paramInfo['name'])
  1113. widget = PixmapDial(self, i)
  1114. widget.setPixmap(5)
  1115. widget.setLabel(paramName)
  1116. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1117. widget.setMinimum(paramRanges['min'])
  1118. widget.setMaximum(paramRanges['max'])
  1119. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1120. widget.setEnabled(False)
  1121. self.ui.w_knobs.layout().insertWidget(index, widget)
  1122. index += 1
  1123. self.fParameterList.append([i, widget])
  1124. self.ui.dial_drywet.setIndex(PARAMETER_DRYWET)
  1125. self.ui.dial_drywet.setPixmap(5)
  1126. self.ui.dial_drywet.setLabel("Wet")
  1127. self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1128. self.ui.dial_drywet.setMinimum(0.0)
  1129. self.ui.dial_drywet.setMaximum(1.0)
  1130. self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET)
  1131. self.ui.dial_vol.setIndex(PARAMETER_VOLUME)
  1132. self.ui.dial_vol.setPixmap(5)
  1133. self.ui.dial_vol.setLabel("Vol")
  1134. self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1135. self.ui.dial_vol.setMinimum(0.0)
  1136. self.ui.dial_vol.setMaximum(1.27)
  1137. self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME)
  1138. self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet])
  1139. self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol])
  1140. # -------------------------------------------------------------
  1141. # Set-up MIDI programs
  1142. midiProgramCount = gCarla.host.get_midi_program_count(self.fPluginId) if gCarla.host is not None else 0
  1143. if midiProgramCount > 0:
  1144. self.ui.cb_presets.setEnabled(True)
  1145. self.ui.label_presets.setEnabled(True)
  1146. for i in range(midiProgramCount):
  1147. mpData = gCarla.host.get_midi_program_data(self.fPluginId, i)
  1148. mpName = mpData['name']
  1149. self.ui.cb_presets.addItem(mpName)
  1150. self.fCurrentMidiProgram = gCarla.host.get_current_midi_program_index(self.fPluginId)
  1151. self.ui.cb_presets.setCurrentIndex(self.fCurrentMidiProgram)
  1152. else:
  1153. self.fCurrentMidiProgram = -1
  1154. self.ui.cb_presets.setEnabled(False)
  1155. self.ui.cb_presets.setVisible(False)
  1156. self.ui.label_presets.setEnabled(False)
  1157. self.ui.label_presets.setVisible(False)
  1158. # -------------------------------------------------------------
  1159. self.b_enable = self.ui.b_enable
  1160. self.b_edit = self.ui.b_edit
  1161. self.cb_presets = self.ui.cb_presets
  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.ready()
  1170. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1171. self.ui.cb_presets.currentIndexChanged.connect(self.slot_midiProgramChanged)
  1172. #------------------------------------------------------------------
  1173. def getFixedHeight(self):
  1174. return 74
  1175. #------------------------------------------------------------------
  1176. def paintEvent(self, event):
  1177. painter = QPainter(self)
  1178. painter.setBrush(Qt.transparent)
  1179. painter.setPen(QPen(QColor(60, 60, 60), 1))
  1180. painter.drawRect(0, 1, self.width()-1, 74-3)
  1181. painter.setPen(QPen(QColor(94, 94, 94), 1))
  1182. painter.drawLine(0, 0, self.width(), 0)
  1183. AbstractPluginSlot.paintEvent(self, event)
  1184. # ------------------------------------------------------------------------------------------------------------
  1185. def createPluginSlot(parent, pluginId):
  1186. if not gCarla.useCustomSkins:
  1187. return PluginSlot_Default(parent, pluginId)
  1188. pluginInfo = gCarla.host.get_plugin_info(pluginId)
  1189. pluginName = gCarla.host.get_real_plugin_name(pluginId)
  1190. pluginLabel = pluginInfo['label']
  1191. pluginMaker = pluginInfo['maker']
  1192. uniqueId = pluginInfo['uniqueId']
  1193. #pluginIcon = pluginInfo['iconName']
  1194. if pluginInfo['type'] == PLUGIN_INTERNAL:
  1195. if pluginLabel.startswith("zyn") and pluginInfo['category'] != PLUGIN_CATEGORY_SYNTH:
  1196. return PluginSlot_ZynFX(parent, pluginId)
  1197. elif pluginInfo['type'] == PLUGIN_LADSPA:
  1198. if (pluginLabel == "zita-reverb" and uniqueId == 3701) or (pluginLabel == "zita-reverb-amb" and uniqueId == 3702):
  1199. return PluginSlot_ZitaRev(parent, pluginId)
  1200. if pluginLabel.startswith("Zyn") and pluginMaker.startswith("Josep Andreu"):
  1201. return PluginSlot_ZynFX(parent, pluginId)
  1202. if pluginName.split(" ", 1)[0].lower() == "calf":
  1203. return PluginSlot_Calf(parent, pluginId)
  1204. #if pluginName.lower() == "nekobi":
  1205. #return PluginSlot_Nekobi(parent, pluginId)
  1206. return PluginSlot_BasicFX(parent, pluginId)
  1207. # ------------------------------------------------------------------------------------------------------------
  1208. # Main Testing
  1209. if __name__ == '__main__':
  1210. from carla_app import CarlaApplication
  1211. import resources_rc
  1212. app = CarlaApplication("Carla-Skins")
  1213. #gui = PluginSlot_BasicFX(None, 0)
  1214. #gui = PluginSlot_Calf(None, 0)
  1215. #gui = PluginSlot_Default(None, 0)
  1216. #gui = PluginSlot_ZitaRev(None, 0)
  1217. gui = PluginSlot_ZynFX(None, 0)
  1218. gui.setSelected(True)
  1219. gui.show()
  1220. app.exec_()