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.

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