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.

1697 lines
67KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla widgets code
  4. # Copyright (C) 2011-2013 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. try:
  20. from PyQt5.QtCore import pyqtSignal, pyqtSlot, QByteArray, QSettings
  21. from PyQt5.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
  22. from PyQt5.QtWidgets import QDialog, QFrame, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
  23. except:
  24. from PyQt4.QtCore import pyqtSignal, pyqtSlot, QByteArray, QSettings
  25. from PyQt4.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
  26. from PyQt4.QtGui import QDialog, QFrame, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
  27. # ------------------------------------------------------------------------------------------------------------
  28. # Imports (Custom)
  29. import ui_carla_about
  30. import ui_carla_edit
  31. import ui_carla_parameter
  32. import ui_carla_plugin
  33. from carla_shared import *
  34. # ------------------------------------------------------------------------------------------------------------
  35. # Carla GUI defines
  36. ICON_STATE_NULL = 0
  37. ICON_STATE_OFF = 1
  38. ICON_STATE_WAIT = 2
  39. ICON_STATE_ON = 3
  40. # ------------------------------------------------------------------------------------------------------------
  41. # Fake plugin info for easy testing
  42. gFakePluginInfo = {
  43. "type": PLUGIN_NONE,
  44. "category": PLUGIN_CATEGORY_SYNTH,
  45. "hints": PLUGIN_IS_SYNTH|PLUGIN_CAN_DRYWET|PLUGIN_CAN_VOLUME|PLUGIN_CAN_PANNING,
  46. "optionsAvailable": 0x1FF, # all
  47. "optionsEnabled": 0x1FF, # all
  48. "binary": "AwesoomeBinary.yeah",
  49. "name": "Awesoome Name",
  50. "label": "awesoomeLabel",
  51. "maker": "Awesoome Maker",
  52. "copyright": "Awesoome Copyright",
  53. "iconName": "plugin",
  54. "uniqueId": 0,
  55. "latency": 0
  56. }
  57. gFakeParamInfo = {
  58. 'hints': PARAMETER_IS_INPUT|PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE,
  59. 'name': "Parameter Name",
  60. 'unit': "",
  61. 'scalePoints': [],
  62. 'index': 0,
  63. 'default': 0.0,
  64. 'minimum': 0.0,
  65. 'maximum': 1.0,
  66. 'step': 0.01,
  67. 'stepSmall': 0.01,
  68. 'stepLarge': 0.01,
  69. 'midiCC': -1,
  70. 'midiChannel': 1,
  71. 'current': 0.0
  72. }
  73. gFakeCountInfo = {
  74. "ins": 0,
  75. "outs": 0,
  76. "total": 0
  77. }
  78. # ------------------------------------------------------------------------------------------------------------
  79. # Carla About dialog
  80. class CarlaAboutW(QDialog):
  81. def __init__(self, parent):
  82. QDialog.__init__(self, parent)
  83. self.ui = ui_carla_about.Ui_CarlaAboutW()
  84. self.ui.setupUi(self)
  85. if Carla.isControl:
  86. extraInfo = " - <b>%s</b>" % self.tr("OSC Bridge Version")
  87. elif Carla.isPlugin:
  88. extraInfo = " - <b>%s</b>" % self.tr("Plugin Version")
  89. else:
  90. extraInfo = ""
  91. self.ui.l_about.setText(self.tr(""
  92. "<br>Version %s"
  93. "<br>Carla is a Multi-Plugin Host for JACK%s.<br>"
  94. "<br>Copyright (C) 2011-2013 falkTX<br>"
  95. "" % (VERSION, extraInfo)))
  96. if Carla.isControl or Carla.isPlugin or Carla.host is None:
  97. self.ui.l_extended.hide()
  98. self.ui.tabWidget.removeTab(1)
  99. self.ui.tabWidget.removeTab(1)
  100. self.adjustSize()
  101. else:
  102. self.ui.l_extended.setText(Carla.host.get_complete_license_text())
  103. if Carla.host.is_engine_running():
  104. self.ui.le_osc_url_tcp.setText(Carla.host.get_host_osc_url_tcp())
  105. self.ui.le_osc_url_udp.setText(Carla.host.get_host_osc_url_udp())
  106. else:
  107. self.ui.le_osc_url_tcp.setText(self.tr("(Engine not running)"))
  108. self.ui.le_osc_url_udp.setText(self.tr("(Engine not running)"))
  109. self.ui.l_osc_cmds.setText(""
  110. " /set_active <i-value>\n"
  111. " /set_drywet <f-value>\n"
  112. " /set_volume <f-value>\n"
  113. " /set_balance_left <f-value>\n"
  114. " /set_balance_right <f-value>\n"
  115. " /set_panning <f-value>\n"
  116. " /set_parameter_value <i-index> <f-value>\n"
  117. " /set_parameter_midi_cc <i-index> <i-cc>\n"
  118. " /set_parameter_midi_channel <i-index> <i-channel>\n"
  119. " /set_program <i-index>\n"
  120. " /set_midi_program <i-index>\n"
  121. " /note_on <i-note> <i-velo>\n"
  122. " /note_off <i-note>\n"
  123. )
  124. self.ui.l_example.setText("/Carla/2/set_parameter_value 5 1.0")
  125. self.ui.l_example_help.setText("<i>(as in this example, \"2\" is the plugin number and \"5\" the parameter)</i>")
  126. self.ui.l_ladspa.setText(self.tr("Everything! (Including LRDF)"))
  127. self.ui.l_dssi.setText(self.tr("Everything! (Including CustomData/Chunks)"))
  128. self.ui.l_lv2.setText(self.tr("About 80&#37; complete (using custom extensions)<br/>"
  129. "Implemented Feature/Extensions:"
  130. "<ul>"
  131. "<li>http://lv2plug.in/ns/ext/atom</li>"
  132. "<li>http://lv2plug.in/ns/ext/buf-size</li>"
  133. "<li>http://lv2plug.in/ns/ext/data-access</li>"
  134. #"<li>http://lv2plug.in/ns/ext/dynmanifest</li>"
  135. "<li>http://lv2plug.in/ns/ext/event</li>"
  136. "<li>http://lv2plug.in/ns/ext/instance-access</li>"
  137. "<li>http://lv2plug.in/ns/ext/log</li>"
  138. "<li>http://lv2plug.in/ns/ext/midi</li>"
  139. #"<li>http://lv2plug.in/ns/ext/morph</li>"
  140. "<li>http://lv2plug.in/ns/ext/options</li>"
  141. "<li>http://lv2plug.in/ns/ext/parameters</li>"
  142. #"<li>http://lv2plug.in/ns/ext/patch</li>"
  143. #"<li>http://lv2plug.in/ns/ext/port-groups</li>"
  144. #"<li>http://lv2plug.in/ns/ext/port-props</li>"
  145. "<li>http://lv2plug.in/ns/ext/presets</li>"
  146. #"<li>http://lv2plug.in/ns/ext/resize-port</li>"
  147. "<li>http://lv2plug.in/ns/ext/state</li>"
  148. "<li>http://lv2plug.in/ns/ext/time</li>"
  149. "<li>http://lv2plug.in/ns/ext/uri-map</li>"
  150. "<li>http://lv2plug.in/ns/ext/urid</li>"
  151. #"<li>http://lv2plug.in/ns/ext/worker</li>"
  152. "<li>http://lv2plug.in/ns/extensions/ui</li>"
  153. "<li>http://lv2plug.in/ns/extensions/units</li>"
  154. "<li>http://kxstudio.sf.net/ns/lv2ext/external-ui</li>"
  155. "<li>http://kxstudio.sf.net/ns/lv2ext/programs</li>"
  156. "<li>http://kxstudio.sf.net/ns/lv2ext/rtmempool</li>"
  157. "<li>http://ll-plugins.nongnu.org/lv2/ext/midimap</li>"
  158. "<li>http://ll-plugins.nongnu.org/lv2/ext/miditype</li>"
  159. "</ul>"))
  160. self.ui.l_vst.setText(self.tr("<p>About 85&#37; complete (missing vst bank/presets and some minor stuff)</p>"))
  161. def done(self, r):
  162. QDialog.done(self, r)
  163. self.close()
  164. # ------------------------------------------------------------------------------------------------------------
  165. # Plugin Parameter
  166. class PluginParameter(QWidget):
  167. midiControlChanged = pyqtSignal(int, int)
  168. midiChannelChanged = pyqtSignal(int, int)
  169. valueChanged = pyqtSignal(int, float)
  170. def __init__(self, parent, pInfo, pluginId, tabIndex):
  171. QWidget.__init__(self, parent)
  172. self.ui = ui_carla_parameter.Ui_PluginParameter()
  173. self.ui.setupUi(self)
  174. # -------------------------------------------------------------
  175. # Internal stuff
  176. self.fMidiControl = -1
  177. self.fMidiChannel = 1
  178. self.fParameterId = pInfo['index']
  179. self.fPluginId = pluginId
  180. self.fTabIndex = tabIndex
  181. # -------------------------------------------------------------
  182. # Set-up GUI
  183. pType = pInfo['type']
  184. pHints = pInfo['hints']
  185. self.ui.label.setText(pInfo['name'])
  186. self.ui.widget.setName(pInfo['name'])
  187. self.ui.widget.setMinimum(pInfo['minimum'])
  188. self.ui.widget.setMaximum(pInfo['maximum'])
  189. self.ui.widget.setDefault(pInfo['default'])
  190. self.ui.widget.setValue(pInfo['current'], False)
  191. self.ui.widget.setLabel(pInfo['unit'])
  192. self.ui.widget.setStep(pInfo['step'])
  193. self.ui.widget.setStepSmall(pInfo['stepSmall'])
  194. self.ui.widget.setStepLarge(pInfo['stepLarge'])
  195. self.ui.widget.setScalePoints(pInfo['scalePoints'], bool(pHints & PARAMETER_USES_SCALEPOINTS))
  196. if not pHints & PARAMETER_IS_ENABLED:
  197. self.ui.label.setEnabled(False)
  198. self.ui.widget.setEnabled(False)
  199. self.ui.widget.setReadOnly(True)
  200. self.ui.sb_control.setEnabled(False)
  201. self.ui.sb_channel.setEnabled(False)
  202. elif not pHints & PARAMETER_IS_AUTOMABLE:
  203. self.ui.sb_control.setEnabled(False)
  204. self.ui.sb_channel.setEnabled(False)
  205. if pHints & PARAMETER_IS_READ_ONLY:
  206. self.ui.widget.setReadOnly(True)
  207. if pHints & PARAMETER_USES_CUSTOM_TEXT:
  208. self.ui.widget.setTextCallback(self._textCallBack)
  209. self.ui.widget.updateAll()
  210. self.setMidiControl(pInfo['midiCC'])
  211. self.setMidiChannel(pInfo['midiChannel'])
  212. # -------------------------------------------------------------
  213. # Set-up connections
  214. self.ui.sb_control.customContextMenuRequested.connect(self.slot_controlSpinboxCustomMenu)
  215. self.ui.sb_channel.customContextMenuRequested.connect(self.slot_channelSpinboxCustomMenu)
  216. self.ui.sb_control.valueChanged.connect(self.slot_controlSpinboxChanged)
  217. self.ui.sb_channel.valueChanged.connect(self.slot_channelSpinboxChanged)
  218. self.ui.widget.valueChanged.connect(self.slot_widgetValueChanged)
  219. # -------------------------------------------------------------
  220. def pluginId(self):
  221. return self.fPluginId
  222. def tabIndex(self):
  223. return self.fTabIndex
  224. def setDefault(self, value):
  225. self.ui.widget.setDefault(value)
  226. def setValue(self, value, send=True):
  227. self.ui.widget.setValue(value, send)
  228. def setMidiControl(self, control):
  229. self.fMidiControl = control
  230. self.ui.sb_control.blockSignals(True)
  231. self.ui.sb_control.setValue(control)
  232. self.ui.sb_control.blockSignals(False)
  233. def setMidiChannel(self, channel):
  234. self.fMidiChannel = channel
  235. self.ui.sb_channel.blockSignals(True)
  236. self.ui.sb_channel.setValue(channel)
  237. self.ui.sb_channel.blockSignals(False)
  238. def setLabelWidth(self, width):
  239. self.ui.label.setMinimumWidth(width)
  240. self.ui.label.setMaximumWidth(width)
  241. @pyqtSlot()
  242. def slot_controlSpinboxCustomMenu(self):
  243. menu = QMenu(self)
  244. actNone = menu.addAction(self.tr("None"))
  245. if self.fMidiControl == -1:
  246. actNone.setCheckable(True)
  247. actNone.setChecked(True)
  248. for cc in MIDI_CC_LIST:
  249. action = menu.addAction(cc)
  250. if self.fMidiControl != -1 and int(cc.split(" ")[0], 16) == self.fMidiControl:
  251. action.setCheckable(True)
  252. action.setChecked(True)
  253. actSel = menu.exec_(QCursor.pos())
  254. if not actSel:
  255. pass
  256. elif actSel == actNone:
  257. self.ui.sb_control.setValue(-1)
  258. else:
  259. selControlStr = actSel.text()
  260. selControl = int(selControlStr.split(" ")[0], 16)
  261. self.ui.sb_control.setValue(selControl)
  262. @pyqtSlot()
  263. def slot_channelSpinboxCustomMenu(self):
  264. menu = QMenu(self)
  265. for i in range(1, 16+1):
  266. action = menu.addAction("%i" % i)
  267. if self.fMidiChannel == i:
  268. action.setCheckable(True)
  269. action.setChecked(True)
  270. actSel = menu.exec_(QCursor.pos())
  271. if actSel:
  272. selChannel = int(actSel.text())
  273. self.ui.sb_channel.setValue(selChannel)
  274. @pyqtSlot(int)
  275. def slot_controlSpinboxChanged(self, control):
  276. if self.fMidiControl != control:
  277. self.midiControlChanged.emit(self.fParameterId, control)
  278. self.fMidiControl = control
  279. @pyqtSlot(int)
  280. def slot_channelSpinboxChanged(self, channel):
  281. if self.fMidiChannel != channel:
  282. self.midiChannelChanged.emit(self.fParameterId, channel)
  283. self.fMidiChannel = channel
  284. @pyqtSlot(float)
  285. def slot_widgetValueChanged(self, value):
  286. self.valueChanged.emit(self.fParameterId, value)
  287. def _textCallBack(self):
  288. return Carla.host.get_parameter_text(self.fPluginId, self.fParameterId)
  289. # ------------------------------------------------------------------------------------------------------------
  290. # Plugin Editor (Built-in)
  291. class PluginEdit(QDialog):
  292. ParamsPerPage = 8
  293. def __init__(self, parent, pluginId):
  294. QDialog.__init__(self, Carla.gui)
  295. self.ui = ui_carla_edit.Ui_PluginEdit()
  296. self.ui.setupUi(self)
  297. # -------------------------------------------------------------
  298. # Internal stuff
  299. self.fGeometry = QByteArray()
  300. self.fPluginId = pluginId
  301. self.fPuginInfo = None
  302. self.fRealParent = parent
  303. self.fCurrentProgram = -1
  304. self.fCurrentMidiProgram = -1
  305. self.fCurrentStateFilename = None
  306. self.fControlChannel = 0
  307. self.fScrollAreaSetup = False
  308. self.fParameterCount = 0
  309. self.fParameterList = [] # (type, id, widget)
  310. self.fParametersToUpdate = [] # (id, value)
  311. self.fPlayingNotes = [] # (channel, note)
  312. self.fTabIconOff = QIcon(":/bitmaps/led_off.png")
  313. self.fTabIconOn = QIcon(":/bitmaps/led_yellow.png")
  314. self.fTabIconCount = 0
  315. self.fTabIconTimers = []
  316. # -------------------------------------------------------------
  317. # Set-up GUI
  318. self.ui.dial_drywet.setCustomPaint(self.ui.dial_drywet.CUSTOM_PAINT_CARLA_WET)
  319. self.ui.dial_drywet.setPixmap(3)
  320. self.ui.dial_drywet.setLabel("Dry/Wet")
  321. self.ui.dial_vol.setCustomPaint(self.ui.dial_vol.CUSTOM_PAINT_CARLA_VOL)
  322. self.ui.dial_vol.setPixmap(3)
  323. self.ui.dial_vol.setLabel("Volume")
  324. self.ui.dial_b_left.setCustomPaint(self.ui.dial_b_left.CUSTOM_PAINT_CARLA_L)
  325. self.ui.dial_b_left.setPixmap(4)
  326. self.ui.dial_b_left.setLabel("L")
  327. self.ui.dial_b_right.setCustomPaint(self.ui.dial_b_right.CUSTOM_PAINT_CARLA_R)
  328. self.ui.dial_b_right.setPixmap(4)
  329. self.ui.dial_b_right.setLabel("R")
  330. self.ui.dial_pan.setCustomPaint(self.ui.dial_b_right.CUSTOM_PAINT_CARLA_R) # FIXME
  331. self.ui.dial_pan.setPixmap(4)
  332. self.ui.dial_pan.setLabel("Pan")
  333. self.ui.keyboard.setMode(self.ui.keyboard.HORIZONTAL)
  334. self.ui.keyboard.setOctaves(10)
  335. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  336. self.ui.scrollArea.ensureVisible(self.ui.keyboard.width() / 3, 0)
  337. self.ui.scrollArea.setEnabled(False)
  338. self.ui.scrollArea.setVisible(False)
  339. self.reloadAll()
  340. # -------------------------------------------------------------
  341. # Set-up connections
  342. self.finished.connect(self.slot_finished)
  343. self.ui.ch_fixed_buffer.clicked.connect(self.slot_optionChanged)
  344. self.ui.ch_force_stereo.clicked.connect(self.slot_optionChanged)
  345. self.ui.ch_map_program_changes.clicked.connect(self.slot_optionChanged)
  346. self.ui.ch_use_chunks.clicked.connect(self.slot_optionChanged)
  347. self.ui.ch_send_control_changes.clicked.connect(self.slot_optionChanged)
  348. self.ui.ch_send_channel_pressure.clicked.connect(self.slot_optionChanged)
  349. self.ui.ch_send_note_aftertouch.clicked.connect(self.slot_optionChanged)
  350. self.ui.ch_send_pitchbend.clicked.connect(self.slot_optionChanged)
  351. self.ui.ch_send_all_sound_off.clicked.connect(self.slot_optionChanged)
  352. self.ui.dial_drywet.valueChanged.connect(self.slot_dryWetChanged)
  353. self.ui.dial_vol.valueChanged.connect(self.slot_volumeChanged)
  354. self.ui.dial_b_left.valueChanged.connect(self.slot_balanceLeftChanged)
  355. self.ui.dial_b_right.valueChanged.connect(self.slot_balanceRightChanged)
  356. self.ui.sb_ctrl_channel.valueChanged.connect(self.slot_ctrlChannelChanged)
  357. self.ui.dial_drywet.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  358. self.ui.dial_vol.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  359. self.ui.dial_b_left.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  360. self.ui.dial_b_right.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  361. self.ui.sb_ctrl_channel.customContextMenuRequested.connect(self.slot_channelCustomMenu)
  362. self.ui.keyboard.noteOn.connect(self.slot_noteOn)
  363. self.ui.keyboard.noteOff.connect(self.slot_noteOff)
  364. self.ui.cb_programs.currentIndexChanged.connect(self.slot_programIndexChanged)
  365. self.ui.cb_midi_programs.currentIndexChanged.connect(self.slot_midiProgramIndexChanged)
  366. if Carla.isLocal:
  367. self.ui.b_save_state.clicked.connect(self.slot_stateSave)
  368. self.ui.b_load_state.clicked.connect(self.slot_stateLoad)
  369. else:
  370. self.ui.b_load_state.setEnabled(False)
  371. self.ui.b_save_state.setEnabled(False)
  372. # -------------------------------------------------------------
  373. def reloadAll(self):
  374. if Carla.host is not None:
  375. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId)
  376. self.fPluginInfo['binary'] = cString(self.fPluginInfo['binary'])
  377. self.fPluginInfo['name'] = cString(self.fPluginInfo['name'])
  378. self.fPluginInfo['label'] = cString(self.fPluginInfo['label'])
  379. self.fPluginInfo['maker'] = cString(self.fPluginInfo['maker'])
  380. self.fPluginInfo['copyright'] = cString(self.fPluginInfo['copyright'])
  381. self.fPluginInfo['iconName'] = cString(self.fPluginInfo['iconName'])
  382. if not Carla.isLocal:
  383. self.fPluginInfo['hints'] &= ~PLUGIN_HAS_GUI
  384. else:
  385. self.fPluginInfo = gFakePluginInfo
  386. self.reloadInfo()
  387. self.reloadParameters()
  388. self.reloadPrograms()
  389. if self.fPluginInfo['type'] == PLUGIN_LV2:
  390. self.ui.b_save_state.setEnabled(False)
  391. if not self.ui.scrollArea.isEnabled():
  392. self.resize(self.width(), self.height()-self.ui.scrollArea.height())
  393. def reloadInfo(self):
  394. if Carla.host is not None:
  395. pluginName = cString(Carla.host.get_real_plugin_name(self.fPluginId))
  396. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  397. midiCountInfo = Carla.host.get_midi_port_count_info(self.fPluginId)
  398. paramCountInfo = Carla.host.get_parameter_count_info(self.fPluginId)
  399. else:
  400. pluginName = ""
  401. audioCountInfo = gFakeCountInfo
  402. midiCountInfo = gFakeCountInfo
  403. paramCountInfo = gFakeCountInfo
  404. pluginType = self.fPluginInfo['type']
  405. pluginHints = self.fPluginInfo['hints']
  406. if pluginType == PLUGIN_INTERNAL:
  407. self.ui.le_type.setText(self.tr("Internal"))
  408. elif pluginType == PLUGIN_LADSPA:
  409. self.ui.le_type.setText("LADSPA")
  410. elif pluginType == PLUGIN_DSSI:
  411. self.ui.le_type.setText("DSSI")
  412. elif pluginType == PLUGIN_LV2:
  413. self.ui.le_type.setText("LV2")
  414. elif pluginType == PLUGIN_VST:
  415. self.ui.le_type.setText("VST")
  416. elif pluginType == PLUGIN_AU:
  417. self.ui.le_type.setText("AU")
  418. elif pluginType == PLUGIN_CSOUND:
  419. self.ui.le_type.setText("CSOUND")
  420. elif pluginType == PLUGIN_GIG:
  421. self.ui.le_type.setText("GIG")
  422. elif pluginType == PLUGIN_SF2:
  423. self.ui.le_type.setText("SF2")
  424. elif pluginType == PLUGIN_SFZ:
  425. self.ui.le_type.setText("SFZ")
  426. else:
  427. self.ui.le_type.setText(self.tr("Unknown"))
  428. if pluginName:
  429. self.ui.label_name.setEnabled(True)
  430. self.ui.le_name.setEnabled(True)
  431. self.ui.le_name.setText(pluginName)
  432. self.ui.le_name.setToolTip(pluginName)
  433. else:
  434. self.ui.label_name.setEnabled(False)
  435. self.ui.le_name.setEnabled(False)
  436. self.ui.le_name.setText("")
  437. self.ui.le_name.setToolTip("")
  438. if self.fPluginInfo['label']:
  439. self.ui.label_label.setEnabled(True)
  440. self.ui.le_label.setEnabled(True)
  441. self.ui.le_label.setText(self.fPluginInfo['label'])
  442. self.ui.le_label.setToolTip(self.fPluginInfo['label'])
  443. else:
  444. self.ui.label_label.setEnabled(False)
  445. self.ui.le_label.setEnabled(False)
  446. self.ui.le_label.setText("")
  447. self.ui.le_label.setToolTip("")
  448. if self.fPluginInfo['maker']:
  449. self.ui.label_maker.setEnabled(True)
  450. self.ui.le_maker.setEnabled(True)
  451. self.ui.le_maker.setText(self.fPluginInfo['maker'])
  452. self.ui.le_maker.setToolTip(self.fPluginInfo['maker'])
  453. else:
  454. self.ui.label_maker.setEnabled(False)
  455. self.ui.le_maker.setEnabled(False)
  456. self.ui.le_maker.setText("")
  457. self.ui.le_maker.setToolTip("")
  458. if self.fPluginInfo['copyright']:
  459. self.ui.label_copyright.setEnabled(True)
  460. self.ui.le_copyright.setEnabled(True)
  461. self.ui.le_copyright.setText(self.fPluginInfo['copyright'])
  462. self.ui.le_copyright.setToolTip(self.fPluginInfo['copyright'])
  463. else:
  464. self.ui.label_copyright.setEnabled(False)
  465. self.ui.le_copyright.setEnabled(False)
  466. self.ui.le_copyright.setText("")
  467. self.ui.le_copyright.setToolTip("")
  468. if self.fPluginInfo['uniqueId'] != 0:
  469. self.ui.label_unique_id.setEnabled(True)
  470. self.ui.le_unique_id.setEnabled(True)
  471. self.ui.le_unique_id.setText(str(self.fPluginInfo['uniqueId']))
  472. self.ui.le_unique_id.setToolTip(str(self.fPluginInfo['uniqueId']))
  473. else:
  474. self.ui.label_unique_id.setEnabled(False)
  475. self.ui.le_unique_id.setEnabled(False)
  476. self.ui.le_unique_id.setText("")
  477. self.ui.le_unique_id.setToolTip("")
  478. self.ui.label_plugin.setText("\n%s\n" % self.fPluginInfo['name'])
  479. self.setWindowTitle(self.fPluginInfo['name'])
  480. self.ui.dial_drywet.setEnabled(pluginHints & PLUGIN_CAN_DRYWET)
  481. self.ui.dial_vol.setEnabled(pluginHints & PLUGIN_CAN_VOLUME)
  482. self.ui.dial_b_left.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  483. self.ui.dial_b_right.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  484. self.ui.dial_pan.setEnabled(pluginHints & PLUGIN_CAN_PANNING)
  485. self.ui.ch_fixed_buffer.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FIXED_BUFFERS)
  486. self.ui.ch_fixed_buffer.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FIXED_BUFFERS)
  487. self.ui.ch_force_stereo.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FORCE_STEREO)
  488. self.ui.ch_force_stereo.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FORCE_STEREO)
  489. self.ui.ch_map_program_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  490. self.ui.ch_map_program_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  491. self.ui.ch_use_chunks.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_USE_CHUNKS)
  492. self.ui.ch_use_chunks.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_USE_CHUNKS)
  493. self.ui.ch_send_control_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  494. self.ui.ch_send_control_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  495. self.ui.ch_send_channel_pressure.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  496. self.ui.ch_send_channel_pressure.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  497. self.ui.ch_send_note_aftertouch.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  498. self.ui.ch_send_note_aftertouch.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  499. self.ui.ch_send_pitchbend.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PITCHBEND)
  500. self.ui.ch_send_pitchbend.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_PITCHBEND)
  501. self.ui.ch_send_all_sound_off.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  502. self.ui.ch_send_all_sound_off.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  503. if self.fPluginInfo['type'] != PLUGIN_VST:
  504. self.ui.sw_programs.setCurrentIndex(1)
  505. # Show/hide keyboard
  506. showKeyboard = (self.fPluginInfo['category'] == PLUGIN_CATEGORY_SYNTH or midiCountInfo['ins'] > 0 < midiCountInfo['outs'])
  507. self.ui.scrollArea.setEnabled(showKeyboard)
  508. self.ui.scrollArea.setVisible(showKeyboard)
  509. # Force-Update parent for new hints
  510. if self.fRealParent:
  511. self.fRealParent.recheckPluginHints(pluginHints)
  512. def reloadParameters(self):
  513. # Reset
  514. self.fParameterCount = 0
  515. self.fParameterList = []
  516. self.fParametersToUpdate = []
  517. self.fTabIconCount = 0
  518. self.fTabIconTimers = []
  519. # Remove all previous parameters
  520. for x in range(self.ui.tabWidget.count()-1):
  521. self.ui.tabWidget.widget(1).deleteLater()
  522. self.ui.tabWidget.removeTab(1)
  523. if Carla.host is None:
  524. paramFakeListFull = []
  525. paramFakeList = []
  526. paramFakeWidth = QFontMetrics(self.font()).width(gFakeParamInfo['name'])
  527. paramFakeList.append(gFakeParamInfo)
  528. paramFakeListFull.append((paramFakeList, paramFakeWidth))
  529. self._createParameterWidgets(PARAMETER_INPUT, paramFakeListFull, self.tr("Parameters"))
  530. return
  531. parameterCount = Carla.host.get_parameter_count(self.fPluginId)
  532. if parameterCount <= 0:
  533. pass
  534. elif parameterCount <= Carla.maxParameters:
  535. paramInputListFull = []
  536. paramOutputListFull = []
  537. paramInputList = [] # ([params], width)
  538. paramInputWidth = 0
  539. paramOutputList = [] # ([params], width)
  540. paramOutputWidth = 0
  541. for i in range(parameterCount):
  542. paramInfo = Carla.host.get_parameter_info(self.fPluginId, i)
  543. paramData = Carla.host.get_parameter_data(self.fPluginId, i)
  544. paramRanges = Carla.host.get_parameter_ranges(self.fPluginId, i)
  545. paramValue = Carla.host.get_current_parameter_value(self.fPluginId, i)
  546. if paramData['type'] not in (PARAMETER_INPUT, PARAMETER_OUTPUT):
  547. continue
  548. parameter = {
  549. 'type': paramData['type'],
  550. 'hints': paramData['hints'],
  551. 'name': cString(paramInfo['name']),
  552. 'unit': cString(paramInfo['unit']),
  553. 'scalePoints': [],
  554. 'index': paramData['index'],
  555. 'default': paramRanges['def'],
  556. 'minimum': paramRanges['min'],
  557. 'maximum': paramRanges['max'],
  558. 'step': paramRanges['step'],
  559. 'stepSmall': paramRanges['stepSmall'],
  560. 'stepLarge': paramRanges['stepLarge'],
  561. 'midiCC': paramData['midiCC'],
  562. 'midiChannel': paramData['midiChannel']+1,
  563. 'current': paramValue
  564. }
  565. for j in range(paramInfo['scalePointCount']):
  566. scalePointInfo = Carla.host.get_parameter_scalepoint_info(self.fPluginId, i, j)
  567. parameter['scalePoints'].append({
  568. 'value': scalePointInfo['value'],
  569. 'label': cString(scalePointInfo['label'])
  570. })
  571. #parameter['name'] = parameter['name'][:30] + (parameter['name'][30:] and "...")
  572. # -----------------------------------------------------------------
  573. # Get width values, in packs of 10
  574. if parameter['type'] == PARAMETER_INPUT:
  575. paramInputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  576. if paramInputWidthTMP > paramInputWidth:
  577. paramInputWidth = paramInputWidthTMP
  578. paramInputList.append(parameter)
  579. if len(paramInputList) == self.ParamsPerPage:
  580. paramInputListFull.append((paramInputList, paramInputWidth))
  581. paramInputList = []
  582. paramInputWidth = 0
  583. else:
  584. paramOutputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  585. if paramOutputWidthTMP > paramOutputWidth:
  586. paramOutputWidth = paramOutputWidthTMP
  587. paramOutputList.append(parameter)
  588. if len(paramOutputList) == self.ParamsPerPage:
  589. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  590. paramOutputList = []
  591. paramOutputWidth = 0
  592. # for i in range(parameterCount)
  593. else:
  594. # Final page width values
  595. if 0 < len(paramInputList) < 10:
  596. paramInputListFull.append((paramInputList, paramInputWidth))
  597. if 0 < len(paramOutputList) < 10:
  598. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  599. # -----------------------------------------------------------------
  600. # Create parameter tabs + widgets
  601. self._createParameterWidgets(PARAMETER_INPUT, paramInputListFull, self.tr("Parameters"))
  602. self._createParameterWidgets(PARAMETER_OUTPUT, paramOutputListFull, self.tr("Outputs"))
  603. else: # > Carla.maxParameters
  604. fakeName = self.tr("This plugin has too many parameters to display here!")
  605. paramFakeListFull = []
  606. paramFakeList = []
  607. paramFakeWidth = QFontMetrics(self.font()).width(fakeName)
  608. parameter = {
  609. 'type': PARAMETER_UNKNOWN,
  610. 'hints': 0,
  611. 'name': fakeName,
  612. 'unit': "",
  613. 'scalePoints': [],
  614. 'index': 0,
  615. 'default': 0.0,
  616. 'minimum': 0.0,
  617. 'maximum': 0.0,
  618. 'step': 0.0,
  619. 'stepSmall': 0.0,
  620. 'stepLarge': 0.0,
  621. 'midiCC': -1,
  622. 'midiChannel': 1,
  623. 'current': 0.0
  624. }
  625. paramFakeList.append(parameter)
  626. paramFakeListFull.append((paramFakeList, paramFakeWidth))
  627. self._createParameterWidgets(PARAMETER_UNKNOWN, paramFakeListFull, self.tr("Information"))
  628. def reloadPrograms(self):
  629. # Programs
  630. self.ui.cb_programs.blockSignals(True)
  631. self.ui.cb_programs.clear()
  632. programCount = Carla.host.get_program_count(self.fPluginId) if Carla.host is not None else 0
  633. if programCount > 0:
  634. self.ui.cb_programs.setEnabled(True)
  635. self.ui.label_programs.setEnabled(True)
  636. for i in range(programCount):
  637. pName = cString(Carla.host.get_program_name(self.fPluginId, i))
  638. #pName = pName[:40] + (pName[40:] and "...")
  639. self.ui.cb_programs.addItem(pName)
  640. self.fCurrentProgram = Carla.host.get_current_program_index(self.fPluginId)
  641. self.ui.cb_programs.setCurrentIndex(self.fCurrentProgram)
  642. else:
  643. self.fCurrentProgram = -1
  644. self.ui.cb_programs.setEnabled(False)
  645. self.ui.label_programs.setEnabled(False)
  646. self.ui.cb_programs.blockSignals(False)
  647. # MIDI Programs
  648. self.ui.cb_midi_programs.blockSignals(True)
  649. self.ui.cb_midi_programs.clear()
  650. midiProgramCount = Carla.host.get_midi_program_count(self.fPluginId) if Carla.host is not None else 0
  651. if midiProgramCount > 0:
  652. self.ui.cb_midi_programs.setEnabled(True)
  653. self.ui.label_midi_programs.setEnabled(True)
  654. for i in range(midiProgramCount):
  655. mpData = Carla.host.get_midi_program_data(self.fPluginId, i)
  656. mpBank = int(mpData['bank'])
  657. mpProg = int(mpData['program'])
  658. mpName = cString(mpData['name'])
  659. #mpName = mpName[:40] + (mpName[40:] and "...")
  660. self.ui.cb_midi_programs.addItem("%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  661. self.fCurrentMidiProgram = Carla.host.get_current_midi_program_index(self.fPluginId)
  662. self.ui.cb_midi_programs.setCurrentIndex(self.fCurrentMidiProgram)
  663. else:
  664. self.fCurrentMidiProgram = -1
  665. self.ui.cb_midi_programs.setEnabled(False)
  666. self.ui.label_midi_programs.setEnabled(False)
  667. self.ui.cb_midi_programs.blockSignals(False)
  668. self.ui.sw_programs.setEnabled(programCount > 0 or midiProgramCount > 0)
  669. if self.fPluginInfo['type'] == PLUGIN_LV2:
  670. self.ui.b_load_state.setEnabled(programCount > 0)
  671. def updateInfo(self):
  672. # Update current program text
  673. if self.ui.cb_programs.count() > 0:
  674. pIndex = self.ui.cb_programs.currentIndex()
  675. pName = cString(Carla.host.get_program_name(self.fPluginId, pIndex))
  676. #pName = pName[:40] + (pName[40:] and "...")
  677. self.ui.cb_programs.setItemText(pIndex, pName)
  678. # Update current midi program text
  679. if self.ui.cb_midi_programs.count() > 0:
  680. mpIndex = self.ui.cb_midi_programs.currentIndex()
  681. mpData = Carla.host.get_midi_program_data(self.fPluginId, mpIndex)
  682. mpBank = int(mpData['bank'])
  683. mpProg = int(mpData['program'])
  684. mpName = cString(mpData['name'])
  685. #mpName = mpName[:40] + (mpName[40:] and "...")
  686. self.ui.cb_midi_programs.setItemText(mpIndex, "%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  687. # Update all parameter values
  688. for paramType, paramId, paramWidget in self.fParameterList:
  689. paramWidget.setValue(Carla.host.get_current_parameter_value(self.fPluginId, paramId), False)
  690. paramWidget.update()
  691. self.fParametersToUpdate = []
  692. def clearNotes(self):
  693. self.fPlayingNotes = []
  694. self.ui.keyboard.allNotesOff()
  695. def setName(self, name):
  696. self.ui.label_plugin.setText("\n%s\n" % name)
  697. self.setWindowTitle(name)
  698. def setParameterValue(self, parameterId, value):
  699. for paramItem in self.fParametersToUpdate:
  700. if paramItem[0] == parameterId:
  701. paramItem[1] = value
  702. break
  703. else:
  704. self.fParametersToUpdate.append([parameterId, value])
  705. def setParameterDefault(self, parameterId, value):
  706. for paramType, paramId, paramWidget in self.fParameterList:
  707. if paramId == parameterId:
  708. paramWidget.setDefault(value)
  709. break
  710. def setParameterMidiControl(self, parameterId, control):
  711. for paramType, paramId, paramWidget in self.fParameterList:
  712. if paramId == parameterId:
  713. paramWidget.setMidiControl(control)
  714. break
  715. def setParameterMidiChannel(self, parameterId, channel):
  716. for paramType, paramId, paramWidget in self.fParameterList:
  717. if paramId == parameterId:
  718. paramWidget.setMidiChannel(channel+1)
  719. break
  720. def setProgram(self, index):
  721. self.ui.cb_programs.blockSignals(True)
  722. self.ui.cb_programs.setCurrentIndex(index)
  723. self.ui.cb_programs.blockSignals(False)
  724. def setMidiProgram(self, index):
  725. self.ui.cb_midi_programs.blockSignals(True)
  726. self.ui.cb_midi_programs.setCurrentIndex(index)
  727. self.ui.cb_midi_programs.blockSignals(False)
  728. def sendNoteOn(self, channel, note):
  729. if self.fControlChannel == channel:
  730. self.ui.keyboard.sendNoteOn(note, False)
  731. playItem = (channel, note)
  732. if playItem not in self.fPlayingNotes:
  733. self.fPlayingNotes.append(playItem)
  734. return bool(len(self.fPlayingNotes) == 1)
  735. def sendNoteOff(self, channel, note):
  736. if self.fControlChannel == channel:
  737. self.ui.keyboard.sendNoteOff(note, False)
  738. playItem = (channel, note)
  739. if playItem in self.fPlayingNotes:
  740. self.fPlayingNotes.remove(playItem)
  741. return bool(len(self.fPlayingNotes) == 0)
  742. def setVisible(self, yesNo):
  743. if yesNo:
  744. if not self.fGeometry.isNull():
  745. self.restoreGeometry(self.fGeometry)
  746. else:
  747. self.fGeometry = self.saveGeometry()
  748. QDialog.setVisible(self, yesNo)
  749. def idleSlow(self):
  750. # Check Tab icons
  751. for i in range(len(self.fTabIconTimers)):
  752. if self.fTabIconTimers[i] == ICON_STATE_ON:
  753. self.fTabIconTimers[i] = ICON_STATE_WAIT
  754. elif self.fTabIconTimers[i] == ICON_STATE_WAIT:
  755. self.fTabIconTimers[i] = ICON_STATE_OFF
  756. elif self.fTabIconTimers[i] == ICON_STATE_OFF:
  757. self.fTabIconTimers[i] = ICON_STATE_NULL
  758. self.ui.tabWidget.setTabIcon(i+1, self.fTabIconOff)
  759. # Check parameters needing update
  760. for index, value in self.fParametersToUpdate:
  761. if index == PARAMETER_DRYWET:
  762. self.ui.dial_drywet.blockSignals(True)
  763. self.ui.dial_drywet.setValue(value * 1000)
  764. self.ui.dial_drywet.blockSignals(False)
  765. elif index == PARAMETER_VOLUME:
  766. self.ui.dial_vol.blockSignals(True)
  767. self.ui.dial_vol.setValue(value * 1000)
  768. self.ui.dial_vol.blockSignals(False)
  769. elif index == PARAMETER_BALANCE_LEFT:
  770. self.ui.dial_b_left.blockSignals(True)
  771. self.ui.dial_b_left.setValue(value * 1000)
  772. self.ui.dial_b_left.blockSignals(False)
  773. elif index == PARAMETER_BALANCE_RIGHT:
  774. self.ui.dial_b_right.blockSignals(True)
  775. self.ui.dial_b_right.setValue(value * 1000)
  776. self.ui.dial_b_right.blockSignals(False)
  777. #elif index == PARAMETER_PANNING:
  778. #self.ui.dial_pan.blockSignals(True)
  779. #self.ui.dial_pan.setValue(value * 1000, True, False)
  780. #self.ui.dial_pan.blockSignals(False)
  781. elif index == PARAMETER_CTRL_CHANNEL:
  782. self.fControlChannel = int(value)
  783. self.ui.sb_ctrl_channel.blockSignals(True)
  784. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  785. self.ui.sb_ctrl_channel.blockSignals(False)
  786. self.ui.keyboard.allNotesOff()
  787. self._updateCtrlMidiProgram()
  788. elif index >= 0:
  789. for paramType, paramId, paramWidget in self.fParameterList:
  790. if paramId != index:
  791. continue
  792. paramWidget.setValue(value, False)
  793. if paramType == PARAMETER_INPUT:
  794. tabIndex = paramWidget.tabIndex()
  795. if self.fTabIconTimers[tabIndex-1] == ICON_STATE_NULL:
  796. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOn)
  797. self.fTabIconTimers[tabIndex-1] = ICON_STATE_ON
  798. break
  799. # Clear all parameters
  800. self.fParametersToUpdate = []
  801. # Update parameter outputs
  802. for paramType, paramId, paramWidget in self.fParameterList:
  803. if paramType == PARAMETER_OUTPUT:
  804. value = Carla.host.get_current_parameter_value(self.fPluginId, paramId)
  805. paramWidget.setValue(value, False)
  806. @pyqtSlot()
  807. def slot_stateSave(self):
  808. if self.fPluginInfo['type'] == PLUGIN_LV2:
  809. # TODO
  810. return
  811. if self.fCurrentStateFilename:
  812. askTry = QMessageBox.question(self, self.tr("Overwrite?"), self.tr("Overwrite previously created file?"), QMessageBox.Ok|QMessageBox.Cancel)
  813. if askTry == QMessageBox.Ok:
  814. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  815. return
  816. self.fCurrentStateFilename = None
  817. fileFilter = self.tr("Carla State File (*.carxs)")
  818. filenameTry = QFileDialog.getSaveFileName(self, self.tr("Save Plugin State File"), filter=fileFilter)
  819. if filenameTry:
  820. if not filenameTry.lower().endswith(".carxs"):
  821. filenameTry += ".carxs"
  822. self.fCurrentStateFilename = filenameTry
  823. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  824. @pyqtSlot()
  825. def slot_stateLoad(self):
  826. if self.fPluginInfo['type'] == PLUGIN_LV2:
  827. presetList = []
  828. for i in range(Carla.host.get_program_count(self.fPluginId)):
  829. presetList.append("%03i - %s" % (i+1, cString(Carla.host.get_program_name(self.fPluginId, i))))
  830. ret = QInputDialog.getItem(self, self.tr("Open LV2 Preset"), self.tr("Select an LV2 Preset:"), presetList, 0, False)
  831. if ret[1]:
  832. index = int(ret[0].split(" - ", 1)[0])-1
  833. Carla.host.set_midi_program(self.fPluginId, -1)
  834. Carla.host.set_program(self.fPluginId, index)
  835. self.setMidiProgram(-1)
  836. return
  837. fileFilter = self.tr("Carla State File (*.carxs)")
  838. filenameTry = QFileDialog.getOpenFileName(self, self.tr("Open Plugin State File"), filter=fileFilter)
  839. if filenameTry:
  840. self.fCurrentStateFilename = filenameTry
  841. Carla.host.load_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  842. @pyqtSlot(bool)
  843. def slot_optionChanged(self, clicked):
  844. sender = self.sender()
  845. if sender == self.ui.ch_fixed_buffer:
  846. option = PLUGIN_OPTION_FIXED_BUFFERS
  847. elif sender == self.ui.ch_force_stereo:
  848. option = PLUGIN_OPTION_FORCE_STEREO
  849. elif sender == self.ui.ch_map_program_changes:
  850. option = PLUGIN_OPTION_MAP_PROGRAM_CHANGES
  851. elif sender == self.ui.ch_use_chunks:
  852. option = PLUGIN_OPTION_USE_CHUNKS
  853. elif sender == self.ui.ch_send_control_changes:
  854. option = PLUGIN_OPTION_SEND_CONTROL_CHANGES
  855. elif sender == self.ui.ch_send_channel_pressure:
  856. option = PLUGIN_OPTION_SEND_CHANNEL_PRESSURE
  857. elif sender == self.ui.ch_send_note_aftertouch:
  858. option = PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH
  859. elif sender == self.ui.ch_send_pitchbend:
  860. option = PLUGIN_OPTION_SEND_PITCHBEND
  861. elif sender == self.ui.ch_send_all_sound_off:
  862. option = PLUGIN_OPTION_SEND_ALL_SOUND_OFF
  863. else:
  864. return
  865. Carla.host.set_option(self.fPluginId, option, clicked)
  866. @pyqtSlot(int)
  867. def slot_dryWetChanged(self, value):
  868. Carla.host.set_drywet(self.fPluginId, float(value)/1000)
  869. @pyqtSlot(int)
  870. def slot_volumeChanged(self, value):
  871. Carla.host.set_volume(self.fPluginId, float(value)/1000)
  872. @pyqtSlot(int)
  873. def slot_balanceLeftChanged(self, value):
  874. Carla.host.set_balance_left(self.fPluginId, float(value)/1000)
  875. @pyqtSlot(int)
  876. def slot_balanceRightChanged(self, value):
  877. Carla.host.set_balance_right(self.fPluginId, float(value)/1000)
  878. @pyqtSlot(int)
  879. def slot_panningChanged(self, value):
  880. Carla.host.set_panning(self.fPluginId, float(value)/1000)
  881. @pyqtSlot(int)
  882. def slot_ctrlChannelChanged(self, value):
  883. self.fControlChannel = value-1
  884. Carla.host.set_ctrl_channel(self.fPluginId, self.fControlChannel)
  885. self.ui.keyboard.allNotesOff()
  886. self._updateCtrlMidiProgram()
  887. @pyqtSlot(int, float)
  888. def slot_parameterValueChanged(self, parameterId, value):
  889. Carla.host.set_parameter_value(self.fPluginId, parameterId, value)
  890. @pyqtSlot(int, int)
  891. def slot_parameterMidiControlChanged(self, parameterId, control):
  892. Carla.host.set_parameter_midi_cc(self.fPluginId, parameterId, control)
  893. @pyqtSlot(int, int)
  894. def slot_parameterMidiChannelChanged(self, parameterId, channel):
  895. Carla.host.set_parameter_midi_channel(self.fPluginId, parameterId, channel-1)
  896. @pyqtSlot(int)
  897. def slot_programIndexChanged(self, index):
  898. self.fCurrentProgram = index
  899. Carla.host.set_program(self.fPluginId, index)
  900. @pyqtSlot(int)
  901. def slot_midiProgramIndexChanged(self, index):
  902. self.fCurrentMidiProgram = index
  903. Carla.host.set_midi_program(self.fPluginId, index)
  904. @pyqtSlot(int)
  905. def slot_noteOn(self, note):
  906. if self.fControlChannel >= 0:
  907. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 100)
  908. @pyqtSlot(int)
  909. def slot_noteOff(self, note):
  910. if self.fControlChannel >= 0:
  911. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 0)
  912. @pyqtSlot()
  913. def slot_finished(self):
  914. if self.fRealParent:
  915. self.fRealParent.editClosed()
  916. @pyqtSlot()
  917. def slot_knobCustomMenu(self):
  918. dialName = self.sender().objectName()
  919. if dialName == "dial_drywet":
  920. minimum = 0
  921. maximum = 100
  922. default = 100
  923. label = "Dry/Wet"
  924. elif dialName == "dial_vol":
  925. minimum = 0
  926. maximum = 127
  927. default = 100
  928. label = "Volume"
  929. elif dialName == "dial_b_left":
  930. minimum = -100
  931. maximum = 100
  932. default = -100
  933. label = "Balance-Left"
  934. elif dialName == "dial_b_right":
  935. minimum = -100
  936. maximum = 100
  937. default = 100
  938. label = "Balance-Right"
  939. elif dialName == "dial_panning":
  940. minimum = -100
  941. maximum = 100
  942. default = 0
  943. label = "Panning"
  944. else:
  945. minimum = 0
  946. maximum = 100
  947. default = 100
  948. label = "Unknown"
  949. current = self.sender().value() / 10
  950. menu = QMenu(self)
  951. actReset = menu.addAction(self.tr("Reset (%i%%)" % default))
  952. menu.addSeparator()
  953. actMinimum = menu.addAction(self.tr("Set to Minimum (%i%%)" % minimum))
  954. actCenter = menu.addAction(self.tr("Set to Center"))
  955. actMaximum = menu.addAction(self.tr("Set to Maximum (%i%%)" % maximum))
  956. menu.addSeparator()
  957. actSet = menu.addAction(self.tr("Set value..."))
  958. if label not in ("Balance-Left", "Balance-Right"):
  959. menu.removeAction(actCenter)
  960. actSelected = menu.exec_(QCursor.pos())
  961. if actSelected == actSet:
  962. valueTry = QInputDialog.getInteger(self, self.tr("Set value"), label, current, minimum, maximum, 1)
  963. if valueTry[1]:
  964. value = valueTry[0] * 10
  965. else:
  966. return
  967. elif actSelected == actMinimum:
  968. value = minimum * 10
  969. elif actSelected == actMaximum:
  970. value = maximum * 10
  971. elif actSelected == actReset:
  972. value = default * 10
  973. elif actSelected == actCenter:
  974. value = 0
  975. else:
  976. return
  977. if label == "Dry/Wet":
  978. self.ui.dial_drywet.setValue(value)
  979. elif label == "Volume":
  980. self.ui.dial_vol.setValue(value)
  981. elif label == "Balance-Left":
  982. self.ui.dial_b_left.setValue(value)
  983. elif label == "Balance-Right":
  984. self.ui.dial_b_right.setValue(value)
  985. #elif label == "Panning":
  986. #self.ui.dial_panning.setValue(value)
  987. @pyqtSlot()
  988. def slot_channelCustomMenu(self):
  989. menu = QMenu(self)
  990. actNone = menu.addAction(self.tr("None"))
  991. if self.fControlChannel+1 == 0:
  992. actNone.setCheckable(True)
  993. actNone.setChecked(True)
  994. for i in range(1, 16+1):
  995. action = menu.addAction("%i" % i)
  996. if self.fControlChannel+1 == i:
  997. action.setCheckable(True)
  998. action.setChecked(True)
  999. actSel = menu.exec_(QCursor.pos())
  1000. if not actSel:
  1001. pass
  1002. elif actSel == actNone:
  1003. self.ui.sb_ctrl_channel.setValue(0)
  1004. elif actSel:
  1005. selChannel = int(actSel.text())
  1006. self.ui.sb_ctrl_channel.setValue(selChannel)
  1007. def _createParameterWidgets(self, paramType, paramListFull, tabPageName):
  1008. i = 1
  1009. for paramList, width in paramListFull:
  1010. if len(paramList) == 0:
  1011. break
  1012. tabIndex = self.ui.tabWidget.count()
  1013. tabPageContainer = QWidget(self.ui.tabWidget)
  1014. tabPageLayout = QVBoxLayout(tabPageContainer)
  1015. tabPageContainer.setLayout(tabPageLayout)
  1016. for paramInfo in paramList:
  1017. paramWidget = PluginParameter(tabPageContainer, paramInfo, self.fPluginId, tabIndex)
  1018. paramWidget.setLabelWidth(width)
  1019. tabPageLayout.addWidget(paramWidget)
  1020. self.fParameterList.append((paramType, paramInfo['index'], paramWidget))
  1021. if paramType == PARAMETER_INPUT:
  1022. paramWidget.valueChanged.connect(self.slot_parameterValueChanged)
  1023. paramWidget.midiControlChanged.connect(self.slot_parameterMidiControlChanged)
  1024. paramWidget.midiChannelChanged.connect(self.slot_parameterMidiChannelChanged)
  1025. tabPageLayout.addStretch()
  1026. self.ui.tabWidget.addTab(tabPageContainer, "%s (%i)" % (tabPageName, i))
  1027. i += 1
  1028. if paramType == PARAMETER_INPUT:
  1029. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOff)
  1030. self.fTabIconTimers.append(ICON_STATE_NULL)
  1031. def _updateCtrlMidiProgram(self):
  1032. if self.fPluginInfo['type'] not in (PLUGIN_INTERNAL, PLUGIN_SF2):
  1033. return
  1034. elif self.fPluginInfo['category'] != PLUGIN_CATEGORY_SYNTH:
  1035. return
  1036. if self.fControlChannel < 0:
  1037. self.ui.cb_midi_programs.setEnabled(False)
  1038. return
  1039. self.ui.cb_midi_programs.setEnabled(True)
  1040. mpIndex = Carla.host.get_current_midi_program_index(self.fPluginId)
  1041. if self.ui.cb_midi_programs.currentIndex() != mpIndex:
  1042. self.setMidiProgram(mpIndex)
  1043. def showEvent(self, event):
  1044. if not self.fScrollAreaSetup:
  1045. self.fScrollAreaSetup = True
  1046. minHeight = self.ui.scrollArea.height()+2
  1047. self.ui.scrollArea.setMinimumHeight(minHeight)
  1048. self.ui.scrollArea.setMaximumHeight(minHeight)
  1049. QDialog.showEvent(self, event)
  1050. def done(self, r):
  1051. QDialog.done(self, r)
  1052. self.close()
  1053. # ------------------------------------------------------------------------------------------------------------
  1054. # Plugin Widget
  1055. class PluginWidget(QFrame):
  1056. def __init__(self, parent, pluginId):
  1057. QFrame.__init__(self, parent)
  1058. self.ui = ui_carla_plugin.Ui_PluginWidget()
  1059. self.ui.setupUi(self)
  1060. # -------------------------------------------------------------
  1061. # Internal stuff
  1062. self.fPluginId = pluginId
  1063. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId) if Carla.host is not None else gFakePluginInfo
  1064. self.fPluginInfo['binary'] = cString(self.fPluginInfo['binary'])
  1065. self.fPluginInfo['name'] = cString(self.fPluginInfo['name'])
  1066. self.fPluginInfo['label'] = cString(self.fPluginInfo['label'])
  1067. self.fPluginInfo['maker'] = cString(self.fPluginInfo['maker'])
  1068. self.fPluginInfo['copyright'] = cString(self.fPluginInfo['copyright'])
  1069. self.fPluginInfo['iconName'] = cString(self.fPluginInfo['iconName'])
  1070. if not Carla.isLocal:
  1071. self.fPluginInfo['hints'] &= ~PLUGIN_HAS_GUI
  1072. self.fLastGreenLedState = False
  1073. self.fLastBlueLedState = False
  1074. self.fParameterIconTimer = ICON_STATE_NULL
  1075. if Carla.processMode == PROCESS_MODE_CONTINUOUS_RACK or Carla.host is None:
  1076. self.fPeaksInputCount = 2
  1077. self.fPeaksOutputCount = 2
  1078. else:
  1079. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  1080. self.fPeaksInputCount = int(audioCountInfo['ins'])
  1081. self.fPeaksOutputCount = int(audioCountInfo['outs'])
  1082. if self.fPeaksInputCount > 2:
  1083. self.fPeaksInputCount = 2
  1084. if self.fPeaksOutputCount > 2:
  1085. self.fPeaksOutputCount = 2
  1086. if self.palette().window().color().lightness() > 100:
  1087. # Light background
  1088. labelColor = "333"
  1089. isLight = True
  1090. self.fColorTop = QColor(60, 60, 60)
  1091. self.fColorBottom = QColor(47, 47, 47)
  1092. self.fColorSeprtr = QColor(70, 70, 70)
  1093. else:
  1094. # Dark background
  1095. labelColor = "BBB"
  1096. isLight = False
  1097. self.fColorTop = QColor(60, 60, 60)
  1098. self.fColorBottom = QColor(47, 47, 47)
  1099. self.fColorSeprtr = QColor(70, 70, 70)
  1100. # -------------------------------------------------------------
  1101. # Set-up GUI
  1102. self.setStyleSheet("""
  1103. QLabel#label_name {
  1104. color: #%s;
  1105. }""" % labelColor)
  1106. if isLight:
  1107. self.ui.b_enable.setPixmaps(":/bitmaps/button_off2.png", ":/bitmaps/button_on2.png", ":/bitmaps/button_off2.png")
  1108. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit2.png", ":/bitmaps/button_edit_down2.png", ":/bitmaps/button_edit_hover2.png")
  1109. if self.fPluginInfo['iconName'] == "distrho":
  1110. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho2.png", ":/bitmaps/button_distrho_down2.png", ":/bitmaps/button_distrho_hover2.png")
  1111. elif self.fPluginInfo['iconName'] == "file":
  1112. self.ui.b_gui.setPixmaps(":/bitmaps/button_file2.png", ":/bitmaps/button_file_down2.png", ":/bitmaps/button_file_hover2.png")
  1113. else:
  1114. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui2.png", ":/bitmaps/button_gui_down2.png", ":/bitmaps/button_gui_hover2.png")
  1115. else:
  1116. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  1117. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  1118. if self.fPluginInfo['iconName'] == "distrho":
  1119. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  1120. elif self.fPluginInfo['iconName'] == "file":
  1121. self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  1122. else:
  1123. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  1124. self.ui.led_control.setColor(self.ui.led_control.YELLOW)
  1125. self.ui.led_control.setEnabled(False)
  1126. self.ui.led_midi.setColor(self.ui.led_midi.RED)
  1127. self.ui.led_midi.setEnabled(False)
  1128. self.ui.led_audio_in.setColor(self.ui.led_audio_in.GREEN)
  1129. self.ui.led_audio_in.setEnabled(False)
  1130. self.ui.led_audio_out.setColor(self.ui.led_audio_out.BLUE)
  1131. self.ui.led_audio_out.setEnabled(False)
  1132. self.ui.peak_in.setColor(self.ui.peak_in.GREEN)
  1133. self.ui.peak_in.setChannels(self.fPeaksInputCount)
  1134. self.ui.peak_in.setOrientation(self.ui.peak_in.HORIZONTAL)
  1135. self.ui.peak_out.setColor(self.ui.peak_in.BLUE)
  1136. self.ui.peak_out.setChannels(self.fPeaksOutputCount)
  1137. self.ui.peak_out.setOrientation(self.ui.peak_out.HORIZONTAL)
  1138. self.ui.label_name.setText(self.fPluginInfo['name'])
  1139. self.ui.edit_dialog = PluginEdit(self, self.fPluginId)
  1140. self.ui.edit_dialog.hide()
  1141. self.setFixedHeight(32)
  1142. # -------------------------------------------------------------
  1143. # Set-up connections
  1144. self.customContextMenuRequested.connect(self.slot_showCustomMenu)
  1145. self.ui.b_enable.clicked.connect(self.slot_enableClicked)
  1146. self.ui.b_gui.clicked.connect(self.slot_guiClicked)
  1147. self.ui.b_edit.clicked.connect(self.slot_editClicked)
  1148. # -------------------------------------------------------------
  1149. def idleFast(self):
  1150. # Input peaks
  1151. if self.fPeaksInputCount > 0:
  1152. if self.fPeaksInputCount > 1:
  1153. peak1 = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1154. peak2 = Carla.host.get_input_peak_value(self.fPluginId, 2)
  1155. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1156. self.ui.peak_in.displayMeter(1, peak1)
  1157. self.ui.peak_in.displayMeter(2, peak2)
  1158. else:
  1159. peak = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1160. ledState = bool(peak != 0.0)
  1161. self.ui.peak_in.displayMeter(1, peak)
  1162. if self.fLastGreenLedState != ledState:
  1163. self.fLastGreenLedState = ledState
  1164. self.ui.led_audio_in.setChecked(ledState)
  1165. # Output peaks
  1166. if self.fPeaksOutputCount > 0:
  1167. if self.fPeaksOutputCount > 1:
  1168. peak1 = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1169. peak2 = Carla.host.get_output_peak_value(self.fPluginId, 2)
  1170. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1171. self.ui.peak_out.displayMeter(1, peak1)
  1172. self.ui.peak_out.displayMeter(2, peak2)
  1173. else:
  1174. peak = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1175. ledState = bool(peak != 0.0)
  1176. self.ui.peak_out.displayMeter(1, peak)
  1177. if self.fLastBlueLedState != ledState:
  1178. self.fLastBlueLedState = ledState
  1179. self.ui.led_audio_out.setChecked(ledState)
  1180. def idleSlow(self):
  1181. # Parameter Activity LED
  1182. if self.fParameterIconTimer == ICON_STATE_ON:
  1183. self.fParameterIconTimer = ICON_STATE_WAIT
  1184. self.ui.led_control.setChecked(True)
  1185. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  1186. self.fParameterIconTimer = ICON_STATE_OFF
  1187. elif self.fParameterIconTimer == ICON_STATE_OFF:
  1188. self.fParameterIconTimer = ICON_STATE_NULL
  1189. self.ui.led_control.setChecked(False)
  1190. # Update edit dialog
  1191. self.ui.edit_dialog.idleSlow()
  1192. def editClosed(self):
  1193. self.ui.b_edit.setChecked(False)
  1194. def recheckPluginHints(self, hints):
  1195. self.fPluginInfo['hints'] = hints
  1196. self.ui.b_gui.setEnabled(hints & PLUGIN_HAS_GUI)
  1197. def setActive(self, active, sendGui=False, sendCallback=True):
  1198. if sendGui: self.ui.b_enable.setChecked(active)
  1199. if sendCallback: Carla.host.set_active(self.fPluginId, active)
  1200. if active:
  1201. self.ui.edit_dialog.clearNotes()
  1202. self.ui.led_midi.setChecked(False)
  1203. def setParameterValue(self, parameterId, value):
  1204. self.fParameterIconTimer = ICON_STATE_ON
  1205. if parameterId == PARAMETER_ACTIVE:
  1206. return self.setActive(bool(value), True, False)
  1207. self.ui.edit_dialog.setParameterValue(parameterId, value)
  1208. def setParameterDefault(self, parameterId, value):
  1209. self.ui.edit_dialog.setParameterDefault(parameterId, value)
  1210. def setParameterMidiControl(self, parameterId, control):
  1211. self.ui.edit_dialog.setParameterMidiControl(parameterId, control)
  1212. def setParameterMidiChannel(self, parameterId, channel):
  1213. self.ui.edit_dialog.setParameterMidiChannel(parameterId, channel)
  1214. def setProgram(self, index):
  1215. self.fParameterIconTimer = ICON_STATE_ON
  1216. self.ui.edit_dialog.setProgram(index)
  1217. def setMidiProgram(self, index):
  1218. self.fParameterIconTimer = ICON_STATE_ON
  1219. self.ui.edit_dialog.setMidiProgram(index)
  1220. def sendNoteOn(self, channel, note):
  1221. if self.ui.edit_dialog.sendNoteOn(channel, note):
  1222. self.ui.led_midi.setChecked(True)
  1223. def sendNoteOff(self, channel, note):
  1224. if self.ui.edit_dialog.sendNoteOff(channel, note):
  1225. self.ui.led_midi.setChecked(False)
  1226. def setId(self, idx):
  1227. self.fPluginId = idx
  1228. self.ui.edit_dialog.fPluginId = idx
  1229. @pyqtSlot()
  1230. def slot_showCustomMenu(self):
  1231. menu = QMenu(self)
  1232. actActive = menu.addAction(self.tr("Disable") if self.ui.b_enable.isChecked() else self.tr("Enable"))
  1233. menu.addSeparator()
  1234. actGui = menu.addAction(self.tr("Show GUI"))
  1235. actGui.setCheckable(True)
  1236. actGui.setChecked(self.ui.b_gui.isChecked())
  1237. actGui.setEnabled(self.ui.b_gui.isEnabled())
  1238. actEdit = menu.addAction(self.tr("Edit"))
  1239. actEdit.setCheckable(True)
  1240. actEdit.setChecked(self.ui.b_edit.isChecked())
  1241. menu.addSeparator()
  1242. actClone = menu.addAction(self.tr("Clone"))
  1243. actRename = menu.addAction(self.tr("Rename..."))
  1244. actRemove = menu.addAction(self.tr("Remove"))
  1245. actSel = menu.exec_(QCursor.pos())
  1246. if not actSel:
  1247. return
  1248. if actSel == actActive:
  1249. self.setActive(not self.ui.b_enable.isChecked(), True, True)
  1250. elif actSel == actGui:
  1251. self.ui.b_gui.click()
  1252. elif actSel == actEdit:
  1253. self.ui.b_edit.click()
  1254. elif actSel == actClone:
  1255. if not Carla.host.clone_plugin(self.fPluginId):
  1256. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  1257. cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  1258. elif actSel == actRename:
  1259. oldName = self.fPluginInfo['name']
  1260. newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName)
  1261. if not (newNameTry[1] and newNameTry[0] and oldName != newNameTry[0]):
  1262. return
  1263. newName = newNameTry[0]
  1264. if Carla.host is None or Carla.host.rename_plugin(self.fPluginId, newName):
  1265. self.fPluginInfo['name'] = newName
  1266. self.ui.edit_dialog.fPluginInfo['name'] = newName
  1267. self.ui.edit_dialog.reloadInfo()
  1268. self.ui.label_name.setText(newName)
  1269. else:
  1270. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  1271. cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  1272. elif actSel == actRemove:
  1273. if not Carla.host.remove_plugin(self.fPluginId):
  1274. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  1275. cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  1276. @pyqtSlot(bool)
  1277. def slot_enableClicked(self, yesNo):
  1278. self.setActive(yesNo, False, True)
  1279. @pyqtSlot(bool)
  1280. def slot_guiClicked(self, show):
  1281. Carla.host.show_gui(self.fPluginId, show)
  1282. @pyqtSlot(bool)
  1283. def slot_editClicked(self, show):
  1284. self.ui.edit_dialog.setVisible(show)
  1285. def paintEvent(self, event):
  1286. painter = QPainter(self)
  1287. painter.save()
  1288. areaX = self.ui.area_right.x()+7
  1289. painter.setPen(self.fColorSeprtr.lighter(110))
  1290. painter.setBrush(self.fColorBottom)
  1291. painter.setRenderHint(QPainter.Antialiasing, True)
  1292. # name -> leds arc
  1293. path = QPainterPath()
  1294. path.moveTo(areaX-20, self.height()-4)
  1295. path.cubicTo(areaX, self.height()-5, areaX-20, 4.75, areaX, 4.75)
  1296. path.lineTo(areaX, self.height()-5)
  1297. painter.drawPath(path)
  1298. painter.setPen(self.fColorSeprtr)
  1299. painter.setRenderHint(QPainter.Antialiasing, False)
  1300. # separator lines
  1301. painter.drawLine(0, self.height()-5, areaX-20, self.height()-5)
  1302. painter.drawLine(areaX, 4, self.width(), 4)
  1303. painter.setPen(self.fColorBottom)
  1304. painter.setBrush(self.fColorBottom)
  1305. # top, bottom and left lines
  1306. painter.drawLine(0, 0, self.width(), 0)
  1307. painter.drawRect(0, self.height()-4, areaX, 4)
  1308. painter.drawRoundedRect(areaX-20, self.height()-5, areaX, 5, 22, 22)
  1309. painter.drawLine(0, 0, 0, self.height())
  1310. # fill the rest
  1311. painter.drawRect(areaX-1, 5, self.width(), self.height())
  1312. # bottom 1px line
  1313. painter.setPen(self.fColorSeprtr)
  1314. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  1315. painter.restore()
  1316. QFrame.paintEvent(self, event)
  1317. # ------------------------------------------------------------------------------------------------------------
  1318. # Main
  1319. if __name__ == '__main__':
  1320. try:
  1321. from PyQt5.QtWidgets import QApplication
  1322. except:
  1323. from PyQt4.QtGui import QApplication
  1324. app = QApplication(sys.argv)
  1325. app.setApplicationName("Carla")
  1326. app.setApplicationVersion(VERSION)
  1327. app.setOrganizationName("falkTX")
  1328. app.setWindowIcon(QIcon(":/scalable/carla.svg"))
  1329. #gui = PluginParameter(None, gFakeParamInfo, 0, 0)
  1330. #gui = PluginEdit(None, 0)
  1331. gui = PluginWidget(None, 0)
  1332. gui.show()
  1333. sys.exit(app.exec_())