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.

1320 lines
49KB

  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 = Carla.host.get_plugin_info(self.fPluginId) if Carla.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 Carla.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 Carla.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK or Carla.host is None:
  56. self.fPeaksInputCount = 2
  57. self.fPeaksOutputCount = 2
  58. else:
  59. audioCountInfo = Carla.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 Carla.host is not None:
  127. paramWidget.setValue(Carla.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: Carla.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. Carla.host.set_drywet(self.fPluginId, value)
  167. elif parameterId == PARAMETER_VOLUME:
  168. if (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) == 0: return
  169. Carla.host.set_volume(self.fPluginId, value)
  170. elif parameterId == PARAMETER_BALANCE_LEFT:
  171. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  172. Carla.host.set_balance_left(self.fPluginId, value)
  173. elif parameterId == PARAMETER_BALANCE_RIGHT:
  174. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  175. Carla.host.set_balance_right(self.fPluginId, value)
  176. elif parameterId == PARAMETER_PANNING:
  177. if (self.fPluginInfo['hints'] & PLUGIN_CAN_PANNING) == 0: return
  178. Carla.host.set_panning(self.fPluginId, value)
  179. elif parameterId == PARAMETER_CTRL_CHANNEL:
  180. Carla.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 = Carla.host.get_input_peak_value(self.fPluginId, True)
  280. peak2 = Carla.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 = Carla.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 = Carla.host.get_output_peak_value(self.fPluginId, True)
  297. peak2 = Carla.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 = Carla.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 Carla.host is not None and not Carla.host.clone_plugin(self.fPluginId):
  363. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  364. Carla.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 Carla.host is None or Carla.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. Carla.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  376. elif actSel == actRemove:
  377. if Carla.host is not None and not Carla.host.remove_plugin(self.fPluginId):
  378. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  379. Carla.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. Carla.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. Carla.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. Carla.host.set_parameter_value(self.fPluginId, index, value)
  406. self.setParameterValue(index, value, False)
  407. @pyqtSlot(int)
  408. def slot_programChanged(self, index):
  409. Carla.host.set_program(self.fPluginId, index)
  410. self.setProgram(index, False)
  411. @pyqtSlot(int)
  412. def slot_midiProgramChanged(self, index):
  413. Carla.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. self.ui.label_type.setFont(labelFont)
  529. r = 40
  530. g = 40
  531. b = 40
  532. if self.fPluginInfo['category'] == PLUGIN_CATEGORY_MODULATOR:
  533. r += 10
  534. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_EQ:
  535. g += 10
  536. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  537. b += 10
  538. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  539. r += 15
  540. b -= 15
  541. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DISTORTION:
  542. g += 10
  543. b += 10
  544. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DYNAMICS:
  545. r += 10
  546. b += 10
  547. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_UTILITY:
  548. r += 10
  549. g += 10
  550. self.setStyleSheet("""
  551. QFrame#PluginWidget {
  552. background-color: rgb(%i, %i, %i);
  553. background-image: url(:/bitmaps/background_noise1.png);
  554. background-repeat: repeat-xy;
  555. }""" % (r, g, b))
  556. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  557. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  558. if self.fPluginInfo['iconName'] == "distrho":
  559. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  560. elif self.fPluginInfo['iconName'] == "file":
  561. self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  562. else:
  563. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  564. # -------------------------------------------------------------
  565. # Set-up parameters
  566. parameterCount = Carla.host.get_parameter_count(self.fPluginId) if Carla.host is not None else 0
  567. index = 0
  568. for i in range(min(parameterCount, 8)):
  569. paramInfo = Carla.host.get_parameter_info(self.fPluginId, i)
  570. paramData = Carla.host.get_parameter_data(self.fPluginId, i)
  571. paramRanges = Carla.host.get_parameter_ranges(self.fPluginId, i)
  572. if paramData['type'] != PARAMETER_INPUT:
  573. continue
  574. paramName = charPtrToString(paramInfo['name']).split("/", 1)[0].split(" (", 1)[0].strip()
  575. paramLow = paramName.lower()
  576. if "Bandwidth" in paramName:
  577. paramName = paramName.replace("Bandwidth", "Bw")
  578. elif "Frequency" in paramName:
  579. paramName = paramName.replace("Frequency", "Freq")
  580. elif "Output" in paramName:
  581. paramName = paramName.replace("Output", "Out")
  582. elif paramLow == "threshold":
  583. paramName = "Thres"
  584. if len(paramName) > 9:
  585. paramName = paramName[:9]
  586. #if self.fPluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  587. #_r = 55 + float(i)/8*200
  588. #_g = 255 - float(i)/8*200
  589. #_b = 127 - r*2
  590. #elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  591. #_r = 127
  592. #_g = 55 + float(i)/8*200
  593. #_b = 255 - float(i)/8*200
  594. #elif r < b < g:
  595. #_r = 55 + float(i)/8*200
  596. #_g = 127
  597. #_b = 255 - float(i)/8*200
  598. #else:
  599. _r = 255 - float(i)/8*200
  600. _g = 55 + float(i)/8*200
  601. _b = (r-40)*4
  602. #if _r < 140: _r = 140
  603. #if _g < 140: _g = 140
  604. #if _b < 140: _b = 140
  605. widget = PixmapDial(self, i)
  606. widget.setPixmap(3)
  607. widget.setLabel(paramName)
  608. widget.setCustomColor(QColor(_r, _g, _b))
  609. widget.setCustomPaint(PixmapDial.CUSTOM_PAINT_COLOR)
  610. widget.setSingleStep(paramRanges['step']*1000)
  611. widget.setMinimum(paramRanges['min']*1000)
  612. widget.setMaximum(paramRanges['max']*1000)
  613. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  614. widget.setEnabled(False)
  615. self.ui.w_knobs.layout().insertWidget(index, widget)
  616. index += 1
  617. self.fParameterList.append([i, widget])
  618. self.ui.dial_drywet.setIndex(PARAMETER_DRYWET)
  619. self.ui.dial_drywet.setPixmap(3)
  620. self.ui.dial_drywet.setLabel("Dry/Wet")
  621. self.ui.dial_drywet.setCustomPaint(PixmapDial.CUSTOM_PAINT_CARLA_WET)
  622. self.ui.dial_vol.setIndex(PARAMETER_VOLUME)
  623. self.ui.dial_vol.setPixmap(3)
  624. self.ui.dial_vol.setLabel("Volume")
  625. self.ui.dial_vol.setCustomPaint(PixmapDial.CUSTOM_PAINT_CARLA_VOL)
  626. self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet])
  627. self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol])
  628. # -------------------------------------------------------------
  629. self.b_enable = self.ui.b_enable
  630. self.b_gui = self.ui.b_gui
  631. self.b_edit = self.ui.b_edit
  632. self.label_name = self.ui.label_name
  633. self.label_type = self.ui.label_type
  634. self.peak_in = self.ui.peak_in
  635. self.peak_out = self.ui.peak_out
  636. self.ready()
  637. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  638. #------------------------------------------------------------------
  639. def getFixedHeight(self):
  640. return 79
  641. # ------------------------------------------------------------------------------------------------------------
  642. class PluginSlot_Calf(AbstractPluginSlot):
  643. def __init__(self, parent, pluginId):
  644. AbstractPluginSlot.__init__(self, parent, pluginId)
  645. self.ui = ui_carla_plugin_calf.Ui_PluginWidget()
  646. self.ui.setupUi(self)
  647. # -------------------------------------------------------------
  648. # Internal stuff
  649. self.fButtonFont = QFont()
  650. #self.fButtonFont.setBold(False)
  651. self.fButtonFont.setPointSize(8)
  652. self.fButtonColorOn = QColor( 18, 41, 87)
  653. self.fButtonColorOff = QColor(150, 150, 150)
  654. # -------------------------------------------------------------
  655. # Set-up GUI
  656. self.setStyleSheet("""
  657. QLabel#label_name, QLabel#label_audio_in, QLabel#label_audio_out, QLabel#label_midi {
  658. color: black;
  659. }
  660. QFrame#PluginWidget {
  661. background-image: url(:/bitmaps/background_calf.png);
  662. background-repeat: repeat-xy;
  663. border: 2px;
  664. }
  665. """)
  666. self.ui.b_gui.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  667. self.ui.b_edit.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  668. self.ui.b_remove.setPixmaps(":/bitmaps/button_calf1.png", ":/bitmaps/button_calf1_down.png", ":/bitmaps/button_calf1_hover.png")
  669. self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont)
  670. self.ui.b_remove.setTopText(self.tr("Remove"), self.fButtonColorOn, self.fButtonFont)
  671. if self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI:
  672. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  673. else:
  674. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  675. labelFont = self.ui.label_name.font()
  676. labelFont.setBold(True)
  677. labelFont.setPointSize(labelFont.pointSize()+3)
  678. self.ui.label_name.setFont(labelFont)
  679. audioCount = Carla.host.get_audio_port_count_info(self.fPluginId) if Carla.host is not None else {'ins': 2, 'outs': 2 }
  680. midiCount = Carla.host.get_midi_port_count_info(self.fPluginId) if Carla.host is not None else {'ins': 1, 'outs': 0 }
  681. if audioCount['ins'] == 0:
  682. self.ui.label_audio_in.hide()
  683. self.ui.peak_in.hide()
  684. if audioCount['outs'] > 0:
  685. self.ui.peak_out.setMinimumWidth(200)
  686. if audioCount['outs'] == 0:
  687. self.ui.label_audio_out.hide()
  688. self.ui.peak_out.hide()
  689. if midiCount['ins'] == 0:
  690. self.ui.label_midi.hide()
  691. self.ui.led_midi.hide()
  692. # -------------------------------------------------------------
  693. self.b_gui = self.ui.b_gui
  694. self.b_edit = self.ui.b_edit
  695. self.b_remove = self.ui.b_remove
  696. self.label_name = self.ui.label_name
  697. self.led_midi = self.ui.led_midi
  698. self.peak_in = self.ui.peak_in
  699. self.peak_out = self.ui.peak_out
  700. self.ready()
  701. self.ui.led_midi.setColor(self.ui.led_midi.CALF)
  702. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  703. #------------------------------------------------------------------
  704. def getFixedHeight(self):
  705. return 70
  706. #------------------------------------------------------------------
  707. def recheckPluginHints(self, hints):
  708. if hints & PLUGIN_HAS_CUSTOM_UI:
  709. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  710. else:
  711. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  712. AbstractPluginSlot.recheckPluginHints(self, hints)
  713. # ------------------------------------------------------------------------------------------------------------
  714. class PluginSlot_ZitaRev(AbstractPluginSlot):
  715. def __init__(self, parent, pluginId):
  716. AbstractPluginSlot.__init__(self, parent, pluginId)
  717. self.ui = ui_carla_plugin_zita.Ui_PluginWidget()
  718. self.ui.setupUi(self)
  719. # -------------------------------------------------------------
  720. # Internal stuff
  721. audioCount = Carla.host.get_audio_port_count_info(self.fPluginId) if Carla.host is not None else {'ins': 2, 'outs': 2 }
  722. # -------------------------------------------------------------
  723. # Set-up GUI
  724. self.setMinimumWidth(640)
  725. self.setStyleSheet("""
  726. QFrame#PluginWidget {
  727. background-color: #404040;
  728. border: 2px solid transparent;
  729. }
  730. QWidget#w_revsect {
  731. background-image: url(:/bitmaps/zita-rev/revsect.png);
  732. }
  733. QWidget#w_eq1sect {
  734. background-image: url(:/bitmaps/zita-rev/eq1sect.png);
  735. }
  736. QWidget#w_eq2sect {
  737. background-image: url(:/bitmaps/zita-rev/eq2sect.png);
  738. }
  739. QWidget#w_ambmixsect {
  740. background-image: url(:/bitmaps/zita-rev/%s.png);
  741. }
  742. QWidget#w_redzita {
  743. background-image: url(:/bitmaps/zita-rev/redzita.png);
  744. }
  745. """ % ("mixsect" if audioCount['outs'] == 2 else "ambsect"))
  746. # -------------------------------------------------------------
  747. # Set-up Knobs
  748. self.fKnobDelay = PixmapDial(self, 0)
  749. self.fKnobDelay.setPixmap(6)
  750. self.fKnobDelay.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  751. self.fKnobDelay.setMinimum(0.02*1000)
  752. self.fKnobDelay.setMaximum(0.10*1000)
  753. self.fKnobXover = PixmapDial(self, 1)
  754. self.fKnobXover.setPixmap(6)
  755. self.fKnobXover.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  756. self.fKnobXover.setMinimum(50*1000)
  757. self.fKnobXover.setMaximum(1000*1000)
  758. self.fKnobRtLow = PixmapDial(self, 2)
  759. self.fKnobRtLow.setPixmap(6)
  760. self.fKnobRtLow.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  761. self.fKnobRtLow.setMinimum(1*1000)
  762. self.fKnobRtLow.setMaximum(8*1000)
  763. self.fKnobRtMid = PixmapDial(self, 3)
  764. self.fKnobRtMid.setPixmap(6)
  765. self.fKnobRtMid.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  766. self.fKnobRtMid.setMinimum(1*1000)
  767. self.fKnobRtMid.setMaximum(8*1000)
  768. self.fKnobDamping = PixmapDial(self, 4)
  769. self.fKnobDamping.setPixmap(6)
  770. self.fKnobDamping.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  771. self.fKnobDamping.setMinimum(1500*1000)
  772. self.fKnobDamping.setMaximum(24000*1000)
  773. self.fKnobEq1Freq = PixmapDial(self, 5)
  774. self.fKnobEq1Freq.setPixmap(6)
  775. self.fKnobEq1Freq.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  776. self.fKnobEq1Freq.setMinimum(40*1000)
  777. self.fKnobEq1Freq.setMaximum(10000*1000)
  778. self.fKnobEq1Gain = PixmapDial(self, 6)
  779. self.fKnobEq1Gain.setPixmap(6)
  780. self.fKnobEq1Gain.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  781. self.fKnobEq1Gain.setMinimum(-20*1000)
  782. self.fKnobEq1Gain.setMaximum(20*1000)
  783. self.fKnobEq2Freq = PixmapDial(self, 7)
  784. self.fKnobEq2Freq.setPixmap(6)
  785. self.fKnobEq2Freq.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  786. self.fKnobEq2Freq.setMinimum(40*1000)
  787. self.fKnobEq2Freq.setMaximum(10000*1000)
  788. self.fKnobEq2Gain = PixmapDial(self, 8)
  789. self.fKnobEq2Gain.setPixmap(6)
  790. self.fKnobEq2Gain.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  791. self.fKnobEq2Gain.setMinimum(-20*1000)
  792. self.fKnobEq2Gain.setMaximum(20*1000)
  793. self.fKnobMix = PixmapDial(self, 9)
  794. self.fKnobMix.setPixmap(6)
  795. self.fKnobMix.setCustomPaint(PixmapDial.CUSTOM_PAINT_ZITA)
  796. self.fKnobMix.setMinimum(0.0*1000)
  797. self.fKnobMix.setMaximum(1.0*1000)
  798. self.fParameterList.append([0, self.fKnobDelay])
  799. self.fParameterList.append([1, self.fKnobXover])
  800. self.fParameterList.append([2, self.fKnobRtLow])
  801. self.fParameterList.append([3, self.fKnobRtMid])
  802. self.fParameterList.append([4, self.fKnobDamping])
  803. self.fParameterList.append([5, self.fKnobEq1Freq])
  804. self.fParameterList.append([6, self.fKnobEq1Gain])
  805. self.fParameterList.append([7, self.fKnobEq2Freq])
  806. self.fParameterList.append([8, self.fKnobEq2Gain])
  807. self.fParameterList.append([9, self.fKnobMix])
  808. # -------------------------------------------------------------
  809. self.ready()
  810. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  811. #------------------------------------------------------------------
  812. def getFixedHeight(self):
  813. return 79
  814. #------------------------------------------------------------------
  815. def paintEvent(self, event):
  816. AbstractPluginSlot.paintEvent(self, event)
  817. self.drawOutline()
  818. def resizeEvent(self, event):
  819. self.fKnobDelay.move(self.ui.w_revsect.x()+31, self.ui.w_revsect.y()+33)
  820. self.fKnobXover.move(self.ui.w_revsect.x()+93, self.ui.w_revsect.y()+18)
  821. self.fKnobRtLow.move(self.ui.w_revsect.x()+148, self.ui.w_revsect.y()+18)
  822. self.fKnobRtMid.move(self.ui.w_revsect.x()+208, self.ui.w_revsect.y()+18)
  823. self.fKnobDamping.move(self.ui.w_revsect.x()+268, self.ui.w_revsect.y()+18)
  824. self.fKnobEq1Freq.move(self.ui.w_eq1sect.x()+20, self.ui.w_eq1sect.y()+33)
  825. self.fKnobEq1Gain.move(self.ui.w_eq1sect.x()+69, self.ui.w_eq1sect.y()+18)
  826. self.fKnobEq2Freq.move(self.ui.w_eq2sect.x()+20, self.ui.w_eq2sect.y()+33)
  827. self.fKnobEq2Gain.move(self.ui.w_eq2sect.x()+69, self.ui.w_eq2sect.y()+18)
  828. self.fKnobMix.move(self.ui.w_ambmixsect.x()+24, self.ui.w_ambmixsect.y()+33)
  829. AbstractPluginSlot.resizeEvent(self, event)
  830. # ------------------------------------------------------------------------------------------------------------
  831. class PluginSlot_ZynFX(AbstractPluginSlot):
  832. def __init__(self, parent, pluginId):
  833. AbstractPluginSlot.__init__(self, parent, pluginId)
  834. self.ui = ui_carla_plugin_zynfx.Ui_PluginWidget()
  835. self.ui.setupUi(self)
  836. # -------------------------------------------------------------
  837. # Set-up GUI
  838. self.setStyleSheet("""
  839. QFrame#PluginWidget {
  840. background-image: url(:/bitmaps/background_zynfx.png);
  841. background-repeat: repeat-xy;
  842. border: 2px;
  843. }
  844. """)
  845. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  846. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  847. # -------------------------------------------------------------
  848. # Set-up parameters
  849. parameterCount = Carla.host.get_parameter_count(self.fPluginId) if Carla.host is not None else 0
  850. index = 0
  851. for i in range(parameterCount):
  852. paramInfo = Carla.host.get_parameter_info(self.fPluginId, i)
  853. paramData = Carla.host.get_parameter_data(self.fPluginId, i)
  854. paramRanges = Carla.host.get_parameter_ranges(self.fPluginId, i)
  855. if paramData['type'] != PARAMETER_INPUT:
  856. continue
  857. paramName = charPtrToString(paramInfo['name'])
  858. paramLow = paramName.lower()
  859. # real zyn fx plugins
  860. if self.fPluginInfo['label'] == "zynalienwah":
  861. if i == 0: paramName = "Freq"
  862. elif i == 1: paramName = "Rnd"
  863. elif i == 2: paramName = "L type" # combobox
  864. elif i == 3: paramName = "St.df"
  865. elif i == 5: paramName = "Fb"
  866. elif i == 7: paramName = "L/R"
  867. if self.fPluginInfo['label'] == "zynchorus":
  868. if i == 0: paramName = "Freq"
  869. elif i == 1: paramName = "Rnd"
  870. elif i == 2: paramName = "L type" # combobox
  871. elif i == 3: paramName = "St.df"
  872. elif i == 6: paramName = "Fb"
  873. elif i == 7: paramName = "L/R"
  874. elif i == 8: paramName = "Flngr" # button
  875. elif i == 9: paramName = "Subst" # button
  876. elif self.fPluginInfo['label'] == "zyndistortion":
  877. if i == 0: paramName = "LRc."
  878. elif i == 4: paramName = "Neg." # button
  879. elif i == 5: paramName = "LPF"
  880. elif i == 6: paramName = "HPF"
  881. elif i == 7: paramName = "St." # button
  882. elif i == 8: paramName = "PF" # button
  883. elif self.fPluginInfo['label'] == "zyndynamicfilter":
  884. if i == 0: paramName = "Freq"
  885. elif i == 1: paramName = "Rnd"
  886. elif i == 2: paramName = "L type" # combobox
  887. elif i == 3: paramName = "St.df"
  888. elif i == 4: paramName = "LfoD"
  889. elif i == 5: paramName = "A.S."
  890. elif i == 6: paramName = "A.Inv." # button
  891. elif i == 7: paramName = "A.M."
  892. elif self.fPluginInfo['label'] == "zynecho":
  893. if i == 1: paramName = "LRdl."
  894. elif i == 2: paramName = "LRc."
  895. elif i == 3: paramName = "Fb."
  896. elif i == 4: paramName = "Damp"
  897. elif self.fPluginInfo['label'] == "zynphaser":
  898. if i == 0: paramName = "Freq"
  899. elif i == 1: paramName = "Rnd"
  900. elif i == 2: paramName = "L type" # combobox
  901. elif i == 3: paramName = "St.df"
  902. elif i == 5: paramName = "Fb"
  903. elif i == 7: paramName = "L/R"
  904. elif i == 8: paramName = "Subst" # button
  905. elif i == 9: paramName = "Phase"
  906. elif i == 11: paramName = "Dist"
  907. elif self.fPluginInfo['label'] == "zynreverb":
  908. if i == 2: paramName = "I.delfb"
  909. elif i == 5: paramName = "LPF"
  910. elif i == 6: paramName = "HPF"
  911. elif i == 9: paramName = "R.S."
  912. elif i == 10: paramName = "I.del"
  913. #elif paramLow.find("damp"):
  914. #paramName = "Damp"
  915. #elif paramLow.find("frequency"):
  916. #paramName = "Freq"
  917. # Cut generic names
  918. #elif paramName == "Depth": paramName = "Dpth"
  919. #elif paramName == "Feedback": paramName = "Fb"
  920. #elif paramName == "L/R Cross": #paramName = "L/R"
  921. #elif paramName == "Random": paramName = "Rnd"
  922. widget = PixmapDial(self, i)
  923. widget.setPixmap(5)
  924. widget.setLabel(paramName)
  925. widget.setCustomPaint(PixmapDial.CUSTOM_PAINT_NO_GRADIENT)
  926. widget.setSingleStep(paramRanges['step']*1000)
  927. widget.setMinimum(paramRanges['min']*1000)
  928. widget.setMaximum(paramRanges['max']*1000)
  929. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  930. widget.setEnabled(False)
  931. self.ui.container.layout().insertWidget(index, widget)
  932. index += 1
  933. self.fParameterList.append([i, widget])
  934. # -------------------------------------------------------------
  935. # Set-up MIDI programs
  936. midiProgramCount = Carla.host.get_midi_program_count(self.fPluginId) if Carla.host is not None else 0
  937. if midiProgramCount > 0:
  938. self.ui.cb_presets.setEnabled(True)
  939. self.ui.label_presets.setEnabled(True)
  940. for i in range(midiProgramCount):
  941. mpData = Carla.host.get_midi_program_data(self.fPluginId, i)
  942. mpName = charPtrToString(mpData['name'])
  943. self.ui.cb_presets.addItem(mpName)
  944. self.fCurrentMidiProgram = Carla.host.get_current_midi_program_index(self.fPluginId)
  945. self.ui.cb_presets.setCurrentIndex(self.fCurrentMidiProgram)
  946. else:
  947. self.fCurrentMidiProgram = -1
  948. self.ui.cb_presets.setEnabled(False)
  949. self.ui.cb_presets.setVisible(False)
  950. self.ui.label_presets.setEnabled(False)
  951. self.ui.label_presets.setVisible(False)
  952. # -------------------------------------------------------------
  953. self.b_enable = self.ui.b_enable
  954. self.b_edit = self.ui.b_edit
  955. self.cb_presets = self.ui.cb_presets
  956. self.label_name = self.ui.label_name
  957. self.peak_in = self.ui.peak_in
  958. self.peak_out = self.ui.peak_out
  959. self.ready()
  960. self.peak_in.setOrientation(self.peak_in.VERTICAL)
  961. self.peak_out.setOrientation(self.peak_out.VERTICAL)
  962. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  963. self.ui.cb_presets.currentIndexChanged.connect(self.slot_midiProgramChanged)
  964. #------------------------------------------------------------------
  965. def getFixedHeight(self):
  966. return 70
  967. # ------------------------------------------------------------------------------------------------------------
  968. def createPluginSlot(parent, pluginId):
  969. pluginInfo = Carla.host.get_plugin_info(pluginId)
  970. pluginName = Carla.host.get_real_plugin_name(pluginId)
  971. pluginLabel = charPtrToString(pluginInfo['label'])
  972. uniqueId = int(pluginInfo['uniqueId'])
  973. #pluginMaker = charPtrToString(pluginInfo['maker'])
  974. #pluginIcon = charPtrToString(pluginInfo['iconName'])
  975. if pluginInfo['type'] == PLUGIN_INTERNAL:
  976. if pluginLabel.startswith("zyn") and pluginInfo['category'] != PLUGIN_CATEGORY_SYNTH:
  977. return PluginSlot_ZynFX(parent, pluginId)
  978. elif pluginInfo['type'] == PLUGIN_LADSPA:
  979. if (pluginLabel == "zita-reverb" and uniqueId == 3701) or (pluginLabel == "zita-reverb-amb" and uniqueId == 3702):
  980. return PluginSlot_ZitaRev(parent, pluginId)
  981. if pluginName.split(" ", 1)[0].lower() == "calf":
  982. return PluginSlot_Calf(parent, pluginId)
  983. return PluginSlot_BasicFX(parent, pluginId)
  984. return PluginSlot_Default(parent, pluginId)
  985. # ------------------------------------------------------------------------------------------------------------
  986. # Main Testing
  987. if __name__ == '__main__':
  988. from carla_style import CarlaApplication
  989. import resources_rc
  990. app = CarlaApplication("Carla-Skins")
  991. #gui = PluginSlot_BasicFX(None, 0)
  992. #gui = PluginSlot_Calf(None, 0)
  993. #gui = PluginSlot_Default(None, 0)
  994. #gui = PluginSlot_ZitaRev(None, 0)
  995. gui = PluginSlot_ZynFX(None, 0)
  996. gui.setSelected(True)
  997. gui.show()
  998. app.exec_()