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 64KB

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