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.

1492 lines
54KB

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