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.

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