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.

1610 lines
58KB

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