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.

1425 lines
52KB

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