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.

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