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.

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