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.

2006 lines
73KB

  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, QFontDatabase, QPen, QPixmap
  25. from PyQt5.QtWidgets import QFrame, QPushButton
  26. else:
  27. from PyQt4.QtCore import Qt, QRectF
  28. from PyQt4.QtGui import QFont, QFontDatabase, 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_sf2
  35. import ui_carla_plugin_zita
  36. import ui_carla_plugin_zynfx
  37. from carla_widgets import *
  38. from digitalpeakmeter import DigitalPeakMeter
  39. from pixmapdial import PixmapDial
  40. # ------------------------------------------------------------------------------------------------------------
  41. # Try to "shortify" a parameter name
  42. def getParameterShortName(paramName):
  43. paramName = paramName.split("/",1)[0].split(" (",1)[0].split(" [",1)[0].strip()
  44. paramLow = paramName.lower()
  45. if paramLow.startswith("compressor "):
  46. paramName = paramName.replace("ompressor ", ".", 1)
  47. paramLow = paramName.lower()
  48. # Cut generic names
  49. if "attack" in paramLow:
  50. paramName = paramName.replace("ttack", "tk")
  51. elif "bandwidth" in paramLow:
  52. paramName = paramName.replace("andwidth", "w")
  53. elif "damping" in paramLow:
  54. paramName = paramName.replace("amping", "amp")
  55. elif "distortion" in paramLow:
  56. paramName = paramName.replace("istortion", "ist")
  57. elif "feedback" in paramLow:
  58. paramName = paramName.replace("eedback", "b")
  59. elif "frequency" in paramLow:
  60. paramName = paramName.replace("requency", "req")
  61. elif "makeup" in paramLow:
  62. paramName = paramName.replace("akeup", "kUp" if "Make" in paramName else "kup")
  63. elif "output" in paramLow:
  64. paramName = paramName.replace("utput", "ut")
  65. elif "random" in paramLow:
  66. paramName = paramName.replace("andom", "nd")
  67. elif "threshold" in paramLow:
  68. paramName = paramName.replace("hreshold", "hres")
  69. # Cut useless prefix
  70. elif paramLow.startswith("room "):
  71. paramName = paramName.split(" ",1)[1]
  72. # Cut useless suffix
  73. elif paramLow.endswith(" level"):
  74. paramName = paramName.rsplit(" ",1)[0]
  75. elif paramLow.endswith(" time"):
  76. paramName = paramName.rsplit(" ",1)[0]
  77. if len(paramName) > 7:
  78. paramName = paramName[:7]
  79. return paramName.strip()
  80. # ------------------------------------------------------------------------------------------------------------
  81. # Abstract plugin slot
  82. class AbstractPluginSlot(QFrame, PluginEditParentMeta):
  83. #class AbstractPluginSlot(QFrame, PluginEditParentMeta, metaclass=PyQtMetaClass):
  84. def __init__(self, parent, host, pluginId):
  85. QFrame.__init__(self, parent)
  86. self.host = host
  87. if False:
  88. # kdevelop likes this :)
  89. host = CarlaHostMeta()
  90. self.host = host
  91. # -------------------------------------------------------------
  92. # Get plugin info
  93. self.fPluginId = pluginId
  94. self.fPluginInfo = host.get_plugin_info(self.fPluginId)
  95. #if not gCarla.isLocal:
  96. #self.fPluginInfo['hints'] &= ~PLUGIN_HAS_CUSTOM_UI
  97. # -------------------------------------------------------------
  98. # Internal stuff
  99. self.fIsActive = bool(host.get_internal_parameter_value(self.fPluginId, PARAMETER_ACTIVE) >= 0.5)
  100. self.fIsSelected = False
  101. self.fLastGreenLedState = False
  102. self.fLastBlueLedState = False
  103. self.fParameterIconTimer = ICON_STATE_NULL
  104. self.fParameterList = [] # index, widget
  105. audioCountInfo = host.get_audio_port_count_info(self.fPluginId)
  106. self.fPeaksInputCount = int(audioCountInfo['ins'])
  107. self.fPeaksOutputCount = int(audioCountInfo['outs'])
  108. if self.fPeaksInputCount > 2:
  109. self.fPeaksInputCount = 2
  110. if self.fPeaksOutputCount > 2:
  111. self.fPeaksOutputCount = 2
  112. # used during testing
  113. self.fIdleTimerId = 0
  114. # -------------------------------------------------------------
  115. # Set-up GUI
  116. self.fEditDialog = PluginEdit(self, host, self.fPluginId)
  117. # -------------------------------------------------------------
  118. # Set-up common widgets (as none)
  119. self.b_enable = None
  120. self.b_gui = None
  121. self.b_edit = None
  122. self.b_remove = None
  123. self.cb_presets = None
  124. self.label_name = None
  125. self.label_type = None
  126. self.led_control = None
  127. self.led_midi = None
  128. self.led_audio_in = None
  129. self.led_audio_out = None
  130. self.peak_in = None
  131. self.peak_out = None
  132. # -------------------------------------------------------------
  133. # Set-up connections
  134. host.PluginRenamedCallback.connect(self.slot_handlePluginRenamedCallback)
  135. host.PluginUnavailableCallback.connect(self.slot_handlePluginUnavailableCallback)
  136. host.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback)
  137. host.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback)
  138. host.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback)
  139. host.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback)
  140. host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback)
  141. host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback)
  142. host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback)
  143. host.UiStateChangedCallback.connect(self.slot_handleUiStateChangedCallback)
  144. # -----------------------------------------------------------------
  145. @pyqtSlot(int, str)
  146. def slot_handlePluginRenamedCallback(self, pluginId, newName):
  147. if self.fPluginId == pluginId:
  148. self.setName(newName)
  149. @pyqtSlot(int, str)
  150. def slot_handlePluginUnavailableCallback(self, pluginId, errorMsg):
  151. if self.fPluginId == pluginId:
  152. pass
  153. @pyqtSlot(int, int, float)
  154. def slot_handleParameterValueChangedCallback(self, pluginId, index, value):
  155. if self.fPluginId == pluginId:
  156. self.setParameterValue(index, value, True)
  157. @pyqtSlot(int, int, float)
  158. def slot_handleParameterDefaultChangedCallback(self, pluginId, index, value):
  159. if self.fPluginId == pluginId:
  160. self.setParameterDefault(index, value)
  161. @pyqtSlot(int, int, int)
  162. def slot_handleParameterMidiCcChangedCallback(self, pluginId, index, cc):
  163. if self.fPluginId == pluginId:
  164. self.setParameterMidiControl(index, cc)
  165. @pyqtSlot(int, int, int)
  166. def slot_handleParameterMidiChannelChangedCallback(self, pluginId, index, channel):
  167. if self.fPluginId == pluginId:
  168. self.setParameterMidiChannel(index, channel)
  169. @pyqtSlot(int, int)
  170. def slot_handleProgramChangedCallback(self, pluginId, index):
  171. if self.fPluginId == pluginId:
  172. self.setProgram(index, True)
  173. @pyqtSlot(int, int)
  174. def slot_handleMidiProgramChangedCallback(self, pluginId, index):
  175. if self.fPluginId == pluginId:
  176. self.setMidiProgram(index, True)
  177. @pyqtSlot(int, int, bool)
  178. def slot_handleOptionChangedCallback(self, pluginId, option, yesNo):
  179. if self.fPluginId == pluginId:
  180. self.setOption(option, yesNo)
  181. @pyqtSlot(int, int)
  182. def slot_handleUiStateChangedCallback(self, pluginId, state):
  183. if self.fPluginId == pluginId:
  184. self.customUiStateChanged(state)
  185. #------------------------------------------------------------------
  186. def ready(self):
  187. if self.b_enable is not None:
  188. self.b_enable.setChecked(self.fIsActive)
  189. self.b_enable.clicked.connect(self.slot_enableClicked)
  190. if self.b_gui is not None:
  191. self.b_gui.clicked.connect(self.slot_showCustomUi)
  192. self.b_gui.setEnabled(bool(self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI))
  193. if self.b_edit is None:
  194. # Edit dialog *must* be available
  195. self.b_edit = QPushButton(self)
  196. self.b_edit.setCheckable(True)
  197. self.b_edit.hide()
  198. self.b_edit.clicked.connect(self.slot_showEditDialog)
  199. if self.b_remove is not None:
  200. self.b_remove.clicked.connect(self.slot_removePlugin)
  201. if self.label_name is not None:
  202. self.label_name.setText(self.fPluginInfo['name'])
  203. if self.label_type is not None:
  204. self.label_type.setText(getPluginTypeAsString(self.fPluginInfo['type']))
  205. if self.led_control is not None:
  206. self.led_control.setColor(self.led_control.YELLOW)
  207. self.led_control.setEnabled(False)
  208. if self.led_midi is not None:
  209. self.led_midi.setColor(self.led_midi.RED)
  210. self.led_midi.setEnabled(False)
  211. if self.led_audio_in is not None:
  212. self.led_audio_in.setColor(self.led_audio_in.GREEN)
  213. self.led_audio_in.setEnabled(False)
  214. if self.led_audio_out is not None:
  215. self.led_audio_out.setColor(self.led_audio_out.BLUE)
  216. self.led_audio_out.setEnabled(False)
  217. if self.peak_in is not None:
  218. self.peak_in.setColor(DigitalPeakMeter.GREEN)
  219. self.peak_in.setChannels(self.fPeaksInputCount)
  220. self.peak_in.setOrientation(DigitalPeakMeter.HORIZONTAL)
  221. if self.fPeaksInputCount == 0:
  222. self.peak_in.hide()
  223. if self.peak_out is not None:
  224. self.peak_out.setColor(DigitalPeakMeter.BLUE)
  225. self.peak_out.setChannels(self.fPeaksOutputCount)
  226. self.peak_out.setOrientation(DigitalPeakMeter.HORIZONTAL)
  227. if self.fPeaksOutputCount == 0:
  228. self.peak_out.hide()
  229. for paramIndex, paramWidget in self.fParameterList:
  230. paramWidget.setContextMenuPolicy(Qt.CustomContextMenu)
  231. paramWidget.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  232. paramWidget.realValueChanged.connect(self.slot_parameterValueChanged)
  233. paramWidget.setValue(self.host.get_internal_parameter_value(self.fPluginId, paramIndex))
  234. self.setWindowTitle(self.fPluginInfo['name'])
  235. #------------------------------------------------------------------
  236. def getFixedHeight(self):
  237. return 32
  238. def getHints(self):
  239. return self.fPluginInfo['hints']
  240. def getPluginId(self):
  241. return self.fPluginId
  242. #------------------------------------------------------------------
  243. def setPluginId(self, idx):
  244. self.fPluginId = idx
  245. self.fEditDialog.setPluginId(idx)
  246. def setName(self, name):
  247. self.fEditDialog.setName(name)
  248. if self.label_name is not None:
  249. self.label_name.setText(name)
  250. def setSelected(self, yesNo):
  251. if self.fIsSelected == yesNo:
  252. return
  253. self.fIsSelected = yesNo
  254. self.update()
  255. #------------------------------------------------------------------
  256. def setActive(self, active, sendCallback=False, sendHost=True):
  257. self.fIsActive = active
  258. if sendCallback:
  259. self.fParameterIconTimer = ICON_STATE_ON
  260. self.activeChanged(active)
  261. if sendHost:
  262. self.host.set_active(self.fPluginId, active)
  263. if active:
  264. self.fEditDialog.clearNotes()
  265. self.midiActivityChanged(False)
  266. # called from rack, checks if param is possible first
  267. def setInternalParameter(self, parameterId, value):
  268. if parameterId <= PARAMETER_MAX or parameterId >= PARAMETER_NULL:
  269. return
  270. elif parameterId == PARAMETER_ACTIVE:
  271. return self.setActive(bool(value), True, True)
  272. elif parameterId == PARAMETER_DRYWET:
  273. if (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) == 0: return
  274. self.host.set_drywet(self.fPluginId, value)
  275. elif parameterId == PARAMETER_VOLUME:
  276. if (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) == 0: return
  277. self.host.set_volume(self.fPluginId, value)
  278. elif parameterId == PARAMETER_BALANCE_LEFT:
  279. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  280. self.host.set_balance_left(self.fPluginId, value)
  281. elif parameterId == PARAMETER_BALANCE_RIGHT:
  282. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  283. self.host.set_balance_right(self.fPluginId, value)
  284. elif parameterId == PARAMETER_PANNING:
  285. if (self.fPluginInfo['hints'] & PLUGIN_CAN_PANNING) == 0: return
  286. self.host.set_panning(self.fPluginId, value)
  287. elif parameterId == PARAMETER_CTRL_CHANNEL:
  288. self.host.set_ctrl_channel(self.fPluginId, value)
  289. self.fEditDialog.setParameterValue(parameterId, value)
  290. #------------------------------------------------------------------
  291. def setParameterValue(self, parameterId, value, sendCallback):
  292. if parameterId == PARAMETER_ACTIVE:
  293. return self.setActive(bool(value), True, False)
  294. self.fEditDialog.setParameterValue(parameterId, value)
  295. if sendCallback:
  296. self.fParameterIconTimer = ICON_STATE_ON
  297. self.editDialogParameterValueChanged(self.fPluginId, parameterId, value)
  298. def setParameterDefault(self, parameterId, value):
  299. self.fEditDialog.setParameterDefault(parameterId, value)
  300. def setParameterMidiControl(self, parameterId, control):
  301. self.fEditDialog.setParameterMidiControl(parameterId, control)
  302. def setParameterMidiChannel(self, parameterId, channel):
  303. self.fEditDialog.setParameterMidiChannel(parameterId, channel)
  304. #------------------------------------------------------------------
  305. def setProgram(self, index, sendCallback):
  306. self.fEditDialog.setProgram(index)
  307. if sendCallback:
  308. self.fParameterIconTimer = ICON_STATE_ON
  309. self.editDialogProgramChanged(self.fPluginId, index)
  310. self.updateParameterValues()
  311. def setMidiProgram(self, index, sendCallback):
  312. self.fEditDialog.setMidiProgram(index)
  313. if sendCallback:
  314. self.fParameterIconTimer = ICON_STATE_ON
  315. self.editDialogMidiProgramChanged(self.fPluginId, index)
  316. self.updateParameterValues()
  317. #------------------------------------------------------------------
  318. def setOption(self, option, yesNo):
  319. self.fEditDialog.setOption(option, yesNo)
  320. #------------------------------------------------------------------
  321. def activeChanged(self, onOff):
  322. self.fIsActive = onOff
  323. if self.b_enable is None:
  324. return
  325. self.b_enable.blockSignals(True)
  326. self.b_enable.setChecked(onOff)
  327. self.b_enable.blockSignals(False)
  328. def customUiStateChanged(self, state):
  329. if self.b_gui is None:
  330. return
  331. self.b_gui.blockSignals(True)
  332. if state == 0:
  333. self.b_gui.setChecked(False)
  334. self.b_gui.setEnabled(True)
  335. elif state == 1:
  336. self.b_gui.setChecked(True)
  337. self.b_gui.setEnabled(True)
  338. elif state == -1:
  339. self.b_gui.setChecked(False)
  340. self.b_gui.setEnabled(False)
  341. self.b_gui.blockSignals(False)
  342. def parameterActivityChanged(self, onOff):
  343. if self.led_control is None:
  344. return
  345. self.led_control.setChecked(onOff)
  346. def midiActivityChanged(self, onOff):
  347. if self.led_midi is None:
  348. return
  349. self.led_midi.setChecked(onOff)
  350. def optionChanged(self, option, yesNo):
  351. pass
  352. # -----------------------------------------------------------------
  353. # PluginEdit callbacks
  354. def editDialogVisibilityChanged(self, pluginId, visible):
  355. if self.b_edit is None:
  356. return
  357. self.b_edit.blockSignals(True)
  358. self.b_edit.setChecked(visible)
  359. self.b_edit.blockSignals(False)
  360. def editDialogPluginHintsChanged(self, pluginId, hints):
  361. self.fPluginInfo['hints'] = hints
  362. for paramIndex, paramWidget in self.fParameterList:
  363. if paramIndex == PARAMETER_DRYWET:
  364. paramWidget.setVisible(hints & PLUGIN_CAN_DRYWET)
  365. elif paramIndex == PARAMETER_VOLUME:
  366. paramWidget.setVisible(hints & PLUGIN_CAN_VOLUME)
  367. if self.b_gui is not None:
  368. self.b_gui.setEnabled(bool(hints & PLUGIN_HAS_CUSTOM_UI))
  369. def editDialogParameterValueChanged(self, pluginId, parameterId, value):
  370. for paramIndex, paramWidget in self.fParameterList:
  371. if paramIndex != parameterId:
  372. continue
  373. paramWidget.blockSignals(True)
  374. paramWidget.setValue(value)
  375. paramWidget.blockSignals(False)
  376. break
  377. def editDialogProgramChanged(self, pluginId, index):
  378. if self.cb_presets is None:
  379. return
  380. self.cb_presets.blockSignals(True)
  381. self.cb_presets.setCurrentIndex(index)
  382. self.cb_presets.blockSignals(False)
  383. # FIXME
  384. self.updateParameterValues()
  385. def editDialogMidiProgramChanged(self, pluginId, index):
  386. if self.cb_presets is None:
  387. return
  388. self.cb_presets.blockSignals(True)
  389. self.cb_presets.setCurrentIndex(index)
  390. self.cb_presets.blockSignals(False)
  391. # FIXME
  392. self.updateParameterValues()
  393. def editDialogNotePressed(self, pluginId, note):
  394. pass
  395. def editDialogNoteReleased(self, pluginId, note):
  396. pass
  397. def editDialogMidiActivityChanged(self, pluginId, onOff):
  398. self.midiActivityChanged(onOff)
  399. #------------------------------------------------------------------
  400. def idleFast(self):
  401. # Input peaks
  402. if self.fPeaksInputCount > 0:
  403. if self.fPeaksInputCount > 1:
  404. peak1 = self.host.get_input_peak_value(self.fPluginId, True)
  405. peak2 = self.host.get_input_peak_value(self.fPluginId, False)
  406. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  407. if self.peak_in is not None:
  408. self.peak_in.displayMeter(1, peak1)
  409. self.peak_in.displayMeter(2, peak2)
  410. else:
  411. peak = self.host.get_input_peak_value(self.fPluginId, True)
  412. ledState = bool(peak != 0.0)
  413. if self.peak_in is not None:
  414. self.peak_in.displayMeter(1, peak)
  415. if self.fLastGreenLedState != ledState and self.led_audio_in is not None:
  416. self.fLastGreenLedState = ledState
  417. self.led_audio_in.setChecked(ledState)
  418. # Output peaks
  419. if self.fPeaksOutputCount > 0:
  420. if self.fPeaksOutputCount > 1:
  421. peak1 = self.host.get_output_peak_value(self.fPluginId, True)
  422. peak2 = self.host.get_output_peak_value(self.fPluginId, False)
  423. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  424. if self.peak_out is not None:
  425. self.peak_out.displayMeter(1, peak1)
  426. self.peak_out.displayMeter(2, peak2)
  427. else:
  428. peak = self.host.get_output_peak_value(self.fPluginId, True)
  429. ledState = bool(peak != 0.0)
  430. if self.peak_out is not None:
  431. self.peak_out.displayMeter(1, peak)
  432. if self.fLastBlueLedState != ledState and self.led_audio_out is not None:
  433. self.fLastBlueLedState = ledState
  434. self.led_audio_out.setChecked(ledState)
  435. def idleSlow(self):
  436. if self.fParameterIconTimer == ICON_STATE_ON:
  437. self.parameterActivityChanged(True)
  438. self.fParameterIconTimer = ICON_STATE_WAIT
  439. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  440. self.fParameterIconTimer = ICON_STATE_OFF
  441. elif self.fParameterIconTimer == ICON_STATE_OFF:
  442. self.parameterActivityChanged(False)
  443. self.fParameterIconTimer = ICON_STATE_NULL
  444. self.fEditDialog.idleSlow()
  445. #------------------------------------------------------------------
  446. def drawOutline(self):
  447. painter = QPainter(self)
  448. if self.fIsSelected:
  449. painter.setPen(QPen(Qt.cyan, 4))
  450. painter.setBrush(Qt.transparent)
  451. painter.drawRect(0, 0, self.width(), self.height())
  452. else:
  453. painter.setPen(QPen(Qt.black, 1))
  454. painter.setBrush(Qt.black)
  455. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  456. def showDefaultCustomMenu(self, isEnabled, bEdit = None, bGui = None):
  457. menu = QMenu(self)
  458. actActive = menu.addAction(self.tr("Disable") if isEnabled else self.tr("Enable"))
  459. menu.addSeparator()
  460. actReset = menu.addAction(self.tr("Reset parameters"))
  461. actRandom = menu.addAction(self.tr("Randomize parameters"))
  462. menu.addSeparator()
  463. if bEdit is not None:
  464. actEdit = menu.addAction(self.tr("Edit"))
  465. actEdit.setCheckable(True)
  466. actEdit.setChecked(bEdit.isChecked())
  467. else:
  468. actEdit = None
  469. if bGui is not None:
  470. actGui = menu.addAction(self.tr("Show Custom UI"))
  471. actGui.setCheckable(True)
  472. actGui.setChecked(bGui.isChecked())
  473. actGui.setEnabled(bGui.isEnabled())
  474. else:
  475. actGui = None
  476. menu.addSeparator()
  477. actClone = menu.addAction(self.tr("Clone"))
  478. actReplace = menu.addAction(self.tr("Replace..."))
  479. actRename = menu.addAction(self.tr("Rename..."))
  480. actRemove = menu.addAction(self.tr("Remove"))
  481. if self.fIdleTimerId != 0:
  482. actRemove.setVisible(False)
  483. actSel = menu.exec_(QCursor.pos())
  484. if not actSel:
  485. return
  486. if actSel == actActive:
  487. self.setActive(not isEnabled, True, True)
  488. elif actSel == actReset:
  489. self.host.reset_parameters(self.fPluginId)
  490. elif actSel == actRandom:
  491. self.host.randomize_parameters(self.fPluginId)
  492. elif actSel == actGui:
  493. bGui.click()
  494. elif actSel == actEdit:
  495. bEdit.click()
  496. elif actSel == actClone:
  497. if not self.host.clone_plugin(self.fPluginId):
  498. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  499. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  500. elif actSel == actRename:
  501. oldName = self.fPluginInfo['name']
  502. newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName)
  503. if not (newNameTry[1] and newNameTry[0] and oldName != newNameTry[0]):
  504. return
  505. newName = newNameTry[0]
  506. if self.host.rename_plugin(self.fPluginId, newName):
  507. self.setName(newName)
  508. else:
  509. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  510. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  511. elif actSel == actReplace:
  512. gCarla.gui.slot_pluginAdd(self.fPluginId)
  513. elif actSel == actRemove:
  514. if not self.host.remove_plugin(self.fPluginId):
  515. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  516. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  517. def updateParameterValues(self):
  518. for paramIndex, paramWidget in self.fParameterList:
  519. if paramIndex < 0:
  520. continue
  521. paramWidget.blockSignals(True)
  522. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramIndex))
  523. paramWidget.blockSignals(False)
  524. #------------------------------------------------------------------
  525. @pyqtSlot(bool)
  526. def slot_enableClicked(self, yesNo):
  527. self.setActive(yesNo, False, True)
  528. @pyqtSlot()
  529. def slot_showDefaultCustomMenu(self):
  530. self.showDefaultCustomMenu(self.fIsActive, self.b_edit, self.b_gui)
  531. @pyqtSlot()
  532. def slot_knobCustomMenu(self):
  533. sender = self.sender()
  534. index = sender.fIndex
  535. minimum = sender.fMinimum
  536. maximum = sender.fMaximum
  537. current = sender.fRealValue
  538. label = sender.fLabel
  539. if index in (PARAMETER_DRYWET, PARAMETER_VOLUME):
  540. default = 1.0
  541. resetText = self.tr("Reset (%i%%)" % int(default*100.0))
  542. minimText = self.tr("Set to Minimum (%i%%)" % int(minimum*100.0))
  543. maximText = self.tr("Set to Maximum (%i%%)" % int(maximum*100.0))
  544. else:
  545. default = self.host.get_default_parameter_value(self.fPluginId, index)
  546. resetText = self.tr("Reset (%f)" % default)
  547. minimText = self.tr("Set to Minimum (%f)" % minimum)
  548. maximText = self.tr("Set to Maximum (%f)" % maximum)
  549. menu = QMenu(self)
  550. actReset = menu.addAction(resetText)
  551. menu.addSeparator()
  552. actMinimum = menu.addAction(minimText)
  553. actMaximum = menu.addAction(maximText)
  554. menu.addSeparator()
  555. actSet = menu.addAction(self.tr("Set value..."))
  556. actSelected = menu.exec_(QCursor.pos())
  557. if actSelected == actSet:
  558. valueTry = QInputDialog.getDouble(self, self.tr("Set value"), label, current, minimum, maximum, 3) # FIXME - 3 decimals
  559. if valueTry[1]:
  560. value = valueTry[0] * 10
  561. else:
  562. return
  563. elif actSelected == actMinimum:
  564. value = minimum
  565. elif actSelected == actMaximum:
  566. value = maximum
  567. elif actSelected == actReset:
  568. value = default
  569. else:
  570. return
  571. self.sender().setValue(value)
  572. #------------------------------------------------------------------
  573. @pyqtSlot(bool)
  574. def slot_showCustomUi(self, show):
  575. self.host.show_custom_ui(self.fPluginId, show)
  576. @pyqtSlot(bool)
  577. def slot_showEditDialog(self, show):
  578. self.fEditDialog.setVisible(show)
  579. @pyqtSlot()
  580. def slot_removePlugin(self):
  581. self.host.remove_plugin(self.fPluginId)
  582. #------------------------------------------------------------------
  583. @pyqtSlot(int)
  584. def slot_parameterValueChanged(self, value):
  585. index = self.sender().getIndex()
  586. if index < 0:
  587. self.setInternalParameter(index, value)
  588. else:
  589. self.host.set_parameter_value(self.fPluginId, index, value)
  590. self.setParameterValue(index, value, False)
  591. @pyqtSlot(int)
  592. def slot_programChanged(self, index):
  593. self.host.set_program(self.fPluginId, index)
  594. self.setProgram(index, False)
  595. @pyqtSlot(int)
  596. def slot_midiProgramChanged(self, index):
  597. self.host.set_midi_program(self.fPluginId, index)
  598. self.setMidiProgram(index, False)
  599. #------------------------------------------------------------------
  600. def testTimer(self):
  601. self.fIdleTimerId = self.startTimer(25)
  602. #------------------------------------------------------------------
  603. def closeEvent(self, event):
  604. if self.fIdleTimerId != 0:
  605. self.killTimer(self.fIdleTimerId)
  606. self.fIdleTimerId = 0
  607. self.host.engine_close()
  608. QFrame.closeEvent(self, event)
  609. def timerEvent(self, event):
  610. if event.timerId() == self.fIdleTimerId:
  611. self.host.engine_idle()
  612. self.idleFast()
  613. self.idleSlow()
  614. QFrame.timerEvent(self, event)
  615. def paintEvent(self, event):
  616. self.drawOutline()
  617. QFrame.paintEvent(self, event)
  618. # ------------------------------------------------------------------------------------------------------------
  619. class PluginSlot_Default(AbstractPluginSlot):
  620. def __init__(self, parent, host, pluginId):
  621. AbstractPluginSlot.__init__(self, parent, host, pluginId)
  622. self.ui = ui_carla_plugin_default.Ui_PluginWidget()
  623. self.ui.setupUi(self)
  624. # -------------------------------------------------------------
  625. # Internal stuff
  626. self.fColorTop = QColor(60, 60, 60)
  627. self.fColorBottom = QColor(47, 47, 47)
  628. self.fColorSeprtr = QColor(70, 70, 70)
  629. # -------------------------------------------------------------
  630. # Set-up GUI
  631. self.setStyleSheet("""
  632. QLabel#label_name {
  633. color: #BBB;
  634. }
  635. """)
  636. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  637. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  638. if self.fPluginInfo['iconName'] == "distrho":
  639. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  640. elif self.fPluginInfo['iconName'] == "file":
  641. self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  642. else:
  643. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  644. # -------------------------------------------------------------
  645. self.b_enable = self.ui.b_enable
  646. self.b_gui = self.ui.b_gui
  647. self.b_edit = self.ui.b_edit
  648. self.label_name = self.ui.label_name
  649. self.led_control = self.ui.led_control
  650. self.led_midi = self.ui.led_midi
  651. self.led_audio_in = self.ui.led_audio_in
  652. self.led_audio_out = self.ui.led_audio_out
  653. self.peak_in = self.ui.peak_in
  654. self.peak_out = self.ui.peak_out
  655. self.ready()
  656. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  657. #------------------------------------------------------------------
  658. def getFixedHeight(self):
  659. return 36
  660. #------------------------------------------------------------------
  661. def paintEvent(self, event):
  662. painter = QPainter(self)
  663. painter.save()
  664. areaX = self.ui.area_right.x()+7
  665. width = self.width()
  666. height = self.height()
  667. painter.setPen(QPen(QColor(17, 17, 17), 1))
  668. painter.setBrush(QColor(17, 17, 17))
  669. painter.drawRect(0, 0, width, height)
  670. painter.setPen(self.fColorSeprtr.lighter(110))
  671. painter.setBrush(self.fColorBottom)
  672. painter.setRenderHint(QPainter.Antialiasing, True)
  673. # name -> leds arc
  674. path = QPainterPath()
  675. path.moveTo(areaX-20, height-4)
  676. path.cubicTo(areaX, height-5, areaX-20, 4.75, areaX, 4.75)
  677. path.lineTo(areaX, height-5)
  678. painter.drawPath(path)
  679. painter.setPen(self.fColorSeprtr)
  680. painter.setRenderHint(QPainter.Antialiasing, False)
  681. # separator lines
  682. painter.drawLine(0, height-5, areaX-20, height-5)
  683. painter.drawLine(areaX, 4, width, 4)
  684. painter.setPen(self.fColorBottom)
  685. painter.setBrush(self.fColorBottom)
  686. # top, bottom and left lines
  687. painter.drawLine(0, 0, width, 0)
  688. painter.drawRect(0, height-4, areaX, 4)
  689. painter.drawRoundedRect(areaX-20, height-5, areaX, 5, 22, 22)
  690. painter.drawLine(0, 0, 0, height)
  691. # fill the rest
  692. painter.drawRect(areaX-1, 5, width, height)
  693. # bottom 1px line
  694. painter.setPen(self.fColorSeprtr)
  695. painter.drawLine(0, height-1, width, height-1)
  696. painter.restore()
  697. AbstractPluginSlot.paintEvent(self, event)
  698. # ------------------------------------------------------------------------------------------------------------
  699. class PluginSlot_BasicFX(AbstractPluginSlot):
  700. def __init__(self, parent, host, pluginId):
  701. AbstractPluginSlot.__init__(self, parent, host, pluginId)
  702. self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget()
  703. self.ui.setupUi(self)
  704. # -------------------------------------------------------------
  705. # Set-up GUI
  706. labelFont = self.ui.label_name.font()
  707. labelFont.setBold(True)
  708. labelFont.setPointSize(9)
  709. self.ui.label_name.setFont(labelFont)
  710. r = 40
  711. g = 40
  712. b = 40
  713. if self.fPluginInfo['category'] == PLUGIN_CATEGORY_MODULATOR:
  714. r += 10
  715. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_EQ:
  716. g += 10
  717. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  718. b += 10
  719. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  720. r += 15
  721. b -= 15
  722. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DISTORTION:
  723. g += 10
  724. b += 10
  725. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DYNAMICS:
  726. r += 10
  727. b += 10
  728. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_UTILITY:
  729. r += 10
  730. g += 10
  731. bg = "noise1"
  732. if self.fPluginInfo['maker'] in ("falkTX, Michael Gruhn", "DISTRHO") and "3bandeq" in self.fPluginInfo['label'].lower():
  733. bg = "3bandeq"
  734. self.setStyleSheet("""
  735. PluginSlot_BasicFX#PluginWidget {
  736. background-color: rgb(%i, %i, %i);
  737. background-image: url(:/bitmaps/background_%s.png);
  738. background-repeat: repeat-xy;
  739. }
  740. QLabel#label_name {
  741. color: #BBB;
  742. }
  743. """ % (r, g, b, bg))
  744. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  745. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  746. if self.fPluginInfo['iconName'] == "distrho":
  747. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  748. elif self.fPluginInfo['iconName'] == "file":
  749. self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  750. else:
  751. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  752. # -------------------------------------------------------------
  753. # Set-up parameters
  754. parameterCount = self.host.get_parameter_count(self.fPluginId)
  755. index = 0
  756. for i in range(parameterCount):
  757. if index >= 8:
  758. break
  759. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  760. paramData = self.host.get_parameter_data(self.fPluginId, i)
  761. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  762. if paramData['type'] != PARAMETER_INPUT:
  763. continue
  764. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  765. continue
  766. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  767. continue
  768. paramName = getParameterShortName(paramInfo['name'])
  769. #if self.fPluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  770. #_r = 55 + float(i)/8*200
  771. #_g = 255 - float(i)/8*200
  772. #_b = 127 - r*2
  773. #elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  774. #_r = 127
  775. #_g = 55 + float(i)/8*200
  776. #_b = 255 - float(i)/8*200
  777. #elif r < b < g:
  778. #_r = 55 + float(i)/8*200
  779. #_g = 127
  780. #_b = 255 - float(i)/8*200
  781. #else:
  782. _r = 255 - float(index)/8*200
  783. _g = 55 + float(index)/8*200
  784. _b = (r-40)*4
  785. #if _r < 140: _r = 140
  786. #if _g < 140: _g = 140
  787. #if _b < 140: _b = 140
  788. widget = PixmapDial(self, i)
  789. widget.setPixmap(3)
  790. widget.setLabel(paramName)
  791. widget.setCustomPaintColor(QColor(_r, _g, _b))
  792. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  793. widget.forceWhiteLabelGradientText()
  794. widget.setMinimum(paramRanges['min'])
  795. widget.setMaximum(paramRanges['max'])
  796. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  797. widget.setEnabled(False)
  798. self.ui.w_knobs.layout().insertWidget(index, widget)
  799. index += 1
  800. self.fParameterList.append([i, widget])
  801. self.ui.dial_drywet.setIndex(PARAMETER_DRYWET)
  802. self.ui.dial_drywet.setPixmap(3)
  803. self.ui.dial_drywet.setLabel("Dry/Wet")
  804. self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  805. self.ui.dial_drywet.setMinimum(0.0)
  806. self.ui.dial_drywet.setMaximum(1.0)
  807. self.ui.dial_drywet.forceWhiteLabelGradientText()
  808. self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET)
  809. self.ui.dial_vol.setIndex(PARAMETER_VOLUME)
  810. self.ui.dial_vol.setPixmap(3)
  811. self.ui.dial_vol.setLabel("Volume")
  812. self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  813. self.ui.dial_vol.setMinimum(0.0)
  814. self.ui.dial_vol.setMaximum(1.27)
  815. self.ui.dial_vol.forceWhiteLabelGradientText()
  816. self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME)
  817. self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet])
  818. self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol])
  819. # -------------------------------------------------------------
  820. self.b_enable = self.ui.b_enable
  821. self.b_gui = self.ui.b_gui
  822. self.b_edit = self.ui.b_edit
  823. self.label_name = self.ui.label_name
  824. self.led_control = self.ui.led_control
  825. self.led_midi = self.ui.led_midi
  826. self.led_audio_in = self.ui.led_audio_in
  827. self.led_audio_out = self.ui.led_audio_out
  828. self.peak_in = self.ui.peak_in
  829. self.peak_out = self.ui.peak_out
  830. self.ready()
  831. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  832. #------------------------------------------------------------------
  833. def getFixedHeight(self):
  834. return 79
  835. #------------------------------------------------------------------
  836. def paintEvent(self, event):
  837. painter = QPainter(self)
  838. painter.setBrush(Qt.transparent)
  839. painter.setPen(QPen(QColor(42, 42, 42), 1))
  840. painter.drawRect(0, 1, self.width()-1, 79-3)
  841. painter.setPen(QPen(QColor(60, 60, 60), 1))
  842. painter.drawLine(0, 0, self.width(), 0)
  843. AbstractPluginSlot.paintEvent(self, event)
  844. # ------------------------------------------------------------------------------------------------------------
  845. class PluginSlot_Calf(AbstractPluginSlot):
  846. def __init__(self, parent, host, pluginId):
  847. AbstractPluginSlot.__init__(self, parent, host, pluginId)
  848. self.ui = ui_carla_plugin_calf.Ui_PluginWidget()
  849. self.ui.setupUi(self)
  850. audioCount = self.host.get_audio_port_count_info(self.fPluginId)
  851. midiCount = self.host.get_midi_port_count_info(self.fPluginId)
  852. # -------------------------------------------------------------
  853. # Internal stuff
  854. self.fButtonFont = self.ui.b_gui.font()
  855. self.fButtonFont.setBold(False)
  856. self.fButtonFont.setPointSize(8)
  857. # Use black for mono plugins
  858. self.fBackgroundBlack = audioCount['ins'] == 1
  859. self.fButtonColorOn = QColor( 18, 41, 87)
  860. self.fButtonColorOff = QColor(150, 150, 150)
  861. # -------------------------------------------------------------
  862. # Set-up GUI
  863. self.setStyleSheet("""
  864. QLabel#label_name, QLabel#label_audio_in, QLabel#label_audio_out, QLabel#label_midi {
  865. color: #BBB;
  866. }
  867. PluginSlot_Calf#PluginWidget {
  868. background-image: url(:/bitmaps/background_calf_%s.png);
  869. background-repeat: repeat-xy;
  870. border: 2px;
  871. }
  872. """ % ("black" if self.fBackgroundBlack else "blue"))
  873. self.ui.b_gui.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  874. self.ui.b_edit.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  875. self.ui.b_remove.setPixmaps(":/bitmaps/button_calf1.png", ":/bitmaps/button_calf1_down.png", ":/bitmaps/button_calf1_hover.png")
  876. self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont)
  877. self.ui.b_remove.setTopText(self.tr("Remove"), self.fButtonColorOn, self.fButtonFont)
  878. if self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI:
  879. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  880. else:
  881. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  882. labelFont = self.ui.label_name.font()
  883. labelFont.setBold(True)
  884. labelFont.setPointSize(10)
  885. self.ui.label_name.setFont(labelFont)
  886. if audioCount['ins'] == 0:
  887. self.ui.label_audio_in.hide()
  888. self.ui.peak_in.hide()
  889. if audioCount['outs'] > 0:
  890. self.ui.peak_out.setMinimumWidth(200)
  891. if audioCount['outs'] == 0:
  892. self.ui.label_audio_out.hide()
  893. self.ui.peak_out.hide()
  894. if midiCount['ins'] == 0:
  895. self.ui.label_midi.hide()
  896. self.ui.led_midi.hide()
  897. if self.fIdleTimerId != 0:
  898. self.ui.b_remove.setEnabled(False)
  899. self.ui.b_remove.setVisible(False)
  900. # -------------------------------------------------------------
  901. # Set-up parameters
  902. parameterCount = self.host.get_parameter_count(self.fPluginId)
  903. index = 0
  904. limit = 7 if midiCount['ins'] == 0 else 6
  905. for i in range(parameterCount):
  906. if index >= limit:
  907. break
  908. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  909. paramData = self.host.get_parameter_data(self.fPluginId, i)
  910. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  911. if paramData['type'] != PARAMETER_INPUT:
  912. continue
  913. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  914. continue
  915. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  916. continue
  917. paramName = getParameterShortName(paramInfo['name'])
  918. widget = PixmapDial(self, i)
  919. widget.setPixmap(7)
  920. widget.setLabel(paramName)
  921. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  922. widget.setMinimum(paramRanges['min'])
  923. widget.setMaximum(paramRanges['max'])
  924. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  925. widget.setEnabled(False)
  926. self.ui.w_knobs.layout().insertWidget(index, widget)
  927. index += 1
  928. self.fParameterList.append([i, widget])
  929. # -------------------------------------------------------------
  930. self.b_gui = self.ui.b_gui
  931. self.b_edit = self.ui.b_edit
  932. self.b_remove = self.ui.b_remove
  933. self.label_name = self.ui.label_name
  934. self.led_midi = self.ui.led_midi
  935. self.peak_in = self.ui.peak_in
  936. self.peak_out = self.ui.peak_out
  937. self.ready()
  938. self.ui.led_midi.setColor(self.ui.led_midi.CALF)
  939. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  940. #------------------------------------------------------------------
  941. def getFixedHeight(self):
  942. return 88
  943. #------------------------------------------------------------------
  944. def editDialogPluginHintsChanged(self, pluginId, hints):
  945. if hints & PLUGIN_HAS_CUSTOM_UI:
  946. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  947. else:
  948. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  949. AbstractPluginSlot.editDialogPluginHintsChanged(self, pluginId, hints)
  950. #------------------------------------------------------------------
  951. def paintEvent(self, event):
  952. painter = QPainter(self)
  953. painter.setBrush(Qt.transparent)
  954. painter.setPen(QPen(QColor(20, 20, 20) if self.fBackgroundBlack else QColor(75, 86, 99), 1))
  955. painter.drawRect(0, 1, self.width()-1, 88-3)
  956. painter.setPen(QPen(QColor(45, 45, 45) if self.fBackgroundBlack else QColor(86, 99, 114), 1))
  957. painter.drawLine(0, 0, self.width(), 0)
  958. AbstractPluginSlot.paintEvent(self, event)
  959. # ------------------------------------------------------------------------------------------------------------
  960. class PluginSlot_OpenAV(AbstractPluginSlot):
  961. def __init__(self, parent, host, pluginId):
  962. AbstractPluginSlot.__init__(self, parent, host, pluginId)
  963. self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget()
  964. self.ui.setupUi(self)
  965. # -------------------------------------------------------------
  966. # Set-up GUI
  967. QFontDatabase.addApplicationFont(":/fonts/uranium.ttf")
  968. labelFont = QFont()
  969. labelFont.setFamily("Uranium")
  970. labelFont.setPointSize(13)
  971. labelFont.setCapitalization(QFont.AllUppercase)
  972. self.ui.label_name.setFont(labelFont)
  973. self.setStyleSheet("""
  974. PluginSlot_OpenAV#PluginWidget {
  975. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  976. stop: 0 #303030, stop: 0.35 #111111, stop: 1.0 #111111);
  977. }
  978. """)
  979. self.ui.label_name.setStyleSheet("* { color: #FF5100; }")
  980. #self.ui.line.setStyleSheet("* { background-color: #FF5100; color: #FF5100; }")
  981. self.ui.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV)
  982. self.ui.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV)
  983. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  984. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  985. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  986. # -------------------------------------------------------------
  987. # Set-up parameters
  988. parameterCount = self.host.get_parameter_count(self.fPluginId)
  989. index = 0
  990. for i in range(parameterCount):
  991. if index >= 8:
  992. break
  993. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  994. paramData = self.host.get_parameter_data(self.fPluginId, i)
  995. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  996. if paramData['type'] != PARAMETER_INPUT:
  997. continue
  998. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  999. continue
  1000. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1001. continue
  1002. paramName = getParameterShortName(paramInfo['name'])
  1003. widget = PixmapDial(self, i)
  1004. widget.setPixmap(11)
  1005. widget.setLabel(paramName)
  1006. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1007. widget.setMinimum(paramRanges['min'])
  1008. widget.setMaximum(paramRanges['max'])
  1009. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1010. widget.setEnabled(False)
  1011. self.ui.w_knobs.layout().insertWidget(index, widget)
  1012. index += 1
  1013. self.fParameterList.append([i, widget])
  1014. self.ui.dial_drywet.setIndex(PARAMETER_DRYWET)
  1015. self.ui.dial_drywet.setPixmap(13)
  1016. self.ui.dial_drywet.setLabel("Dry/Wet")
  1017. self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1018. self.ui.dial_drywet.setMinimum(0.0)
  1019. self.ui.dial_drywet.setMaximum(1.0)
  1020. self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET)
  1021. self.ui.dial_vol.setIndex(PARAMETER_VOLUME)
  1022. self.ui.dial_vol.setPixmap(12)
  1023. self.ui.dial_vol.setLabel("Volume")
  1024. self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1025. self.ui.dial_vol.setMinimum(0.0)
  1026. self.ui.dial_vol.setMaximum(1.27)
  1027. self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME)
  1028. self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet])
  1029. self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol])
  1030. # -------------------------------------------------------------
  1031. self.b_enable = self.ui.b_enable
  1032. self.b_gui = self.ui.b_gui
  1033. self.b_edit = self.ui.b_edit
  1034. self.label_name = self.ui.label_name
  1035. self.led_control = self.ui.led_control
  1036. self.led_midi = self.ui.led_midi
  1037. self.led_audio_in = self.ui.led_audio_in
  1038. self.led_audio_out = self.ui.led_audio_out
  1039. self.peak_in = self.ui.peak_in
  1040. self.peak_out = self.ui.peak_out
  1041. self.ready()
  1042. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1043. #------------------------------------------------------------------
  1044. def getFixedHeight(self):
  1045. return 79
  1046. #------------------------------------------------------------------
  1047. def paintEvent(self, event):
  1048. painter = QPainter(self)
  1049. painter.setBrush(Qt.transparent)
  1050. painter.setPen(QPen(QColor(42, 42, 42), 1))
  1051. painter.drawRect(0, 1, self.width()-1, 79-3)
  1052. painter.setPen(QPen(QColor(60, 60, 60), 1))
  1053. painter.drawLine(0, 0, self.width(), 0)
  1054. AbstractPluginSlot.paintEvent(self, event)
  1055. # ------------------------------------------------------------------------------------------------------------
  1056. class PluginSlot_Nekobi(AbstractPluginSlot):
  1057. def __init__(self, parent, host, pluginId):
  1058. AbstractPluginSlot.__init__(self, parent, host, pluginId)
  1059. #self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget()
  1060. #self.ui.setupUi(self)
  1061. # -------------------------------------------------------------
  1062. # Set-up GUI
  1063. self.fPixmapCenter = QPixmap(":/bitmaps/background_nekobi.png")
  1064. self.fPixmapLeft = QPixmap(":/bitmaps/background_nekobi_left.png")
  1065. self.fPixmapLeftRect = QRectF(0, 0, self.fPixmapLeft.width(), self.fPixmapLeft.height())
  1066. self.fPixmapRight = QPixmap(":/bitmaps/background_nekobi_right.png")
  1067. self.fPixmapRightRect = QRectF(0, 0, self.fPixmapRight.width(), self.fPixmapRight.height())
  1068. #self.setStyleSheet("""
  1069. #PluginSlot_Nekobi#PluginWidget {
  1070. #background-image: url(:/bitmaps/background_nekobi.png);
  1071. #background-repeat: repeat-xy;
  1072. #}
  1073. #QLabel#label_name {
  1074. #color: #BBB;
  1075. #}
  1076. #""")
  1077. #------------------------------------------------------------------
  1078. def getFixedHeight(self):
  1079. return 108
  1080. #------------------------------------------------------------------
  1081. def paintEvent(self, event):
  1082. painter = QPainter(self)
  1083. # main bg (center)
  1084. painter.drawTiledPixmap(0, 0, self.width(), self.height(), self.fPixmapCenter)
  1085. # left side
  1086. painter.drawPixmap(self.fPixmapLeftRect, self.fPixmapLeft, self.fPixmapLeftRect)
  1087. # right side
  1088. rightTarget = QRectF(self.fPixmapRightRect)
  1089. rightTarget.moveLeft(self.width()-rightTarget.width())
  1090. painter.drawPixmap(rightTarget, self.fPixmapRight, self.fPixmapRightRect)
  1091. AbstractPluginSlot.paintEvent(self, event)
  1092. # ------------------------------------------------------------------------------------------------------------
  1093. class PluginSlot_SF2(AbstractPluginSlot):
  1094. def __init__(self, parent, host, pluginId):
  1095. AbstractPluginSlot.__init__(self, parent, host, pluginId)
  1096. self.ui = ui_carla_plugin_sf2.Ui_PluginWidget()
  1097. self.ui.setupUi(self)
  1098. # -------------------------------------------------------------
  1099. # Set-up GUI
  1100. #labelFont = self.ui.label_name.font()
  1101. #labelFont.setBold(True)
  1102. #labelFont.setPointSize(9)
  1103. #self.ui.label_name.setFont(labelFont)
  1104. self.setStyleSheet("""
  1105. PluginSlot_SF2#PluginWidget {
  1106. background-image: url(:/bitmaps/background_3bandeq.png);
  1107. background-repeat: repeat-xy;
  1108. }
  1109. QLabel#label_name {
  1110. color: #BBB;
  1111. }
  1112. """)
  1113. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  1114. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  1115. # -------------------------------------------------------------
  1116. # Set-up parameters
  1117. parameterCount = self.host.get_parameter_count(self.fPluginId)
  1118. index = 0
  1119. for i in range(parameterCount):
  1120. if index >= 8:
  1121. break
  1122. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  1123. paramData = self.host.get_parameter_data(self.fPluginId, i)
  1124. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  1125. if paramData['type'] != PARAMETER_INPUT:
  1126. continue
  1127. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  1128. continue
  1129. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1130. continue
  1131. paramName = getParameterShortName(paramInfo['name'])
  1132. widget = PixmapDial(self, i)
  1133. widget.setPixmap(3)
  1134. widget.setLabel(paramName)
  1135. widget.setMinimum(paramRanges['min'])
  1136. widget.setMaximum(paramRanges['max'])
  1137. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1138. widget.setEnabled(False)
  1139. self.ui.w_knobs.layout().insertWidget(index, widget)
  1140. index += 1
  1141. self.fParameterList.append([i, widget])
  1142. self.ui.dial_vol.setIndex(PARAMETER_VOLUME)
  1143. self.ui.dial_vol.setPixmap(3)
  1144. self.ui.dial_vol.setLabel("Volume")
  1145. self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  1146. self.ui.dial_vol.setMinimum(0.0)
  1147. self.ui.dial_vol.setMaximum(1.27)
  1148. self.ui.dial_vol.forceWhiteLabelGradientText()
  1149. self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME)
  1150. self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol])
  1151. # -------------------------------------------------------------
  1152. self.b_enable = self.ui.b_enable
  1153. self.b_edit = self.ui.b_edit
  1154. self.label_name = self.ui.label_name
  1155. self.led_control = self.ui.led_control
  1156. self.led_midi = self.ui.led_midi
  1157. self.led_audio_out = self.ui.led_audio_out
  1158. self.peak_out = self.ui.peak_out
  1159. self.ready()
  1160. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1161. #------------------------------------------------------------------
  1162. def getFixedHeight(self):
  1163. return 79
  1164. #------------------------------------------------------------------
  1165. def paintEvent(self, event):
  1166. painter = QPainter(self)
  1167. painter.setBrush(Qt.transparent)
  1168. painter.setPen(QPen(QColor(42, 42, 42), 1))
  1169. painter.drawRect(0, 1, self.width()-1, 79-3)
  1170. painter.setPen(QPen(QColor(60, 60, 60), 1))
  1171. painter.drawLine(0, 0, self.width(), 0)
  1172. AbstractPluginSlot.paintEvent(self, event)
  1173. # ------------------------------------------------------------------------------------------------------------
  1174. class PluginSlot_ZitaRev(AbstractPluginSlot):
  1175. def __init__(self, parent, host, pluginId):
  1176. AbstractPluginSlot.__init__(self, parent, host, pluginId)
  1177. self.ui = ui_carla_plugin_zita.Ui_PluginWidget()
  1178. self.ui.setupUi(self)
  1179. # -------------------------------------------------------------
  1180. # Internal stuff
  1181. audioCount = self.host.get_audio_port_count_info(self.fPluginId)
  1182. # -------------------------------------------------------------
  1183. # Set-up GUI
  1184. self.setMinimumWidth(640)
  1185. self.setStyleSheet("""
  1186. PluginSlot_ZitaRev#PluginWidget {
  1187. background-color: #404040;
  1188. border: 2px solid transparent;
  1189. }
  1190. QWidget#w_revsect {
  1191. background-image: url(:/bitmaps/zita-rev/revsect.png);
  1192. }
  1193. QWidget#w_eq1sect {
  1194. background-image: url(:/bitmaps/zita-rev/eq1sect.png);
  1195. }
  1196. QWidget#w_eq2sect {
  1197. background-image: url(:/bitmaps/zita-rev/eq2sect.png);
  1198. }
  1199. QWidget#w_ambmixsect {
  1200. background-image: url(:/bitmaps/zita-rev/%s.png);
  1201. }
  1202. QWidget#w_redzita {
  1203. background-image: url(:/bitmaps/zita-rev/redzita.png);
  1204. }
  1205. """ % ("mixsect" if audioCount['outs'] == 2 else "ambsect"))
  1206. # -------------------------------------------------------------
  1207. # Set-up Knobs
  1208. self.fKnobDelay = PixmapDial(self, 0)
  1209. self.fKnobDelay.setPixmap(6)
  1210. self.fKnobDelay.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1211. self.fKnobDelay.setMinimum(0.02)
  1212. self.fKnobDelay.setMaximum(0.10)
  1213. self.fKnobXover = PixmapDial(self, 1)
  1214. self.fKnobXover.setPixmap(6)
  1215. self.fKnobXover.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1216. self.fKnobXover.setMinimum(50.0)
  1217. self.fKnobXover.setMaximum(1000.0)
  1218. self.fKnobRtLow = PixmapDial(self, 2)
  1219. self.fKnobRtLow.setPixmap(6)
  1220. self.fKnobRtLow.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1221. self.fKnobRtLow.setMinimum(1.0)
  1222. self.fKnobRtLow.setMaximum(8.0)
  1223. self.fKnobRtMid = PixmapDial(self, 3)
  1224. self.fKnobRtMid.setPixmap(6)
  1225. self.fKnobRtMid.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1226. self.fKnobRtMid.setMinimum(1.0)
  1227. self.fKnobRtMid.setMaximum(8.0)
  1228. self.fKnobDamping = PixmapDial(self, 4)
  1229. self.fKnobDamping.setPixmap(6)
  1230. self.fKnobDamping.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1231. self.fKnobDamping.setMinimum(1500.0)
  1232. self.fKnobDamping.setMaximum(24000.0)
  1233. self.fKnobEq1Freq = PixmapDial(self, 5)
  1234. self.fKnobEq1Freq.setPixmap(6)
  1235. self.fKnobEq1Freq.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1236. self.fKnobEq1Freq.setMinimum(40.0)
  1237. self.fKnobEq1Freq.setMaximum(10000.0)
  1238. self.fKnobEq1Gain = PixmapDial(self, 6)
  1239. self.fKnobEq1Gain.setPixmap(6)
  1240. self.fKnobEq1Gain.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1241. self.fKnobEq1Gain.setMinimum(-20.0)
  1242. self.fKnobEq1Gain.setMaximum(20.0)
  1243. self.fKnobEq2Freq = PixmapDial(self, 7)
  1244. self.fKnobEq2Freq.setPixmap(6)
  1245. self.fKnobEq2Freq.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1246. self.fKnobEq2Freq.setMinimum(40.0)
  1247. self.fKnobEq2Freq.setMaximum(10000.0)
  1248. self.fKnobEq2Gain = PixmapDial(self, 8)
  1249. self.fKnobEq2Gain.setPixmap(6)
  1250. self.fKnobEq2Gain.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1251. self.fKnobEq2Gain.setMinimum(-20.0)
  1252. self.fKnobEq2Gain.setMaximum(20.0)
  1253. self.fKnobMix = PixmapDial(self, 9)
  1254. self.fKnobMix.setPixmap(6)
  1255. self.fKnobMix.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  1256. self.fKnobMix.setMinimum(0.0)
  1257. self.fKnobMix.setMaximum(1.0)
  1258. self.fParameterList.append([0, self.fKnobDelay])
  1259. self.fParameterList.append([1, self.fKnobXover])
  1260. self.fParameterList.append([2, self.fKnobRtLow])
  1261. self.fParameterList.append([3, self.fKnobRtMid])
  1262. self.fParameterList.append([4, self.fKnobDamping])
  1263. self.fParameterList.append([5, self.fKnobEq1Freq])
  1264. self.fParameterList.append([6, self.fKnobEq1Gain])
  1265. self.fParameterList.append([7, self.fKnobEq2Freq])
  1266. self.fParameterList.append([8, self.fKnobEq2Gain])
  1267. self.fParameterList.append([9, self.fKnobMix])
  1268. # -------------------------------------------------------------
  1269. self.ready()
  1270. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1271. #------------------------------------------------------------------
  1272. def getFixedHeight(self):
  1273. return 79
  1274. #------------------------------------------------------------------
  1275. def paintEvent(self, event):
  1276. AbstractPluginSlot.paintEvent(self, event)
  1277. self.drawOutline()
  1278. def resizeEvent(self, event):
  1279. self.fKnobDelay.move(self.ui.w_revsect.x()+31, self.ui.w_revsect.y()+33)
  1280. self.fKnobXover.move(self.ui.w_revsect.x()+93, self.ui.w_revsect.y()+18)
  1281. self.fKnobRtLow.move(self.ui.w_revsect.x()+148, self.ui.w_revsect.y()+18)
  1282. self.fKnobRtMid.move(self.ui.w_revsect.x()+208, self.ui.w_revsect.y()+18)
  1283. self.fKnobDamping.move(self.ui.w_revsect.x()+268, self.ui.w_revsect.y()+18)
  1284. self.fKnobEq1Freq.move(self.ui.w_eq1sect.x()+20, self.ui.w_eq1sect.y()+33)
  1285. self.fKnobEq1Gain.move(self.ui.w_eq1sect.x()+69, self.ui.w_eq1sect.y()+18)
  1286. self.fKnobEq2Freq.move(self.ui.w_eq2sect.x()+20, self.ui.w_eq2sect.y()+33)
  1287. self.fKnobEq2Gain.move(self.ui.w_eq2sect.x()+69, self.ui.w_eq2sect.y()+18)
  1288. self.fKnobMix.move(self.ui.w_ambmixsect.x()+24, self.ui.w_ambmixsect.y()+33)
  1289. AbstractPluginSlot.resizeEvent(self, event)
  1290. # ------------------------------------------------------------------------------------------------------------
  1291. class PluginSlot_ZynFX(AbstractPluginSlot):
  1292. def __init__(self, parent, host, pluginId):
  1293. AbstractPluginSlot.__init__(self, parent, host, pluginId)
  1294. self.ui = ui_carla_plugin_zynfx.Ui_PluginWidget()
  1295. self.ui.setupUi(self)
  1296. # -------------------------------------------------------------
  1297. # Set-up GUI
  1298. self.setStyleSheet("""
  1299. PluginSlot_ZynFX#PluginWidget {
  1300. background-image: url(:/bitmaps/background_zynfx.png);
  1301. background-repeat: repeat-xy;
  1302. border: 2px;
  1303. }
  1304. QLabel#label_name, QLabel#label_presets {
  1305. color: #BBB;
  1306. }
  1307. """)
  1308. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  1309. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  1310. labelFont = self.ui.label_name.font()
  1311. labelFont.setBold(True)
  1312. labelFont.setPointSize(9)
  1313. self.ui.label_name.setFont(labelFont)
  1314. presetFont = self.ui.label_presets.font()
  1315. presetFont.setBold(True)
  1316. presetFont.setPointSize(8)
  1317. self.ui.label_presets.setFont(presetFont)
  1318. self.ui.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV)
  1319. self.ui.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV)
  1320. # -------------------------------------------------------------
  1321. # Set-up parameters
  1322. parameterCount = self.host.get_parameter_count(self.fPluginId)
  1323. index = 0
  1324. for i in range(parameterCount):
  1325. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  1326. paramData = self.host.get_parameter_data(self.fPluginId, i)
  1327. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  1328. if paramData['type'] != PARAMETER_INPUT:
  1329. continue
  1330. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  1331. continue
  1332. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1333. continue
  1334. paramName = paramInfo['name']
  1335. # real zyn fx plugins
  1336. if self.fPluginInfo['label'] == "zynalienwah":
  1337. if i == 0: paramName = "Freq"
  1338. elif i == 1: paramName = "Rnd"
  1339. elif i == 2: paramName = "L type" # combobox
  1340. elif i == 3: paramName = "St.df"
  1341. elif i == 5: paramName = "Fb"
  1342. elif i == 7: paramName = "L/R"
  1343. elif self.fPluginInfo['label'] == "zynchorus":
  1344. if i == 0: paramName = "Freq"
  1345. elif i == 1: paramName = "Rnd"
  1346. elif i == 2: paramName = "L type" # combobox
  1347. elif i == 3: paramName = "St.df"
  1348. elif i == 6: paramName = "Fb"
  1349. elif i == 7: paramName = "L/R"
  1350. elif i == 8: paramName = "Flngr" # button
  1351. elif i == 9: paramName = "Subst" # button
  1352. elif self.fPluginInfo['label'] == "zyndistortion":
  1353. if i == 0: paramName = "LRc."
  1354. elif i == 4: paramName = "Neg." # button
  1355. elif i == 5: paramName = "LPF"
  1356. elif i == 6: paramName = "HPF"
  1357. elif i == 7: paramName = "St." # button
  1358. elif i == 8: paramName = "PF" # button
  1359. elif self.fPluginInfo['label'] == "zyndynamicfilter":
  1360. if i == 0: paramName = "Freq"
  1361. elif i == 1: paramName = "Rnd"
  1362. elif i == 2: paramName = "L type" # combobox
  1363. elif i == 3: paramName = "St.df"
  1364. elif i == 4: paramName = "LfoD"
  1365. elif i == 5: paramName = "A.S."
  1366. elif i == 6: paramName = "A.Inv." # button
  1367. elif i == 7: paramName = "A.M."
  1368. elif self.fPluginInfo['label'] == "zynecho":
  1369. if i == 1: paramName = "LRdl."
  1370. elif i == 2: paramName = "LRc."
  1371. elif i == 3: paramName = "Fb."
  1372. elif i == 4: paramName = "Damp"
  1373. elif self.fPluginInfo['label'] == "zynphaser":
  1374. if i == 0: paramName = "Freq"
  1375. elif i == 1: paramName = "Rnd"
  1376. elif i == 2: paramName = "L type" # combobox
  1377. elif i == 3: paramName = "St.df"
  1378. elif i == 5: paramName = "Fb"
  1379. elif i == 7: paramName = "L/R"
  1380. elif i == 8: paramName = "Subst" # button
  1381. elif i == 9: paramName = "Phase"
  1382. elif i == 11: paramName = "Dist"
  1383. elif self.fPluginInfo['label'] == "zynreverb":
  1384. if i == 2: paramName = "I.delfb"
  1385. elif i == 5: paramName = "LPF"
  1386. elif i == 6: paramName = "HPF"
  1387. elif i == 9: paramName = "R.S."
  1388. elif i == 10: paramName = "I.del"
  1389. else:
  1390. paramName = getParameterShortName(paramInfo['name'])
  1391. widget = PixmapDial(self, i)
  1392. widget.setPixmap(5)
  1393. widget.setLabel(paramName)
  1394. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1395. widget.setMinimum(paramRanges['min'])
  1396. widget.setMaximum(paramRanges['max'])
  1397. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1398. widget.setEnabled(False)
  1399. self.ui.w_knobs.layout().insertWidget(index, widget)
  1400. index += 1
  1401. self.fParameterList.append([i, widget])
  1402. self.ui.dial_drywet.setIndex(PARAMETER_DRYWET)
  1403. self.ui.dial_drywet.setPixmap(5)
  1404. self.ui.dial_drywet.setLabel("Wet")
  1405. self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1406. self.ui.dial_drywet.setMinimum(0.0)
  1407. self.ui.dial_drywet.setMaximum(1.0)
  1408. self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET)
  1409. self.ui.dial_vol.setIndex(PARAMETER_VOLUME)
  1410. self.ui.dial_vol.setPixmap(5)
  1411. self.ui.dial_vol.setLabel("Vol")
  1412. self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1413. self.ui.dial_vol.setMinimum(0.0)
  1414. self.ui.dial_vol.setMaximum(1.27)
  1415. self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME)
  1416. self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet])
  1417. self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol])
  1418. # -------------------------------------------------------------
  1419. # Set-up MIDI programs
  1420. midiProgramCount = self.host.get_midi_program_count(self.fPluginId)
  1421. if midiProgramCount > 0:
  1422. self.ui.cb_presets.setEnabled(True)
  1423. self.ui.label_presets.setEnabled(True)
  1424. for i in range(midiProgramCount):
  1425. mpData = self.host.get_midi_program_data(self.fPluginId, i)
  1426. mpName = mpData['name']
  1427. self.ui.cb_presets.addItem(mpName)
  1428. self.fCurrentMidiProgram = self.host.get_current_midi_program_index(self.fPluginId)
  1429. self.ui.cb_presets.setCurrentIndex(self.fCurrentMidiProgram)
  1430. else:
  1431. self.fCurrentMidiProgram = -1
  1432. self.ui.cb_presets.setEnabled(False)
  1433. self.ui.cb_presets.setVisible(False)
  1434. self.ui.label_presets.setEnabled(False)
  1435. self.ui.label_presets.setVisible(False)
  1436. # -------------------------------------------------------------
  1437. self.b_enable = self.ui.b_enable
  1438. self.b_edit = self.ui.b_edit
  1439. self.cb_presets = self.ui.cb_presets
  1440. self.label_name = self.ui.label_name
  1441. self.led_control = self.ui.led_control
  1442. self.led_midi = self.ui.led_midi
  1443. self.led_audio_in = self.ui.led_audio_in
  1444. self.led_audio_out = self.ui.led_audio_out
  1445. self.peak_in = self.ui.peak_in
  1446. self.peak_out = self.ui.peak_out
  1447. self.ready()
  1448. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1449. self.ui.cb_presets.currentIndexChanged.connect(self.slot_midiProgramChanged)
  1450. #------------------------------------------------------------------
  1451. def getFixedHeight(self):
  1452. return 77
  1453. #------------------------------------------------------------------
  1454. def paintEvent(self, event):
  1455. painter = QPainter(self)
  1456. painter.setBrush(Qt.transparent)
  1457. painter.setPen(QPen(QColor(60, 60, 60), 1))
  1458. painter.drawRect(0, 1, self.width()-1, self.height()-3)
  1459. painter.setPen(QPen(QColor(94, 94, 94), 1))
  1460. painter.drawLine(0, 0, self.width(), 0)
  1461. AbstractPluginSlot.paintEvent(self, event)
  1462. # ------------------------------------------------------------------------------------------------------------
  1463. def createPluginSlot(parent, host, pluginId, useSkins):
  1464. if not useSkins:
  1465. return PluginSlot_Default(parent, host, pluginId)
  1466. pluginInfo = host.get_plugin_info(pluginId)
  1467. pluginName = host.get_real_plugin_name(pluginId)
  1468. pluginLabel = pluginInfo['label']
  1469. pluginMaker = pluginInfo['maker']
  1470. uniqueId = pluginInfo['uniqueId']
  1471. #pluginIcon = pluginInfo['iconName']
  1472. if pluginInfo['type'] == PLUGIN_SF2:
  1473. return PluginSlot_SF2(parent, host, pluginId)
  1474. if pluginMaker == "OpenAV Productions":
  1475. return PluginSlot_OpenAV(parent, host, pluginId)
  1476. if pluginInfo['type'] == PLUGIN_INTERNAL:
  1477. if pluginLabel.startswith("zyn") and pluginInfo['category'] != PLUGIN_CATEGORY_SYNTH:
  1478. return PluginSlot_ZynFX(parent, host, pluginId)
  1479. elif pluginInfo['type'] == PLUGIN_LADSPA:
  1480. if (pluginLabel == "zita-reverb" and uniqueId == 3701) or (pluginLabel == "zita-reverb-amb" and uniqueId == 3702):
  1481. return PluginSlot_ZitaRev(parent, host, pluginId)
  1482. if pluginLabel.startswith("Zyn") and pluginMaker.startswith("Josep Andreu"):
  1483. return PluginSlot_ZynFX(parent, host, pluginId)
  1484. if pluginName.split(" ", 1)[0].lower() == "calf":
  1485. return PluginSlot_Calf(parent, host, pluginId)
  1486. #if pluginName.lower() == "nekobi":
  1487. #return PluginSlot_Nekobi(parent, pluginId)
  1488. return PluginSlot_BasicFX(parent, host, pluginId)
  1489. # ------------------------------------------------------------------------------------------------------------
  1490. # Main Testing
  1491. if __name__ == '__main__':
  1492. from carla_app import CarlaApplication
  1493. from carla_host import initHost, loadHostSettings
  1494. import resources_rc
  1495. app = CarlaApplication("Carla-Skins")
  1496. host = initHost("Skins", None, False, False, False)
  1497. loadHostSettings(host)
  1498. host.engine_init("JACK", "Carla-Widgets")
  1499. host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, "", "", "zynreverb", 0, None)
  1500. #host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None)
  1501. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://www.openavproductions.com/sorcer", 0, None)
  1502. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://calf.sourceforge.net/plugins/Compressor", 0, None)
  1503. host.set_active(0, True)
  1504. gui = createPluginSlot(None, host, 0, True)
  1505. gui.testTimer()
  1506. gui.show()
  1507. app.exec_()