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