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.

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