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.

1668 lines
66KB

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