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.

1693 lines
68KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla widgets code
  4. # Copyright (C) 2011-2020 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 PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QByteArray, QTimer
  20. from PyQt5.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath, QPalette, QPixmap
  21. from PyQt5.QtWidgets import QDialog, QGroupBox, QInputDialog, QLineEdit, QMenu, QScrollArea, QVBoxLayout, QWidget
  22. # ------------------------------------------------------------------------------------------------------------
  23. # Imports (Custom)
  24. import ui_carla_about
  25. import ui_carla_about_juce
  26. import ui_carla_edit
  27. import ui_carla_parameter
  28. from carla_shared import *
  29. from carla_utils import *
  30. from widgets.collapsablewidget import CollapsibleBox
  31. from widgets.paramspinbox import CustomInputDialog
  32. from widgets.pixmapkeyboard import PixmapKeyboardHArea
  33. # ------------------------------------------------------------------------------------------------------------
  34. # Carla GUI defines
  35. ICON_STATE_ON = 3 # turns on, sets as wait
  36. ICON_STATE_WAIT = 2 # nothing, sets as off
  37. ICON_STATE_OFF = 1 # turns off, sets as null
  38. ICON_STATE_NULL = 0 # nothing
  39. # ------------------------------------------------------------------------------------------------------------
  40. # Carla About dialog
  41. class CarlaAboutW(QDialog):
  42. def __init__(self, parent, host):
  43. QDialog.__init__(self, parent)
  44. self.ui = ui_carla_about.Ui_CarlaAboutW()
  45. self.ui.setupUi(self)
  46. if False:
  47. # kdevelop likes this :)
  48. host = CarlaHostNull()
  49. if host.isControl:
  50. extraInfo = " - <b>%s</b>" % self.tr("OSC Bridge Version")
  51. elif host.isPlugin:
  52. extraInfo = " - <b>%s</b>" % self.tr("Plugin Version")
  53. else:
  54. extraInfo = ""
  55. self.ui.l_about.setText(self.tr(""
  56. "<br>Version %s"
  57. "<br>Carla is a fully-featured audio plugin host%s.<br>"
  58. "<br>Copyright (C) 2011-2020 falkTX<br>"
  59. "" % (VERSION, extraInfo)))
  60. if self.ui.about.palette().color(QPalette.Background).blackF() < 0.5:
  61. self.ui.l_icons.setPixmap(QPixmap(":/bitmaps/carla_about_black.png"))
  62. self.ui.ico_example_edit.setPixmap(QPixmap(":/bitmaps/button_file-black.png"))
  63. self.ui.ico_example_file.setPixmap(QPixmap(":/bitmaps/button_edit-black.png"))
  64. self.ui.ico_example_gui.setPixmap(QPixmap(":/bitmaps/button_gui-black.png"))
  65. if host.isControl:
  66. self.ui.l_extended.hide()
  67. self.ui.tabWidget.removeTab(3)
  68. self.ui.tabWidget.removeTab(2)
  69. self.ui.l_extended.setText(gCarla.utils.get_complete_license_text())
  70. if host.is_engine_running() and not host.isControl:
  71. self.ui.le_osc_url_tcp.setText(host.get_host_osc_url_tcp())
  72. self.ui.le_osc_url_udp.setText(host.get_host_osc_url_udp())
  73. else:
  74. self.ui.le_osc_url_tcp.setText(self.tr("(Engine not running)"))
  75. self.ui.le_osc_url_udp.setText(self.tr("(Engine not running)"))
  76. self.ui.l_osc_cmds.setText("<table>"
  77. "<tr><td>" "/set_active" "&nbsp;</td><td>&lt;i-value&gt;</td></tr>"
  78. "<tr><td>" "/set_drywet" "&nbsp;</td><td>&lt;f-value&gt;</td></tr>"
  79. "<tr><td>" "/set_volume" "&nbsp;</td><td>&lt;f-value&gt;</td></tr>"
  80. "<tr><td>" "/set_balance_left" "&nbsp;</td><td>&lt;f-value&gt;</td></tr>"
  81. "<tr><td>" "/set_balance_right" "&nbsp;</td><td>&lt;f-value&gt;</td></tr>"
  82. "<tr><td>" "/set_panning" "&nbsp;</td><td>&lt;f-value&gt;</td></tr>"
  83. "<tr><td>" "/set_parameter_value" "&nbsp;</td><td>&lt;i-index&gt; &lt;f-value&gt;</td></tr>"
  84. "<tr><td>" "/set_parameter_midi_cc" "&nbsp;</td><td>&lt;i-index&gt; &lt;i-cc&gt;</td></tr>"
  85. "<tr><td>" "/set_parameter_midi_channel" "&nbsp;</td><td>&lt;i-index&gt; &lt;i-channel&gt;</td></tr>"
  86. "<tr><td>" "/set_program" "&nbsp;</td><td>&lt;i-index&gt;</td></tr>"
  87. "<tr><td>" "/set_midi_program" "&nbsp;</td><td>&lt;i-index&gt;</td></tr>"
  88. "<tr><td>" "/note_on" "&nbsp;</td><td>&lt;i-channel&gt; &lt;i-note&gt; &lt;i-velo&gt;</td></tr>"
  89. "<tr><td>" "/note_off" "&nbsp;</td><td>&lt;i-channel&gt; &lt;i-note</td></tr>"
  90. "</table>"
  91. )
  92. self.ui.l_example.setText("/Carla/2/set_parameter_value 5 1.0")
  93. self.ui.l_example_help.setText("<i>(as in this example, \"2\" is the plugin number and \"5\" the parameter)</i>")
  94. self.ui.l_ladspa.setText(self.tr("Everything! (Including LRDF)"))
  95. self.ui.l_dssi.setText(self.tr("Everything! (Including CustomData/Chunks)"))
  96. self.ui.l_lv2.setText(self.tr("About 110&#37; complete (using custom extensions)<br/>"
  97. "Implemented Feature/Extensions:"
  98. "<ul>"
  99. "<li>http://lv2plug.in/ns/ext/atom</li>"
  100. "<li>http://lv2plug.in/ns/ext/buf-size</li>"
  101. "<li>http://lv2plug.in/ns/ext/data-access</li>"
  102. #"<li>http://lv2plug.in/ns/ext/dynmanifest</li>"
  103. "<li>http://lv2plug.in/ns/ext/event</li>"
  104. "<li>http://lv2plug.in/ns/ext/instance-access</li>"
  105. "<li>http://lv2plug.in/ns/ext/log</li>"
  106. "<li>http://lv2plug.in/ns/ext/midi</li>"
  107. #"<li>http://lv2plug.in/ns/ext/morph</li>"
  108. "<li>http://lv2plug.in/ns/ext/options</li>"
  109. "<li>http://lv2plug.in/ns/ext/parameters</li>"
  110. #"<li>http://lv2plug.in/ns/ext/patch</li>"
  111. "<li>http://lv2plug.in/ns/ext/port-props</li>"
  112. "<li>http://lv2plug.in/ns/ext/presets</li>"
  113. "<li>http://lv2plug.in/ns/ext/resize-port</li>"
  114. "<li>http://lv2plug.in/ns/ext/state</li>"
  115. "<li>http://lv2plug.in/ns/ext/time</li>"
  116. "<li>http://lv2plug.in/ns/ext/uri-map</li>"
  117. "<li>http://lv2plug.in/ns/ext/urid</li>"
  118. "<li>http://lv2plug.in/ns/ext/worker</li>"
  119. "<li>http://lv2plug.in/ns/extensions/ui</li>"
  120. "<li>http://lv2plug.in/ns/extensions/units</li>"
  121. "<li>http://home.gna.org/lv2dynparam/rtmempool/v1</li>"
  122. "<li>http://kxstudio.sf.net/ns/lv2ext/external-ui</li>"
  123. "<li>http://kxstudio.sf.net/ns/lv2ext/programs</li>"
  124. "<li>http://kxstudio.sf.net/ns/lv2ext/props</li>"
  125. "<li>http://kxstudio.sf.net/ns/lv2ext/rtmempool</li>"
  126. "<li>http://ll-plugins.nongnu.org/lv2/ext/midimap</li>"
  127. "<li>http://ll-plugins.nongnu.org/lv2/ext/miditype</li>"
  128. "</ul>"))
  129. usingJuce = "juce" in gCarla.utils.get_supported_features()
  130. if usingJuce and (MACOS or WINDOWS):
  131. self.ui.l_vst2.setText(self.tr("Using JUCE host"))
  132. self.ui.l_vst3.setText(self.tr("Using JUCE host"))
  133. else:
  134. self.ui.l_vst2.setText(self.tr("About 85&#37; complete (missing vst bank/presets and some minor stuff)"))
  135. self.ui.line_vst2.hide()
  136. self.ui.l_vst3.hide()
  137. self.ui.lid_vst3.hide()
  138. if MACOS:
  139. self.ui.l_au.setText(self.tr("Using JUCE host"))
  140. else:
  141. self.ui.line_vst3.hide()
  142. self.ui.l_au.hide()
  143. self.ui.lid_au.hide()
  144. # 3rd tab is usually longer than the 1st
  145. # adjust appropriately
  146. self.ui.tabWidget.setCurrentIndex(2)
  147. self.adjustSize()
  148. self.ui.tabWidget.setCurrentIndex(0)
  149. self.setFixedSize(self.size())
  150. flags = self.windowFlags()
  151. flags &= ~Qt.WindowContextHelpButtonHint
  152. if WINDOWS:
  153. flags |= Qt.MSWindowsFixedSizeDialogHint
  154. self.setWindowFlags(flags)
  155. def done(self, r):
  156. QDialog.done(self, r)
  157. self.close()
  158. # ------------------------------------------------------------------------------------------------------------
  159. # JUCE About dialog
  160. class JuceAboutW(QDialog):
  161. def __init__(self, parent):
  162. QDialog.__init__(self, parent)
  163. self.ui = ui_carla_about_juce.Ui_JuceAboutW()
  164. self.ui.setupUi(self)
  165. self.ui.l_text2.setText(self.tr("This program uses JUCE version %s." % gCarla.utils.get_juce_version()))
  166. self.adjustSize()
  167. self.setFixedSize(self.size())
  168. flags = self.windowFlags()
  169. flags &= ~Qt.WindowContextHelpButtonHint
  170. if WINDOWS:
  171. flags |= Qt.MSWindowsFixedSizeDialogHint
  172. self.setWindowFlags(flags)
  173. def done(self, r):
  174. QDialog.done(self, r)
  175. self.close()
  176. # ------------------------------------------------------------------------------------------------------------
  177. # Plugin Parameter
  178. class PluginParameter(QWidget):
  179. mappedControlChanged = pyqtSignal(int, int)
  180. midiChannelChanged = pyqtSignal(int, int)
  181. valueChanged = pyqtSignal(int, float)
  182. def __init__(self, parent, host, pInfo, pluginId, tabIndex):
  183. QWidget.__init__(self, parent)
  184. self.host = host
  185. self.ui = ui_carla_parameter.Ui_PluginParameter()
  186. self.ui.setupUi(self)
  187. if False:
  188. # kdevelop likes this :)
  189. host = CarlaHostNull()
  190. self.host = host
  191. # -------------------------------------------------------------
  192. # Internal stuff
  193. self.fMappedCtrl = pInfo['mappedControlIndex']
  194. self.fMappedMinimum = pInfo['mappedMinimum']
  195. self.fMappedMaximum = pInfo['mappedMaximum']
  196. self.fMidiChannel = pInfo['midiChannel']
  197. self.fParameterId = pInfo['index']
  198. self.fPluginId = pluginId
  199. self.fTabIndex = tabIndex
  200. # -------------------------------------------------------------
  201. # Set-up GUI
  202. pType = pInfo['type']
  203. pHints = pInfo['hints']
  204. self.ui.label.setText(pInfo['name'])
  205. self.ui.widget.setName(pInfo['name'])
  206. self.ui.widget.setMinimum(pInfo['minimum'])
  207. self.ui.widget.setMaximum(pInfo['maximum'])
  208. self.ui.widget.setDefault(pInfo['default'])
  209. self.ui.widget.setLabel(pInfo['unit'])
  210. self.ui.widget.setStep(pInfo['step'])
  211. self.ui.widget.setStepSmall(pInfo['stepSmall'])
  212. self.ui.widget.setStepLarge(pInfo['stepLarge'])
  213. self.ui.widget.setScalePoints(pInfo['scalePoints'], bool(pHints & PARAMETER_USES_SCALEPOINTS))
  214. if pInfo['comment']:
  215. self.ui.label.setToolTip(pInfo['comment'])
  216. self.ui.widget.setToolTip(pInfo['comment'])
  217. if pType == PARAMETER_INPUT:
  218. if not pHints & PARAMETER_IS_ENABLED:
  219. self.ui.label.setEnabled(False)
  220. self.ui.widget.setEnabled(False)
  221. self.ui.widget.setReadOnly(True)
  222. self.ui.tb_options.setEnabled(False)
  223. elif not pHints & PARAMETER_IS_AUTOMABLE:
  224. self.ui.tb_options.setEnabled(False)
  225. if pHints & PARAMETER_IS_READ_ONLY:
  226. self.ui.widget.setReadOnly(True)
  227. self.ui.tb_options.setEnabled(False)
  228. elif pType == PARAMETER_OUTPUT:
  229. self.ui.widget.setReadOnly(True)
  230. else:
  231. self.ui.widget.setVisible(False)
  232. self.ui.tb_options.setVisible(False)
  233. # Only set value after all hints are handled
  234. self.ui.widget.setValue(pInfo['current'])
  235. if pHints & PARAMETER_USES_CUSTOM_TEXT and not host.isPlugin:
  236. self.ui.widget.setTextCallback(self._textCallBack)
  237. self.ui.widget.setValueCallback(self._valueCallBack)
  238. self.ui.widget.updateAll()
  239. self.setMappedControlIndex(pInfo['mappedControlIndex'])
  240. self.setMidiChannel(pInfo['midiChannel'])
  241. # -------------------------------------------------------------
  242. # Set-up connections
  243. self.ui.tb_options.clicked.connect(self.slot_optionsCustomMenu)
  244. self.ui.widget.dragStateChanged.connect(self.slot_parameterDragStateChanged)
  245. # -------------------------------------------------------------
  246. def getPluginId(self):
  247. return self.fPluginId
  248. def getTabIndex(self):
  249. return self.fTabIndex
  250. def setPluginId(self, pluginId):
  251. self.fPluginId = pluginId
  252. def setDefault(self, value):
  253. self.ui.widget.setDefault(value)
  254. def setValue(self, value):
  255. self.ui.widget.blockSignals(True)
  256. self.ui.widget.setValue(value)
  257. self.ui.widget.blockSignals(False)
  258. def setMappedControlIndex(self, control):
  259. self.fMappedCtrl = control
  260. def setMappedRange(self, minimum, maximum):
  261. self.fMappedMinimum = minimum
  262. self.fMappedMaximum = maximum
  263. def setMidiChannel(self, channel):
  264. self.fMidiChannel = channel
  265. def setLabelWidth(self, width):
  266. self.ui.label.setFixedWidth(width)
  267. @pyqtSlot()
  268. def slot_optionsCustomMenu(self):
  269. menu = QMenu(self)
  270. if self.fMappedCtrl == CONTROL_VALUE_NONE:
  271. title = self.tr("Unmapped")
  272. elif self.fMappedCtrl == CONTROL_VALUE_CV:
  273. title = self.tr("Exposed as CV port")
  274. else:
  275. title = self.tr("Mapped to MIDI control %i, channel %i" % (self.fMappedCtrl, self.fMidiChannel))
  276. if self.fMappedCtrl != CONTROL_VALUE_NONE:
  277. title += " (range: %g-%g)" % (self.fMappedMinimum, self.fMappedMaximum)
  278. actTitle = menu.addAction(title)
  279. actTitle.setEnabled(False)
  280. menu.addSeparator()
  281. actUnmap = menu.addAction(self.tr("Unmap"))
  282. if self.fMappedCtrl == CONTROL_VALUE_NONE:
  283. actUnmap.setCheckable(True)
  284. actUnmap.setChecked(True)
  285. menu.addSection("CV")
  286. actCV = menu.addAction(self.tr("Expose as CV port"))
  287. if self.fMappedCtrl == CONTROL_VALUE_CV:
  288. actCV.setCheckable(True)
  289. actCV.setChecked(True)
  290. menu.addSection("MIDI")
  291. menuMIDI = menu.addMenu(self.tr("MIDI Control"))
  292. if self.fMappedCtrl not in (CONTROL_VALUE_NONE, CONTROL_VALUE_CV, CONTROL_VALUE_MIDI_PITCHBEND):
  293. action = menuMIDI.menuAction()
  294. action.setCheckable(True)
  295. action.setChecked(True)
  296. inlist = False
  297. actCCs = []
  298. for cc in MIDI_CC_LIST:
  299. action = menuMIDI.addAction(cc)
  300. actCCs.append(action)
  301. if self.fMappedCtrl >= 0 and self.fMappedCtrl <= MAX_MIDI_CC_LIST_ITEM:
  302. ccx = int(cc.split(" [", 1)[0])
  303. if ccx > self.fMappedCtrl and not inlist:
  304. inlist = True
  305. action = menuMIDI.addAction(self.tr("%02i [0x%02X] (Custom)" % (self.fMappedCtrl, self.fMappedCtrl)))
  306. action.setCheckable(True)
  307. action.setChecked(True)
  308. actCCs.append(action)
  309. elif ccx == self.fMappedCtrl:
  310. inlist = True
  311. action.setCheckable(True)
  312. action.setChecked(True)
  313. if self.fMappedCtrl > MAX_MIDI_CC_LIST_ITEM and self.fMappedCtrl <= 0x77:
  314. action = menuMIDI.addAction(self.tr("%02i [0x%02X] (Custom)" % (self.fMappedCtrl, self.fMappedCtrl)))
  315. action.setCheckable(True)
  316. action.setChecked(True)
  317. actCCs.append(action)
  318. actCustomCC = menuMIDI.addAction(self.tr("Custom..."))
  319. # TODO
  320. #actPitchbend = menu.addAction(self.tr("MIDI Pitchbend"))
  321. #if self.fMappedCtrl == CONTROL_VALUE_MIDI_PITCHBEND:
  322. #actPitchbend.setCheckable(True)
  323. #actPitchbend.setChecked(True)
  324. menuChannel = menu.addMenu(self.tr("MIDI Channel"))
  325. actChannels = []
  326. for i in range(1, 16+1):
  327. action = menuChannel.addAction("%i" % i)
  328. actChannels.append(action)
  329. if self.fMidiChannel == i:
  330. action.setCheckable(True)
  331. action.setChecked(True)
  332. actSel = menu.exec_(QCursor.pos())
  333. if not actSel:
  334. return
  335. if actSel in actChannels:
  336. channel = int(actSel.text())
  337. self.fMidiChannel = channel
  338. self.midiChannelChanged.emit(self.fParameterId, channel)
  339. return
  340. if actSel == actUnmap:
  341. ctrl = CONTROL_VALUE_NONE
  342. elif actSel == actCV:
  343. ctrl = CONTROL_VALUE_CV
  344. elif actSel in actCCs:
  345. ctrl = int(actSel.text().split(" ", 1)[0].replace("&",""), 16)
  346. elif actSel == actCustomCC:
  347. ctrl, ok = QInputDialog.getInt(self,
  348. self.tr("Custom CC"),
  349. "Custom MIDI CC to use:",
  350. self.fMappedCtrl if self.fMappedCtrl >= 0x01 and self.fMappedCtrl <= 0x77 else 1,
  351. 0x01, 0x77, 1)
  352. if not ok:
  353. return
  354. #elif actSel in actPitchbend:
  355. #ctrl = CONTROL_VALUE_MIDI_PITCHBEND
  356. else:
  357. return
  358. self.fMappedCtrl = ctrl
  359. self.mappedControlChanged.emit(self.fParameterId, ctrl)
  360. @pyqtSlot(bool)
  361. def slot_parameterDragStateChanged(self, touch):
  362. self.host.set_parameter_touch(self.fPluginId, self.fParameterId, touch)
  363. def _textCallBack(self):
  364. return self.host.get_parameter_text(self.fPluginId, self.fParameterId)
  365. def _valueCallBack(self, value):
  366. self.valueChanged.emit(self.fParameterId, value)
  367. # ------------------------------------------------------------------------------------------------------------
  368. # Plugin Editor Parent (Meta class)
  369. class PluginEditParentMeta():
  370. #class PluginEditParentMeta(metaclass=ABCMeta):
  371. @abstractmethod
  372. def editDialogVisibilityChanged(self, pluginId, visible):
  373. raise NotImplementedError
  374. @abstractmethod
  375. def editDialogPluginHintsChanged(self, pluginId, hints):
  376. raise NotImplementedError
  377. @abstractmethod
  378. def editDialogParameterValueChanged(self, pluginId, parameterId, value):
  379. raise NotImplementedError
  380. @abstractmethod
  381. def editDialogProgramChanged(self, pluginId, index):
  382. raise NotImplementedError
  383. @abstractmethod
  384. def editDialogMidiProgramChanged(self, pluginId, index):
  385. raise NotImplementedError
  386. @abstractmethod
  387. def editDialogNotePressed(self, pluginId, note):
  388. raise NotImplementedError
  389. @abstractmethod
  390. def editDialogNoteReleased(self, pluginId, note):
  391. raise NotImplementedError
  392. @abstractmethod
  393. def editDialogMidiActivityChanged(self, pluginId, onOff):
  394. raise NotImplementedError
  395. # ------------------------------------------------------------------------------------------------------------
  396. # Plugin Editor (Built-in)
  397. class PluginEdit(QDialog):
  398. # signals
  399. SIGTERM = pyqtSignal()
  400. SIGUSR1 = pyqtSignal()
  401. def __init__(self, parent, host, pluginId):
  402. QDialog.__init__(self, parent.window() if parent is not None else None)
  403. self.host = host
  404. self.ui = ui_carla_edit.Ui_PluginEdit()
  405. self.ui.setupUi(self)
  406. if False:
  407. # kdevelop likes this :)
  408. parent = PluginEditParentMeta()
  409. host = CarlaHostNull()
  410. self.host = host
  411. # -------------------------------------------------------------
  412. # Internal stuff
  413. self.fGeometry = QByteArray()
  414. self.fParent = parent
  415. self.fPluginId = pluginId
  416. self.fPluginInfo = None
  417. self.fCurrentStateFilename = None
  418. self.fControlChannel = round(host.get_internal_parameter_value(pluginId, PARAMETER_CTRL_CHANNEL))
  419. self.fFirstInit = True
  420. self.fParameterList = [] # (type, id, widget)
  421. self.fParametersToUpdate = [] # (id, value)
  422. self.fPlayingNotes = [] # (channel, note)
  423. self.fTabIconOff = QIcon(":/bitmaps/led_off.png")
  424. self.fTabIconOn = QIcon(":/bitmaps/led_yellow.png")
  425. self.fTabIconTimers = []
  426. # used during testing
  427. self.fIdleTimerId = 0
  428. # -------------------------------------------------------------
  429. # Set-up GUI
  430. labelPluginFont = self.ui.label_plugin.font()
  431. labelPluginFont.setPixelSize(15)
  432. labelPluginFont.setWeight(75)
  433. self.ui.label_plugin.setFont(labelPluginFont)
  434. self.ui.dial_drywet.setCustomPaintMode(self.ui.dial_drywet.CUSTOM_PAINT_MODE_CARLA_WET)
  435. self.ui.dial_drywet.setPixmap(3)
  436. self.ui.dial_drywet.setLabel("Dry/Wet")
  437. self.ui.dial_drywet.setMinimum(0.0)
  438. self.ui.dial_drywet.setMaximum(1.0)
  439. self.ui.dial_drywet.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_DRYWET))
  440. self.ui.dial_vol.setCustomPaintMode(self.ui.dial_vol.CUSTOM_PAINT_MODE_CARLA_VOL)
  441. self.ui.dial_vol.setPixmap(3)
  442. self.ui.dial_vol.setLabel("Volume")
  443. self.ui.dial_vol.setMinimum(0.0)
  444. self.ui.dial_vol.setMaximum(1.27)
  445. self.ui.dial_vol.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_VOLUME))
  446. self.ui.dial_b_left.setCustomPaintMode(self.ui.dial_b_left.CUSTOM_PAINT_MODE_CARLA_L)
  447. self.ui.dial_b_left.setPixmap(4)
  448. self.ui.dial_b_left.setLabel("L")
  449. self.ui.dial_b_left.setMinimum(-1.0)
  450. self.ui.dial_b_left.setMaximum(1.0)
  451. self.ui.dial_b_left.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_BALANCE_LEFT))
  452. self.ui.dial_b_right.setCustomPaintMode(self.ui.dial_b_right.CUSTOM_PAINT_MODE_CARLA_R)
  453. self.ui.dial_b_right.setPixmap(4)
  454. self.ui.dial_b_right.setLabel("R")
  455. self.ui.dial_b_right.setMinimum(-1.0)
  456. self.ui.dial_b_right.setMaximum(1.0)
  457. self.ui.dial_b_right.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_BALANCE_RIGHT))
  458. self.ui.dial_pan.setCustomPaintMode(self.ui.dial_b_right.CUSTOM_PAINT_MODE_CARLA_PAN)
  459. self.ui.dial_pan.setPixmap(4)
  460. self.ui.dial_pan.setLabel("Pan")
  461. self.ui.dial_pan.setMinimum(-1.0)
  462. self.ui.dial_pan.setMaximum(1.0)
  463. self.ui.dial_pan.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_PANNING))
  464. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  465. self.ui.scrollArea = PixmapKeyboardHArea(self)
  466. self.ui.keyboard = self.ui.scrollArea.keyboard
  467. self.ui.keyboard.setEnabled(self.fControlChannel >= 0)
  468. self.layout().addWidget(self.ui.scrollArea)
  469. self.ui.scrollArea.setEnabled(False)
  470. self.ui.scrollArea.setVisible(False)
  471. # todo
  472. self.ui.rb_balance.setEnabled(False)
  473. self.ui.rb_balance.setVisible(False)
  474. self.ui.rb_pan.setEnabled(False)
  475. self.ui.rb_pan.setVisible(False)
  476. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  477. self.reloadAll()
  478. self.fFirstInit = False
  479. # -------------------------------------------------------------
  480. # Set-up connections
  481. self.finished.connect(self.slot_finished)
  482. self.ui.ch_fixed_buffer.clicked.connect(self.slot_optionChanged)
  483. self.ui.ch_force_stereo.clicked.connect(self.slot_optionChanged)
  484. self.ui.ch_map_program_changes.clicked.connect(self.slot_optionChanged)
  485. self.ui.ch_use_chunks.clicked.connect(self.slot_optionChanged)
  486. self.ui.ch_send_program_changes.clicked.connect(self.slot_optionChanged)
  487. self.ui.ch_send_control_changes.clicked.connect(self.slot_optionChanged)
  488. self.ui.ch_send_channel_pressure.clicked.connect(self.slot_optionChanged)
  489. self.ui.ch_send_note_aftertouch.clicked.connect(self.slot_optionChanged)
  490. self.ui.ch_send_pitchbend.clicked.connect(self.slot_optionChanged)
  491. self.ui.ch_send_all_sound_off.clicked.connect(self.slot_optionChanged)
  492. self.ui.dial_drywet.realValueChanged.connect(self.slot_dryWetChanged)
  493. self.ui.dial_vol.realValueChanged.connect(self.slot_volumeChanged)
  494. self.ui.dial_b_left.realValueChanged.connect(self.slot_balanceLeftChanged)
  495. self.ui.dial_b_right.realValueChanged.connect(self.slot_balanceRightChanged)
  496. self.ui.dial_pan.realValueChanged.connect(self.slot_panChanged)
  497. self.ui.sb_ctrl_channel.valueChanged.connect(self.slot_ctrlChannelChanged)
  498. self.ui.dial_drywet.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  499. self.ui.dial_vol.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  500. self.ui.dial_b_left.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  501. self.ui.dial_b_right.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  502. self.ui.dial_pan.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  503. self.ui.sb_ctrl_channel.customContextMenuRequested.connect(self.slot_channelCustomMenu)
  504. self.ui.keyboard.noteOn.connect(self.slot_noteOn)
  505. self.ui.keyboard.noteOff.connect(self.slot_noteOff)
  506. self.ui.cb_programs.currentIndexChanged.connect(self.slot_programIndexChanged)
  507. self.ui.cb_midi_programs.currentIndexChanged.connect(self.slot_midiProgramIndexChanged)
  508. self.ui.b_save_state.clicked.connect(self.slot_stateSave)
  509. self.ui.b_load_state.clicked.connect(self.slot_stateLoad)
  510. host.NoteOnCallback.connect(self.slot_handleNoteOnCallback)
  511. host.NoteOffCallback.connect(self.slot_handleNoteOffCallback)
  512. host.UpdateCallback.connect(self.slot_handleUpdateCallback)
  513. host.ReloadInfoCallback.connect(self.slot_handleReloadInfoCallback)
  514. host.ReloadParametersCallback.connect(self.slot_handleReloadParametersCallback)
  515. host.ReloadProgramsCallback.connect(self.slot_handleReloadProgramsCallback)
  516. host.ReloadAllCallback.connect(self.slot_handleReloadAllCallback)
  517. #------------------------------------------------------------------
  518. @pyqtSlot(int, int, int, int)
  519. def slot_handleNoteOnCallback(self, pluginId, channel, note, velocity):
  520. if self.fPluginId != pluginId: return
  521. if self.fControlChannel == channel:
  522. self.ui.keyboard.sendNoteOn(note, False)
  523. playItem = (channel, note)
  524. if playItem not in self.fPlayingNotes:
  525. self.fPlayingNotes.append(playItem)
  526. if len(self.fPlayingNotes) == 1 and self.fParent is not None:
  527. self.fParent.editDialogMidiActivityChanged(self.fPluginId, True)
  528. @pyqtSlot(int, int, int)
  529. def slot_handleNoteOffCallback(self, pluginId, channel, note):
  530. if self.fPluginId != pluginId: return
  531. if self.fControlChannel == channel:
  532. self.ui.keyboard.sendNoteOff(note, False)
  533. playItem = (channel, note)
  534. if playItem in self.fPlayingNotes:
  535. self.fPlayingNotes.remove(playItem)
  536. if len(self.fPlayingNotes) == 0 and self.fParent is not None:
  537. self.fParent.editDialogMidiActivityChanged(self.fPluginId, False)
  538. @pyqtSlot(int)
  539. def slot_handleUpdateCallback(self, pluginId):
  540. if self.fPluginId == pluginId:
  541. self.updateInfo()
  542. @pyqtSlot(int)
  543. def slot_handleReloadInfoCallback(self, pluginId):
  544. if self.fPluginId == pluginId:
  545. self.reloadInfo()
  546. @pyqtSlot(int)
  547. def slot_handleReloadParametersCallback(self, pluginId):
  548. if self.fPluginId == pluginId:
  549. self.reloadParameters()
  550. @pyqtSlot(int)
  551. def slot_handleReloadProgramsCallback(self, pluginId):
  552. if self.fPluginId == pluginId:
  553. self.reloadPrograms()
  554. @pyqtSlot(int)
  555. def slot_handleReloadAllCallback(self, pluginId):
  556. if self.fPluginId == pluginId:
  557. self.reloadAll()
  558. #------------------------------------------------------------------
  559. def updateInfo(self):
  560. # Update current program text
  561. if self.ui.cb_programs.count() > 0:
  562. pIndex = self.ui.cb_programs.currentIndex()
  563. if pIndex >= 0:
  564. pName = self.host.get_program_name(self.fPluginId, pIndex)
  565. #pName = pName[:40] + (pName[40:] and "...")
  566. self.ui.cb_programs.setItemText(pIndex, pName)
  567. # Update current midi program text
  568. if self.ui.cb_midi_programs.count() > 0:
  569. mpIndex = self.ui.cb_midi_programs.currentIndex()
  570. if mpIndex >= 0:
  571. mpData = self.host.get_midi_program_data(self.fPluginId, mpIndex)
  572. mpBank = mpData['bank']
  573. mpProg = mpData['program']
  574. mpName = mpData['name']
  575. #mpName = mpName[:40] + (mpName[40:] and "...")
  576. self.ui.cb_midi_programs.setItemText(mpIndex, "%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  577. # Update all parameter values
  578. for paramType, paramId, paramWidget in self.fParameterList:
  579. paramWidget.blockSignals(True)
  580. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId))
  581. paramWidget.blockSignals(False)
  582. # and the internal ones too
  583. self.ui.dial_drywet.blockSignals(True)
  584. self.ui.dial_drywet.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_DRYWET))
  585. self.ui.dial_drywet.blockSignals(False)
  586. self.ui.dial_vol.blockSignals(True)
  587. self.ui.dial_vol.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_VOLUME))
  588. self.ui.dial_vol.blockSignals(False)
  589. self.ui.dial_b_left.blockSignals(True)
  590. self.ui.dial_b_left.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_BALANCE_LEFT))
  591. self.ui.dial_b_left.blockSignals(False)
  592. self.ui.dial_b_right.blockSignals(True)
  593. self.ui.dial_b_right.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_BALANCE_RIGHT))
  594. self.ui.dial_b_right.blockSignals(False)
  595. self.ui.dial_pan.blockSignals(True)
  596. self.ui.dial_pan.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_PANNING))
  597. self.ui.dial_pan.blockSignals(False)
  598. self.fControlChannel = round(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_CTRL_CHANNEL))
  599. self.ui.sb_ctrl_channel.blockSignals(True)
  600. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  601. self.ui.sb_ctrl_channel.blockSignals(False)
  602. self.ui.keyboard.allNotesOff()
  603. self._updateCtrlPrograms()
  604. self.fParametersToUpdate = []
  605. #------------------------------------------------------------------
  606. def reloadAll(self):
  607. self.fPluginInfo = self.host.get_plugin_info(self.fPluginId)
  608. self.reloadInfo()
  609. self.reloadParameters()
  610. self.reloadPrograms()
  611. if self.fPluginInfo['type'] == PLUGIN_LV2:
  612. self.ui.b_save_state.setEnabled(False)
  613. if not self.ui.scrollArea.isEnabled():
  614. self.resize(self.width(), self.height()-self.ui.scrollArea.height())
  615. #------------------------------------------------------------------
  616. def reloadInfo(self):
  617. realPluginName = self.host.get_real_plugin_name(self.fPluginId)
  618. #audioCountInfo = self.host.get_audio_port_count_info(self.fPluginId)
  619. midiCountInfo = self.host.get_midi_port_count_info(self.fPluginId)
  620. #paramCountInfo = self.host.get_parameter_count_info(self.fPluginId)
  621. pluginHints = self.fPluginInfo['hints']
  622. self.ui.le_type.setText(getPluginTypeAsString(self.fPluginInfo['type']))
  623. self.ui.label_name.setEnabled(bool(realPluginName))
  624. self.ui.le_name.setEnabled(bool(realPluginName))
  625. self.ui.le_name.setText(realPluginName)
  626. self.ui.le_name.setToolTip(realPluginName)
  627. self.ui.label_label.setEnabled(bool(self.fPluginInfo['label']))
  628. self.ui.le_label.setEnabled(bool(self.fPluginInfo['label']))
  629. self.ui.le_label.setText(self.fPluginInfo['label'])
  630. self.ui.le_label.setToolTip(self.fPluginInfo['label'])
  631. self.ui.label_maker.setEnabled(bool(self.fPluginInfo['maker']))
  632. self.ui.le_maker.setEnabled(bool(self.fPluginInfo['maker']))
  633. self.ui.le_maker.setText(self.fPluginInfo['maker'])
  634. self.ui.le_maker.setToolTip(self.fPluginInfo['maker'])
  635. self.ui.label_copyright.setEnabled(bool(self.fPluginInfo['copyright']))
  636. self.ui.le_copyright.setEnabled(bool(self.fPluginInfo['copyright']))
  637. self.ui.le_copyright.setText(self.fPluginInfo['copyright'])
  638. self.ui.le_copyright.setToolTip(self.fPluginInfo['copyright'])
  639. self.ui.label_unique_id.setEnabled(bool(self.fPluginInfo['uniqueId']))
  640. self.ui.le_unique_id.setEnabled(bool(self.fPluginInfo['uniqueId']))
  641. self.ui.le_unique_id.setText(str(self.fPluginInfo['uniqueId']))
  642. self.ui.le_unique_id.setToolTip(str(self.fPluginInfo['uniqueId']))
  643. self.ui.label_plugin.setText("\n%s\n" % (self.fPluginInfo['name'] or "(none)"))
  644. self.setWindowTitle(self.fPluginInfo['name'] or "(none)")
  645. self.ui.dial_drywet.setEnabled(pluginHints & PLUGIN_CAN_DRYWET)
  646. self.ui.dial_vol.setEnabled(pluginHints & PLUGIN_CAN_VOLUME)
  647. self.ui.dial_b_left.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  648. self.ui.dial_b_right.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  649. self.ui.dial_pan.setEnabled(pluginHints & PLUGIN_CAN_PANNING)
  650. self.ui.ch_use_chunks.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_USE_CHUNKS)
  651. self.ui.ch_use_chunks.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_USE_CHUNKS)
  652. self.ui.ch_fixed_buffer.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FIXED_BUFFERS)
  653. self.ui.ch_fixed_buffer.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FIXED_BUFFERS)
  654. self.ui.ch_force_stereo.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FORCE_STEREO)
  655. self.ui.ch_force_stereo.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FORCE_STEREO)
  656. self.ui.ch_map_program_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  657. self.ui.ch_map_program_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  658. self.ui.ch_send_control_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  659. self.ui.ch_send_control_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  660. self.ui.ch_send_channel_pressure.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  661. self.ui.ch_send_channel_pressure.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  662. self.ui.ch_send_note_aftertouch.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  663. self.ui.ch_send_note_aftertouch.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  664. self.ui.ch_send_pitchbend.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PITCHBEND)
  665. self.ui.ch_send_pitchbend.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_PITCHBEND)
  666. self.ui.ch_send_all_sound_off.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  667. self.ui.ch_send_all_sound_off.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  668. canSendPrograms = bool((self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PROGRAM_CHANGES) != 0 and
  669. (self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) == 0)
  670. self.ui.ch_send_program_changes.setEnabled(canSendPrograms)
  671. self.ui.ch_send_program_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_PROGRAM_CHANGES)
  672. self.ui.sw_programs.setCurrentIndex(0 if self.fPluginInfo['type'] in (PLUGIN_VST2, PLUGIN_SFZ) else 1)
  673. # Show/hide keyboard
  674. showKeyboard = (self.fPluginInfo['category'] == PLUGIN_CATEGORY_SYNTH or midiCountInfo['ins'] > 0)
  675. self.ui.scrollArea.setEnabled(showKeyboard)
  676. self.ui.scrollArea.setVisible(showKeyboard)
  677. # Force-update parent for new hints
  678. if self.fParent is not None and not self.fFirstInit:
  679. self.fParent.editDialogPluginHintsChanged(self.fPluginId, pluginHints)
  680. def reloadParameters(self):
  681. # Reset
  682. self.fParameterList = []
  683. self.fParametersToUpdate = []
  684. self.fTabIconTimers = []
  685. # Remove all previous parameters
  686. for x in range(self.ui.tabWidget.count()-1):
  687. self.ui.tabWidget.widget(1).deleteLater()
  688. self.ui.tabWidget.removeTab(1)
  689. parameterCount = self.host.get_parameter_count(self.fPluginId)
  690. # -----------------------------------------------------------------
  691. if parameterCount <= 0:
  692. return
  693. # -----------------------------------------------------------------
  694. paramInputList = []
  695. paramOutputList = []
  696. paramInputWidth = 0
  697. paramOutputWidth = 0
  698. paramInputListFull = [] # ([params], width)
  699. paramOutputListFull = [] # ([params], width)
  700. for i in range(min(parameterCount, self.host.maxParameters)):
  701. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  702. paramData = self.host.get_parameter_data(self.fPluginId, i)
  703. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  704. paramValue = self.host.get_current_parameter_value(self.fPluginId, i)
  705. if paramData['type'] not in (PARAMETER_INPUT, PARAMETER_OUTPUT):
  706. continue
  707. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  708. continue
  709. parameter = {
  710. 'type': paramData['type'],
  711. 'hints': paramData['hints'],
  712. 'name': paramInfo['name'],
  713. 'unit': paramInfo['unit'],
  714. 'scalePoints': [],
  715. 'index': paramData['index'],
  716. 'default': paramRanges['def'],
  717. 'minimum': paramRanges['min'],
  718. 'maximum': paramRanges['max'],
  719. 'step': paramRanges['step'],
  720. 'stepSmall': paramRanges['stepSmall'],
  721. 'stepLarge': paramRanges['stepLarge'],
  722. 'mappedControlIndex': paramData['mappedControlIndex'],
  723. 'mappedMinimum': paramData['mappedMinimum'],
  724. 'mappedMaximum': paramData['mappedMaximum'],
  725. 'midiChannel': paramData['midiChannel']+1,
  726. 'comment': paramInfo['comment'],
  727. 'groupName': paramInfo['groupName'],
  728. 'current': paramValue
  729. }
  730. for j in range(paramInfo['scalePointCount']):
  731. scalePointInfo = self.host.get_parameter_scalepoint_info(self.fPluginId, i, j)
  732. parameter['scalePoints'].append({
  733. 'value': scalePointInfo['value'],
  734. 'label': scalePointInfo['label']
  735. })
  736. #parameter['name'] = parameter['name'][:30] + (parameter['name'][30:] and "...")
  737. # -----------------------------------------------------------------
  738. # Get width values, in packs of 20
  739. if parameter['type'] == PARAMETER_INPUT:
  740. paramInputWidthTMP = fontMetricsHorizontalAdvance(self.fontMetrics(), parameter['name'])
  741. if paramInputWidthTMP > paramInputWidth:
  742. paramInputWidth = paramInputWidthTMP
  743. paramInputList.append(parameter)
  744. else:
  745. paramOutputWidthTMP = fontMetricsHorizontalAdvance(self.fontMetrics(), parameter['name'])
  746. if paramOutputWidthTMP > paramOutputWidth:
  747. paramOutputWidth = paramOutputWidthTMP
  748. paramOutputList.append(parameter)
  749. paramInputListFull.append((paramInputList, paramInputWidth))
  750. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  751. # Create parameter tabs + widgets
  752. self._createParameterWidgets(PARAMETER_INPUT, paramInputListFull, self.tr("Parameters"))
  753. self._createParameterWidgets(PARAMETER_OUTPUT, paramOutputListFull, self.tr("Outputs"))
  754. def reloadPrograms(self):
  755. # Programs
  756. self.ui.cb_programs.blockSignals(True)
  757. self.ui.cb_programs.clear()
  758. programCount = self.host.get_program_count(self.fPluginId)
  759. if programCount > 0:
  760. self.ui.cb_programs.setEnabled(True)
  761. self.ui.label_programs.setEnabled(True)
  762. for i in range(programCount):
  763. pName = self.host.get_program_name(self.fPluginId, i)
  764. #pName = pName[:40] + (pName[40:] and "...")
  765. self.ui.cb_programs.addItem(pName)
  766. self.ui.cb_programs.setCurrentIndex(self.host.get_current_program_index(self.fPluginId))
  767. else:
  768. self.ui.cb_programs.setEnabled(False)
  769. self.ui.label_programs.setEnabled(False)
  770. self.ui.cb_programs.blockSignals(False)
  771. # MIDI Programs
  772. self.ui.cb_midi_programs.blockSignals(True)
  773. self.ui.cb_midi_programs.clear()
  774. midiProgramCount = self.host.get_midi_program_count(self.fPluginId)
  775. if midiProgramCount > 0:
  776. self.ui.cb_midi_programs.setEnabled(True)
  777. self.ui.label_midi_programs.setEnabled(True)
  778. for i in range(midiProgramCount):
  779. mpData = self.host.get_midi_program_data(self.fPluginId, i)
  780. mpBank = mpData['bank']
  781. mpProg = mpData['program']
  782. mpName = mpData['name']
  783. #mpName = mpName[:40] + (mpName[40:] and "...")
  784. self.ui.cb_midi_programs.addItem("%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  785. self.ui.cb_midi_programs.setCurrentIndex(self.host.get_current_midi_program_index(self.fPluginId))
  786. else:
  787. self.ui.cb_midi_programs.setEnabled(False)
  788. self.ui.label_midi_programs.setEnabled(False)
  789. self.ui.cb_midi_programs.blockSignals(False)
  790. self.ui.sw_programs.setEnabled(programCount > 0 or midiProgramCount > 0)
  791. if self.fPluginInfo['type'] == PLUGIN_LV2:
  792. self.ui.b_load_state.setEnabled(programCount > 0)
  793. #------------------------------------------------------------------
  794. def clearNotes(self):
  795. self.fPlayingNotes = []
  796. self.ui.keyboard.allNotesOff()
  797. def noteOn(self, channel, note, velocity):
  798. if self.fControlChannel == channel:
  799. self.ui.keyboard.sendNoteOn(note, False)
  800. def noteOff(self, channel, note):
  801. if self.fControlChannel == channel:
  802. self.ui.keyboard.sendNoteOff(note, False)
  803. #------------------------------------------------------------------
  804. def getHints(self):
  805. return self.fPluginInfo['hints']
  806. def setPluginId(self, idx):
  807. self.fPluginId = idx
  808. def setName(self, name):
  809. self.fPluginInfo['name'] = name
  810. self.ui.label_plugin.setText("\n%s\n" % name)
  811. self.setWindowTitle(name)
  812. #------------------------------------------------------------------
  813. def setParameterValue(self, parameterId, value):
  814. for paramItem in self.fParametersToUpdate:
  815. if paramItem[0] == parameterId:
  816. paramItem[1] = value
  817. break
  818. else:
  819. self.fParametersToUpdate.append([parameterId, value])
  820. def setParameterDefault(self, parameterId, value):
  821. for paramType, paramId, paramWidget in self.fParameterList:
  822. if paramId == parameterId:
  823. paramWidget.setDefault(value)
  824. break
  825. def setParameterMappedControlIndex(self, parameterId, control):
  826. for paramType, paramId, paramWidget in self.fParameterList:
  827. if paramId == parameterId:
  828. paramWidget.setMappedControlIndex(control)
  829. break
  830. def setParameterMappedRange(self, parameterId, minimum, maximum):
  831. for paramType, paramId, paramWidget in self.fParameterList:
  832. if paramId == parameterId:
  833. paramWidget.setMappedRange(minimum, maximum)
  834. break
  835. def setParameterMidiChannel(self, parameterId, channel):
  836. for paramType, paramId, paramWidget in self.fParameterList:
  837. if paramId == parameterId:
  838. paramWidget.setMidiChannel(channel+1)
  839. break
  840. def setProgram(self, index):
  841. self.ui.cb_programs.blockSignals(True)
  842. self.ui.cb_programs.setCurrentIndex(index)
  843. self.ui.cb_programs.blockSignals(False)
  844. self._updateParameterValues()
  845. def setMidiProgram(self, index):
  846. self.ui.cb_midi_programs.blockSignals(True)
  847. self.ui.cb_midi_programs.setCurrentIndex(index)
  848. self.ui.cb_midi_programs.blockSignals(False)
  849. self._updateParameterValues()
  850. def setOption(self, option, yesNo):
  851. if option == PLUGIN_OPTION_USE_CHUNKS:
  852. widget = self.ui.ch_use_chunks
  853. elif option == PLUGIN_OPTION_FIXED_BUFFERS:
  854. widget = self.ui.ch_fixed_buffer
  855. elif option == PLUGIN_OPTION_FORCE_STEREO:
  856. widget = self.ui.ch_force_stereo
  857. elif option == PLUGIN_OPTION_MAP_PROGRAM_CHANGES:
  858. widget = self.ui.ch_map_program_changes
  859. elif option == PLUGIN_OPTION_SEND_PROGRAM_CHANGES:
  860. widget = self.ui.ch_send_program_changes
  861. elif option == PLUGIN_OPTION_SEND_CONTROL_CHANGES:
  862. widget = self.ui.ch_send_control_changes
  863. elif option == PLUGIN_OPTION_SEND_CHANNEL_PRESSURE:
  864. widget = self.ui.ch_send_channel_pressure
  865. elif option == PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH:
  866. widget = self.ui.ch_send_note_aftertouch
  867. elif option == PLUGIN_OPTION_SEND_PITCHBEND:
  868. widget = self.ui.ch_send_pitchbend
  869. elif option == PLUGIN_OPTION_SEND_ALL_SOUND_OFF:
  870. widget = self.ui.ch_send_all_sound_off
  871. else:
  872. return
  873. widget.blockSignals(True)
  874. widget.setChecked(yesNo)
  875. widget.blockSignals(False)
  876. #------------------------------------------------------------------
  877. def setVisible(self, yesNo):
  878. if yesNo:
  879. if not self.fGeometry.isNull():
  880. self.restoreGeometry(self.fGeometry)
  881. else:
  882. self.fGeometry = self.saveGeometry()
  883. QDialog.setVisible(self, yesNo)
  884. #------------------------------------------------------------------
  885. def idleSlow(self):
  886. # Check Tab icons
  887. for i in range(len(self.fTabIconTimers)):
  888. if self.fTabIconTimers[i] == ICON_STATE_ON:
  889. self.fTabIconTimers[i] = ICON_STATE_WAIT
  890. elif self.fTabIconTimers[i] == ICON_STATE_WAIT:
  891. self.fTabIconTimers[i] = ICON_STATE_OFF
  892. elif self.fTabIconTimers[i] == ICON_STATE_OFF:
  893. self.fTabIconTimers[i] = ICON_STATE_NULL
  894. self.ui.tabWidget.setTabIcon(i+1, self.fTabIconOff)
  895. # Check parameters needing update
  896. for index, value in self.fParametersToUpdate:
  897. if index == PARAMETER_DRYWET:
  898. self.ui.dial_drywet.blockSignals(True)
  899. self.ui.dial_drywet.setValue(value)
  900. self.ui.dial_drywet.blockSignals(False)
  901. elif index == PARAMETER_VOLUME:
  902. self.ui.dial_vol.blockSignals(True)
  903. self.ui.dial_vol.setValue(value)
  904. self.ui.dial_vol.blockSignals(False)
  905. elif index == PARAMETER_BALANCE_LEFT:
  906. self.ui.dial_b_left.blockSignals(True)
  907. self.ui.dial_b_left.setValue(value)
  908. self.ui.dial_b_left.blockSignals(False)
  909. elif index == PARAMETER_BALANCE_RIGHT:
  910. self.ui.dial_b_right.blockSignals(True)
  911. self.ui.dial_b_right.setValue(value)
  912. self.ui.dial_b_right.blockSignals(False)
  913. elif index == PARAMETER_PANNING:
  914. self.ui.dial_pan.blockSignals(True)
  915. self.ui.dial_pan.setValue(value)
  916. self.ui.dial_pan.blockSignals(False)
  917. elif index == PARAMETER_CTRL_CHANNEL:
  918. self.fControlChannel = round(value)
  919. self.ui.sb_ctrl_channel.blockSignals(True)
  920. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  921. self.ui.sb_ctrl_channel.blockSignals(False)
  922. self.ui.keyboard.allNotesOff()
  923. self._updateCtrlPrograms()
  924. elif index >= 0:
  925. for paramType, paramId, paramWidget in self.fParameterList:
  926. if paramId != index:
  927. continue
  928. # FIXME see below
  929. if paramType != PARAMETER_INPUT:
  930. continue
  931. paramWidget.blockSignals(True)
  932. paramWidget.setValue(value)
  933. paramWidget.blockSignals(False)
  934. #if paramType == PARAMETER_INPUT:
  935. tabIndex = paramWidget.getTabIndex()
  936. if self.fTabIconTimers[tabIndex-1] == ICON_STATE_NULL:
  937. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOn)
  938. self.fTabIconTimers[tabIndex-1] = ICON_STATE_ON
  939. break
  940. # Clear all parameters
  941. self.fParametersToUpdate = []
  942. # Update parameter outputs | FIXME needed?
  943. for paramType, paramId, paramWidget in self.fParameterList:
  944. if paramType != PARAMETER_OUTPUT:
  945. continue
  946. paramWidget.blockSignals(True)
  947. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId))
  948. paramWidget.blockSignals(False)
  949. #------------------------------------------------------------------
  950. @pyqtSlot()
  951. def slot_stateSave(self):
  952. if self.fPluginInfo['type'] == PLUGIN_LV2:
  953. # TODO
  954. return
  955. if self.fCurrentStateFilename:
  956. askTry = QMessageBox.question(self, self.tr("Overwrite?"), self.tr("Overwrite previously created file?"), QMessageBox.Ok|QMessageBox.Cancel)
  957. if askTry == QMessageBox.Ok:
  958. self.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  959. return
  960. self.fCurrentStateFilename = None
  961. fileFilter = self.tr("Carla State File (*.carxs)")
  962. filename, ok = QFileDialog.getSaveFileName(self, self.tr("Save Plugin State File"), filter=fileFilter)
  963. # FIXME use ok value, test if it works as expected
  964. if not filename:
  965. return
  966. if not filename.lower().endswith(".carxs"):
  967. filename += ".carxs"
  968. self.fCurrentStateFilename = filename
  969. self.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  970. @pyqtSlot()
  971. def slot_stateLoad(self):
  972. if self.fPluginInfo['type'] == PLUGIN_LV2:
  973. presetList = []
  974. for i in range(self.host.get_program_count(self.fPluginId)):
  975. presetList.append("%03i - %s" % (i+1, self.host.get_program_name(self.fPluginId, i)))
  976. ret = QInputDialog.getItem(self, self.tr("Open LV2 Preset"), self.tr("Select an LV2 Preset:"), presetList, 0, False)
  977. if ret[1]:
  978. index = int(ret[0].split(" - ", 1)[0])-1
  979. self.host.set_program(self.fPluginId, index)
  980. self.setMidiProgram(-1)
  981. return
  982. fileFilter = self.tr("Carla State File (*.carxs)")
  983. filename, ok = QFileDialog.getOpenFileName(self, self.tr("Open Plugin State File"), filter=fileFilter)
  984. # FIXME use ok value, test if it works as expected
  985. if not filename:
  986. return
  987. self.fCurrentStateFilename = filename
  988. self.host.load_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  989. #------------------------------------------------------------------
  990. @pyqtSlot(bool)
  991. def slot_optionChanged(self, clicked):
  992. sender = self.sender()
  993. if sender == self.ui.ch_use_chunks:
  994. option = PLUGIN_OPTION_USE_CHUNKS
  995. elif sender == self.ui.ch_fixed_buffer:
  996. option = PLUGIN_OPTION_FIXED_BUFFERS
  997. elif sender == self.ui.ch_force_stereo:
  998. option = PLUGIN_OPTION_FORCE_STEREO
  999. elif sender == self.ui.ch_map_program_changes:
  1000. option = PLUGIN_OPTION_MAP_PROGRAM_CHANGES
  1001. elif sender == self.ui.ch_send_program_changes:
  1002. option = PLUGIN_OPTION_SEND_PROGRAM_CHANGES
  1003. elif sender == self.ui.ch_send_control_changes:
  1004. option = PLUGIN_OPTION_SEND_CONTROL_CHANGES
  1005. elif sender == self.ui.ch_send_channel_pressure:
  1006. option = PLUGIN_OPTION_SEND_CHANNEL_PRESSURE
  1007. elif sender == self.ui.ch_send_note_aftertouch:
  1008. option = PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH
  1009. elif sender == self.ui.ch_send_pitchbend:
  1010. option = PLUGIN_OPTION_SEND_PITCHBEND
  1011. elif sender == self.ui.ch_send_all_sound_off:
  1012. option = PLUGIN_OPTION_SEND_ALL_SOUND_OFF
  1013. else:
  1014. return
  1015. #--------------------------------------------------------------
  1016. # handle map-program-changes and send-program-changes conflict
  1017. if option == PLUGIN_OPTION_MAP_PROGRAM_CHANGES and clicked:
  1018. self.ui.ch_send_program_changes.setEnabled(False)
  1019. # disable send-program-changes if needed
  1020. if self.ui.ch_send_program_changes.isChecked():
  1021. self.host.set_option(self.fPluginId, PLUGIN_OPTION_SEND_PROGRAM_CHANGES, False)
  1022. #--------------------------------------------------------------
  1023. # set option
  1024. self.host.set_option(self.fPluginId, option, clicked)
  1025. #--------------------------------------------------------------
  1026. # handle map-program-changes and send-program-changes conflict
  1027. if option == PLUGIN_OPTION_MAP_PROGRAM_CHANGES and not clicked:
  1028. self.ui.ch_send_program_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PROGRAM_CHANGES)
  1029. # restore send-program-changes if needed
  1030. if self.ui.ch_send_program_changes.isChecked():
  1031. self.host.set_option(self.fPluginId, PLUGIN_OPTION_SEND_PROGRAM_CHANGES, True)
  1032. #------------------------------------------------------------------
  1033. @pyqtSlot(float)
  1034. def slot_dryWetChanged(self, value):
  1035. self.host.set_drywet(self.fPluginId, value)
  1036. if self.fParent is not None:
  1037. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_DRYWET, value)
  1038. @pyqtSlot(float)
  1039. def slot_volumeChanged(self, value):
  1040. self.host.set_volume(self.fPluginId, value)
  1041. if self.fParent is not None:
  1042. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_VOLUME, value)
  1043. @pyqtSlot(float)
  1044. def slot_balanceLeftChanged(self, value):
  1045. self.host.set_balance_left(self.fPluginId, value)
  1046. if self.fParent is not None:
  1047. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_BALANCE_LEFT, value)
  1048. @pyqtSlot(float)
  1049. def slot_balanceRightChanged(self, value):
  1050. self.host.set_balance_right(self.fPluginId, value)
  1051. if self.fParent is not None:
  1052. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_BALANCE_RIGHT, value)
  1053. @pyqtSlot(float)
  1054. def slot_panChanged(self, value):
  1055. self.host.set_panning(self.fPluginId, value)
  1056. if self.fParent is not None:
  1057. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_PANNING, value)
  1058. @pyqtSlot(int)
  1059. def slot_ctrlChannelChanged(self, value):
  1060. self.fControlChannel = value-1
  1061. self.host.set_ctrl_channel(self.fPluginId, self.fControlChannel)
  1062. self.ui.keyboard.allNotesOff()
  1063. self._updateCtrlPrograms()
  1064. #------------------------------------------------------------------
  1065. @pyqtSlot(int, float)
  1066. def slot_parameterValueChanged(self, parameterId, value):
  1067. self.host.set_parameter_value(self.fPluginId, parameterId, value)
  1068. if self.fParent is not None:
  1069. self.fParent.editDialogParameterValueChanged(self.fPluginId, parameterId, value)
  1070. @pyqtSlot(int, int)
  1071. def slot_parameterMappedControlChanged(self, parameterId, control):
  1072. self.host.set_parameter_mapped_control_index(self.fPluginId, parameterId, control)
  1073. @pyqtSlot(int, int)
  1074. def slot_parameterMidiChannelChanged(self, parameterId, channel):
  1075. self.host.set_parameter_midi_channel(self.fPluginId, parameterId, channel-1)
  1076. #------------------------------------------------------------------
  1077. @pyqtSlot(int)
  1078. def slot_programIndexChanged(self, index):
  1079. self.host.set_program(self.fPluginId, index)
  1080. if self.fParent is not None:
  1081. self.fParent.editDialogProgramChanged(self.fPluginId, index)
  1082. self._updateParameterValues()
  1083. @pyqtSlot(int)
  1084. def slot_midiProgramIndexChanged(self, index):
  1085. self.host.set_midi_program(self.fPluginId, index)
  1086. if self.fParent is not None:
  1087. self.fParent.editDialogMidiProgramChanged(self.fPluginId, index)
  1088. self._updateParameterValues()
  1089. #------------------------------------------------------------------
  1090. @pyqtSlot(int)
  1091. def slot_noteOn(self, note):
  1092. if self.fControlChannel >= 0:
  1093. self.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 100)
  1094. if self.fParent is not None:
  1095. self.fParent.editDialogNotePressed(self.fPluginId, note)
  1096. @pyqtSlot(int)
  1097. def slot_noteOff(self, note):
  1098. if self.fControlChannel >= 0:
  1099. self.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 0)
  1100. if self.fParent is not None:
  1101. self.fParent.editDialogNoteReleased(self.fPluginId, note)
  1102. #------------------------------------------------------------------
  1103. @pyqtSlot()
  1104. def slot_finished(self):
  1105. if self.fParent is not None:
  1106. self.fParent.editDialogVisibilityChanged(self.fPluginId, False)
  1107. #------------------------------------------------------------------
  1108. @pyqtSlot()
  1109. def slot_knobCustomMenu(self):
  1110. sender = self.sender()
  1111. knobName = sender.objectName()
  1112. if knobName == "dial_drywet":
  1113. minimum = 0.0
  1114. maximum = 1.0
  1115. default = 1.0
  1116. label = "Dry/Wet"
  1117. elif knobName == "dial_vol":
  1118. minimum = 0.0
  1119. maximum = 1.27
  1120. default = 1.0
  1121. label = "Volume"
  1122. elif knobName == "dial_b_left":
  1123. minimum = -1.0
  1124. maximum = 1.0
  1125. default = -1.0
  1126. label = "Balance-Left"
  1127. elif knobName == "dial_b_right":
  1128. minimum = -1.0
  1129. maximum = 1.0
  1130. default = 1.0
  1131. label = "Balance-Right"
  1132. elif knobName == "dial_pan":
  1133. minimum = -1.0
  1134. maximum = 1.0
  1135. default = 0.0
  1136. label = "Panning"
  1137. else:
  1138. minimum = 0.0
  1139. maximum = 1.0
  1140. default = 0.5
  1141. label = "Unknown"
  1142. menu = QMenu(self)
  1143. actReset = menu.addAction(self.tr("Reset (%i%%)" % (default*100)))
  1144. menu.addSeparator()
  1145. actMinimum = menu.addAction(self.tr("Set to Minimum (%i%%)" % (minimum*100)))
  1146. actCenter = menu.addAction(self.tr("Set to Center"))
  1147. actMaximum = menu.addAction(self.tr("Set to Maximum (%i%%)" % (maximum*100)))
  1148. menu.addSeparator()
  1149. actSet = menu.addAction(self.tr("Set value..."))
  1150. if label not in ("Balance-Left", "Balance-Right", "Panning"):
  1151. menu.removeAction(actCenter)
  1152. actSelected = menu.exec_(QCursor.pos())
  1153. if actSelected == actSet:
  1154. current = minimum + (maximum-minimum)*(float(sender.value())/10000)
  1155. value, ok = QInputDialog.getInt(self, self.tr("Set value"), label, round(current*100.0), round(minimum*100.0), round(maximum*100.0), 1)
  1156. if ok: value = float(value)/100.0
  1157. if not ok:
  1158. return
  1159. elif actSelected == actMinimum:
  1160. value = minimum
  1161. elif actSelected == actMaximum:
  1162. value = maximum
  1163. elif actSelected == actReset:
  1164. value = default
  1165. elif actSelected == actCenter:
  1166. value = 0.0
  1167. else:
  1168. return
  1169. sender.setValue(value, True)
  1170. #------------------------------------------------------------------
  1171. @pyqtSlot()
  1172. def slot_channelCustomMenu(self):
  1173. menu = QMenu(self)
  1174. actNone = menu.addAction(self.tr("None"))
  1175. if self.fControlChannel+1 == 0:
  1176. actNone.setCheckable(True)
  1177. actNone.setChecked(True)
  1178. for i in range(1, 16+1):
  1179. action = menu.addAction("%i" % i)
  1180. if self.fControlChannel+1 == i:
  1181. action.setCheckable(True)
  1182. action.setChecked(True)
  1183. actSel = menu.exec_(QCursor.pos())
  1184. if not actSel:
  1185. pass
  1186. elif actSel == actNone:
  1187. self.ui.sb_ctrl_channel.setValue(0)
  1188. elif actSel:
  1189. selChannel = int(actSel.text())
  1190. self.ui.sb_ctrl_channel.setValue(selChannel)
  1191. #------------------------------------------------------------------
  1192. def _createParameterWidgets(self, paramType, paramListFull, tabPageName):
  1193. groupWidgets = {}
  1194. for paramList, width in paramListFull:
  1195. if len(paramList) == 0:
  1196. break
  1197. tabIndex = self.ui.tabWidget.count()
  1198. scrollArea = QScrollArea(self.ui.tabWidget)
  1199. scrollArea.setWidgetResizable(True)
  1200. scrollArea.setFrameStyle(0)
  1201. palette1 = scrollArea.palette()
  1202. palette1.setColor(QPalette.Background, Qt.transparent)
  1203. scrollArea.setPalette(palette1)
  1204. palette2 = scrollArea.palette()
  1205. palette2.setColor(QPalette.Background, palette2.color(QPalette.Button))
  1206. scrollAreaWidget = QWidget(scrollArea)
  1207. scrollAreaLayout = QVBoxLayout(scrollAreaWidget)
  1208. scrollAreaLayout.setSpacing(3)
  1209. for paramInfo in paramList:
  1210. groupName = paramInfo['groupName']
  1211. if groupName:
  1212. groupSymbol, groupName = groupName.split(":",1)
  1213. groupLayout, groupWidget = groupWidgets.get(groupSymbol, (None, None))
  1214. if groupLayout is None:
  1215. groupWidget = CollapsibleBox(groupName, scrollAreaWidget)
  1216. groupLayout = groupWidget.getContentLayout()
  1217. groupWidget.setPalette(palette2)
  1218. scrollAreaLayout.addWidget(groupWidget)
  1219. groupWidgets[groupSymbol] = (groupLayout, groupWidget)
  1220. else:
  1221. groupLayout = scrollAreaLayout
  1222. groupWidget = scrollAreaWidget
  1223. paramWidget = PluginParameter(groupWidget, self.host, paramInfo, self.fPluginId, tabIndex)
  1224. paramWidget.setLabelWidth(width)
  1225. groupLayout.addWidget(paramWidget)
  1226. self.fParameterList.append((paramType, paramInfo['index'], paramWidget))
  1227. if paramType == PARAMETER_INPUT:
  1228. paramWidget.valueChanged.connect(self.slot_parameterValueChanged)
  1229. paramWidget.mappedControlChanged.connect(self.slot_parameterMappedControlChanged)
  1230. paramWidget.midiChannelChanged.connect(self.slot_parameterMidiChannelChanged)
  1231. scrollAreaLayout.addStretch()
  1232. scrollArea.setWidget(scrollAreaWidget)
  1233. self.ui.tabWidget.addTab(scrollArea, tabPageName)
  1234. if paramType == PARAMETER_INPUT:
  1235. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOff)
  1236. self.fTabIconTimers.append(ICON_STATE_NULL)
  1237. def _updateCtrlPrograms(self):
  1238. self.ui.keyboard.setEnabled(self.fControlChannel >= 0)
  1239. if self.fPluginInfo['category'] != PLUGIN_CATEGORY_SYNTH or self.fPluginInfo['type'] not in (PLUGIN_INTERNAL, PLUGIN_SF2):
  1240. return
  1241. if self.fControlChannel < 0:
  1242. self.ui.cb_programs.setEnabled(False)
  1243. self.ui.cb_midi_programs.setEnabled(False)
  1244. return
  1245. self.ui.cb_programs.setEnabled(True)
  1246. self.ui.cb_midi_programs.setEnabled(True)
  1247. pIndex = self.host.get_current_program_index(self.fPluginId)
  1248. if self.ui.cb_programs.currentIndex() != pIndex:
  1249. self.setProgram(pIndex)
  1250. mpIndex = self.host.get_current_midi_program_index(self.fPluginId)
  1251. if self.ui.cb_midi_programs.currentIndex() != mpIndex:
  1252. self.setMidiProgram(mpIndex)
  1253. def _updateParameterValues(self):
  1254. for paramType, paramId, paramWidget in self.fParameterList:
  1255. paramWidget.blockSignals(True)
  1256. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId))
  1257. paramWidget.blockSignals(False)
  1258. #------------------------------------------------------------------
  1259. def testTimer(self):
  1260. self.fIdleTimerId = self.startTimer(50)
  1261. self.SIGTERM.connect(self.testTimerClose)
  1262. gCarla.gui = self
  1263. setUpSignals()
  1264. def testTimerClose(self):
  1265. self.close()
  1266. app.quit()
  1267. #------------------------------------------------------------------
  1268. def closeEvent(self, event):
  1269. if self.fIdleTimerId != 0:
  1270. self.killTimer(self.fIdleTimerId)
  1271. self.fIdleTimerId = 0
  1272. self.host.engine_close()
  1273. QDialog.closeEvent(self, event)
  1274. def timerEvent(self, event):
  1275. if event.timerId() == self.fIdleTimerId:
  1276. self.host.engine_idle()
  1277. self.idleSlow()
  1278. QDialog.timerEvent(self, event)
  1279. def done(self, r):
  1280. QDialog.done(self, r)
  1281. self.close()
  1282. # ------------------------------------------------------------------------------------------------------------
  1283. # Main
  1284. if __name__ == '__main__':
  1285. from carla_app import CarlaApplication
  1286. from carla_host import initHost, loadHostSettings
  1287. app = CarlaApplication()
  1288. host = initHost("Widgets", None, False, False, False)
  1289. loadHostSettings(host)
  1290. host.engine_init("JACK", "Carla-Widgets")
  1291. host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None, 0x0)
  1292. host.set_active(0, True)
  1293. gui1 = CarlaAboutW(None, host)
  1294. gui1.show()
  1295. gui2 = PluginEdit(None, host, 0)
  1296. gui2.testTimer()
  1297. gui2.show()
  1298. app.exit_exec()