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.

1720 lines
68KB

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