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.

1865 lines
69KB

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