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.

carla_widgets.py 63KB

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