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.

1350 lines
50KB

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