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.

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