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.

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